Fixes various deadlocks & other issues in the TCP Connector

Requires further testing before merge.