server refactoring complete'ish