Fixed a bug causing rectangles to disappear prematurely