Simplify and fix parsing of batch mode input.