Get rid of db dependencies on main

The codebase as it exists right now has a number of unnecessary dependencies which makes code modularization much more difficult. This branch is an attempt to clean some of that up.