Fixed cache clearing bugs