Fix problems with NULL pointers.