Major refactoring

Server was getting too convoluted. Had to break it up.