Adding a range flag for doAverage() as well as some other minor things.