Rectangles fix, misc improvements

Fixed rectangle loading and improved some code. More improvements to
come!