Fixes for PDI-3813 - reference fields with null values caused an exception

Handle null reference field correctly.