Some ORM fixes