Refactoring server

#262