various changes to remove directories, check if files exist and ignore dots