Return app factory to server.py
helper for conditional registration of teardown handler
fix riemann_client use of flask.g to support app factory
cleanup
reorganize imports; cleanup some code to reduce boilerplate; use app-factory compatible setup on flask.g
fix teardown handler registration
cleanup; use correct get_blueprints_manager
fix