Added a custom Application object for managing a global state.
Added a lot of database access improvements.