Cache bugfixes.
Cache bugfixes and added stats.