Add "groups" support which (for now) affects only sorting. Update sorting methods to remove redundancy, centralize all logic in one place.
Update error messages to be more verbose