Server refactoring

Refactored server for easier to read/more efficient code, commenting, and passing checkstyle.