Refactored to only store the main rectangle and compute the sub-rectangles