code cleanups, remove closed sockets