Some formatting, logic, and speedup improvements(only create the same regexes once).
Some formatting, logic, and speedup improvements(only create the same regexes once).

saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt