Bugfixes in cache, tidying up comments, and bugfix in test code.
Fixing up tests, fixing a range of issues noted while fixing up tests.