NPE fix introduced another issue, this fixes both
Merge pull request #15 from timf/caching-recursion-issue

NPE fix introduced another issue, this fixes both