Use channels for the queue.

Chunks of the queue are only processed when they are fully written to.

This is a manual merge of the redo branch.