Fixed sorting issues