QA-6788

Backport fixes from 6.6 to 7.0 avoid exception if reference is not available