Added average() util function.