Support group management with migrations.

The stock references/add_reference are patched to include a grouping:
true option, along with new add/remove_grouping helpers.
Examples