-r parameter bug corrected, getNumberFiles used everywhere possible