Fixed bugs with ORM