Completely refactored everything to work correctly with Django.