Added fix for race condition which leads to channels blocking on write

Looks like the order of things happening is causing code to execute in an order which causes a blocking write to a channel.

This change enables things to coalesce without locking up.

Fixes #4