Code cleanup; trying to nail some bugs when deploying on uWSGI with nginx