Db cleanup

Looks like the new db class was created in a hurry and left a lot of work to do