I'm not sure what you're concerned about leaking, as most of the
information passed on other than the layout detail is available via
properties in the X server. Which is where this should be passed anyway;
I'd probably attach an XMONAD_LAYOUT property to each window with its state
information. This also avoids the potential for race conditions when the
window state changes during the restart sequence.