added simple caching, for use with enumeration