made it self-contained, cleaned up  server code
made it self-contained, cleaned up  server code