Move the Group numbering logic out of the parser.