Merge pull request #46 from mcamou/#40

Fixed a bug in fetch_by_id when inheritance is :leaf
Fix :class inheritance when you have references