Refactoring for the server code.