Various minor fixes and refactoring
Various minor bits of refactoring and fixes ahead of the next part of #1472.
See the individual commit messages for details. Most of these relate to tidying up cache age handling.
Various minor bits of refactoring and fixes ahead of the next part of #1472.
See the individual commit messages for details. Most of these relate to tidying up cache age handling.