Added cardinality caching.