Simplify sum and average

Reviewed-by: Trevor Norris <trev.norris@gmail.com>