Streamline this function, and append the trailing slash for any directories that are resolved. Needs to be more tightly coupled to the dir_walk optimized cache.