Adds a basic write queue.

There's a bit more work to do before this can be merged, but it's ready for review as-is.