Moving some definitions around, removed references to cacheDirectory