Change to table sort and code cleanup.