Dismember modules

Some refactoring to make the code more maintainable - pretty much just splitting the server module into submodules.