WIP: Refactoring to extract server functionality from rest of client
WIP: Further cleanup