This problem might occur because in a table you've merged all the cells (of each column) of a row with the row below, so effectively that row below has no cells left.
So instead of merging all the cells of a row with the row below, you may unmerge the cells and just delete the whole row. This might fix the problem that the 'table-row' is missing elements.
I quickly glanced at the code, the only place I could imagine this could happen is when a (data/template)grid does not contain any objects. But this is without testing so can you please file a ticket with a reproduction?