Refactor the server