migrate wsgi and some cleanups