Finished optimizing multigroup mean calculations