Fixed some bugs in the calculate stats totals job