Fixed totals saving to database