Made filepattern filter to improve performance for large directories.