Fixes to checking whether a path is a file or folder