Fix bug of null pointers.