Multiple fixes for table sorting.