Cleaned up server code