ReferenceField optimization: translate string to reference only when needed in order to avoid zillions of queries
added tests and fixes for more edge cases regarding ReferenceField