Some minor refactoring of match group code.