Fixed a null pointer
Merged Simon's pull request #16.