Fixed erroneous checks for NULL pointers.