Did some minor refactoring of server.