Fix a problem with irregular tables

a typical use case is to have a colspan in the header and more cells
in the rows below. This caused a problem before in the transposed
tables. This should be more robust now.