Code cleanup on server.js

Sockets get their own file amongst other changes.