Colspan fixes

This is a continuation of work done on #579, as we revise it and prepare it to be merged. It addresses table colspan calculation related issues reported in #407.