Group rowids

DO NOT MERGE until tests pass