Fix bugs in null pointers