Add missing NPE checks.