Some refactoring for subgroup support.