clean up sorting a bit and sort groups