Added reordering of rows and columns