Clean up WSGI server

Further clean up this module. Still needs to be optimized.