Added additional check for cache dir.