Updated GroupAverage

fixed the nullpointer and other small issues.