Refactoring cache, timer code so it is not duplicated and so we use a real cache where it makes sense.