Take care of some security flaws, typos, and dangling sockets.