Db refactor

Still looking like "Hackathon" code. Most objects are still uncovered with tests. This is bad.
I don't want this branch to live any longer though. Risking running into merge conflicts.