Refactor sort and rectangles code
Update to v0.3.3