Reorganize metadata to put columns in array for sorting.
Other changes too.