Correction to path handling for files and directories.