ORM refactoring