fixed bugs where ref_objects got overwritten