Fix problem where column headers could end up in the wrong row