If you’re writing complex frame sets by hand, it’s easy to get lost in “spaghetti code.” To keep a handle on the situation, don’t build the entire frame set at once. Instead, build only two or three frames at a time.
Once you get them to appear in the right proportions, place comments above and below that frame set so you can easily see where the unit begins and ends. Then, just think of that unit as a single frame, and nest it into a larger frame set. When that larger unit works properly, comment around it, and place it into a still larger frame set.
In general, start with the smallest frames, and work outward to the largest frames, nesting the sets inside one another.