This updateTargetTableAndIndex function seems like overkill.
I think that p_execute (as I've commented elsewhere) wants to define the target table pointer as a local variable.
Many of the data members for these classes are only really set and used within p_execute and could be local variables.