Also adds some comments I wrote to help me understand what's going
on in the code.
I hope to fix this bug myself, but I think it might be beyond what
you can do with Python regexes and might require writing a proper
parser.
So, as step 1, I'm adding in a couple comments explaining that the
bug exists and how to reproduce it.