Fixed a rare/possible null pointer exception