Fix Issue #5 and a null pointer exception introduced in the previous commit.