Wsgi cleanup

Cleanup code for wsgi, set sensible defaults for dev/test/live databases.