Verified that it indeed fixes the ifCurtailed: problem when abandoning a pre-debug window. I can't review this in detail, however I trust Anthony with these changes. We should probably add this before beta, since it is perhaps somewhat risky.