clean up server code a bit