Fixed MOC hierarchy, saving and permanent object ID resolution.
Permanent IDs are now properly generated before save.