Refactor: Cleaning up Socket.io front-end code