Bugfixes on the socket