Fix faulty cache management