4.0: Rewrite cache handling