ORM query fixes.