Fixed bug where python function arguments overwrote

- all the function closures were stored as references, so they got replaced on subsequent iterations through the for loop