Fixed a bug with RectangleToSegmentDirection, found another in the same class. Another is not fixed yet.