Separate building of header and rows functionality (in order to sort on rows).