Reworked server code to be more object oriented