Fixed a bug where certain objects could not be added to the repositories.

Fixed a bug where an infinite loop would occur due to recursion.
Fixed bugs where certain objects could not have their primary keys determined.