Refactor around channels instead of locks.

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

For comment only...
Your call. I put this here first and realized that you guys may not want a full rewrite, so I factored out what I thought the most important changes were to #632 if that was more appealing.

FWIW: I rewrote the client as part of understanding it. I prefer the use of channels like this as it makes it clearer to me and provides hints to the runtime wrt scheduling.