Improved disconnection handling
Improved mutex safety