Improve multi-thread behavior and error pathes of send and recv

Previously there were error paths which would result in a lost context
and there were interleavings when two threads were working on the same
Connection where their outputs would interleave incorrectly