cleaned up cache directory creation code