Adjust dependent code to handle exceptions from get_unit_by_ref