Refactored some server.rb code