Refactored code, so runBatch() function is not so long.
Made batch processing run in parallel.
Made the output to the standard output serialized.