major server refactor