code clean up + fixes in settings.py