Fix calculation of number of rows in loss and gain table.