Moved ORM code from DB to the model package