Move the complete dbsession stuff into model.py