Use Flask application context for resource management; misc

This PR introduces the use of flask.g, using it to manage the life cycle of various resources such as storage managers, Riemann client, etc.

In addition, some misc fixes, including:
- using explicit absolute imports
- reorganizing some imports to maintain readable order and easily scan-able dependencies : built-ins first, 3rd party later, our own package last
-