Added missing null checks