Fixed a null pointer bug.