Group gems appropriately