Refactoring server code to provide better routing.