Also check for maxNumberOfFiles if current numer is 0. Closes #2501.
Merge branch 'master' into gh-pages