Make the variables used in recursive function global
Make the variables used in recursive function global

This is so we dont overflow the stack when there are lot of transactions being rerun.

jembi/openhim-core-js,jembi/openhim-core-js