Fixed an occasional null pointer exception.