More sorting and fixes