IMP add reference type mapping, FIX model external id reference so that can be updated with different databases, minor fixes