fix stat_cache problem when deleting directories
fix a couple of errors when delaing with directories
- I suspect there are more, need moer tests