Fixes for cleaning up after disconnected sockets.