Fixes to make template profile faster in the regex preprocessing step.