Fix caching of directory paths