fixed several errors related to looking things up by Reference fields.