fix cleanup in case of directories