groupStatistics appeared to be completely broken

Fix typo and rearrange code to avoid fatals.
Change-Id: I2926b4caf75300dfcf9ea6f88dea3b5b5955c980