Added automatic totals calculation.