Flask app refactoring

- app-wide objects continue being memorized
- app-wide objects can be accessed through the app object
- tidy up the setup pieces

Merge with care, deployment functionality hasn't been tested (sentry, mail, twitter).

Also, the actual utility of this commit is debatable, it's only decoupling and syntactic sugar.