cleanup
sort by x coordinate
Merge branch 'master' into mac