[WIP] Initial work on cache invalidsation refactoring

Don't even look at this yet :)