Refactored to work with uWSGI