Minor improvements to caching code.
Minor improvements to caching code.