Fixed sorting errors