Support for group fragments

First two commits clean some things up, lays the groundwork.
Commit bf737b4 is the feature itself, and probably deserves some code review.