Overhaul of server code