adjust totals when emptying a table; also use classes for more precise handling of td