More sorting fixes