Moved the calculation of subtotals into the model, where it belongs.