Adding some missing Null Checks.

Added to avoid possible Null Pointer dereference.