This fixes a problem where Metacube blocks are not deterministically added
for each add_data() call (because they would only be added for each call to
process_queued_data()), causing the different servers to go out of sync.
Also moved most of this logic to Stream, where it seems more appropriate
(even though the mutexes are a bit odd now).