Fix some ORM bugs.