Null pointer checks added.