Implemented object referencing using id-fields

This is a workaround to solve AFM-33 where we end up with duplicate
objects when we use object references.