Changed the way averages were calculated and added a line to output the final table.