some server refactoring