Added some nullpointer checks
Update header