Added averaging option.