Added some more null checks