group by fixes