Refactor around channels instead of locks.

This does not fully work yet and I'm not sure why.

For comment only...
This looks very similar to #632. Can we close #632 in favor of this pr