Fixed blocking reception.
Added proper handling of disconnections.