Better automatic algorithm for RECTANGLES.