Rewrite Reference and ReferenceList fields on import

Fixes STUD-149.