Some cleanup and a fix for the socket which was getting reclaimed by ARC.