Purify the cache check.

Now fully parametric, except for debugln.