Rewrite most of SocketWrapper and friends