Some fixes to sockets