Fix crash due to null pointer exception.