Hi there! I made mostly random changes until it worked, so I have no idea why this contorted approach fixes the earlier failures. But I spend two weeks on this section, so don't touch it!
[this comment removed and replaced with the "Trust me" line, because maybe multi-line comments are breaking things today...]
[this comment removed and replaced with the "Trust me" line, because maybe multi-line comments are breaking things today...]