Bugfixes from previous commit, move models into db module

DBSession and Base are left in db/__init__.py