backport memoiziation from 3.0
Merge pull request #63 from github/memoize-nil-check

make sure nil isn't memoized and frozen