Step by step. Examine the variables. See what it does and why it does it.

That's routine for programmers if they can't find the cause by reading the source. Eventually, they find it.

Kees