Remove global values dir, outputFormat and pattern and make them locally passed to functions