Refactored everything but the server code.