Refactor Server (nearly done!)