Fix missing null checks in previous commit.