minor additions, including writing out the averages file