some sorting fixes