Fixes potential NPE when nulling invisible objects.