Fix memory leak.
Mark sockets for deletion as soon as disconnected.
Fix compilation with Qt 5.0.0.