initial socket.io for msgs; assorted refactors/bug fixes