Fix closures bugs

Hi Richard,

after a long journey I've learned about how upvalues works in Lua and I found my way in your bytecode generator module. I understand now its logic and I was able to appreciate how well written it is even if it lacks comments.

I was able to fix many bugs that I've reported before as issues. Now everything seems to work in my tests and I'm relatively sure that the changes I've done are quite correct. For me these changes marked a milestone for the gsl shell new language compiler based on Nyanga. I'm not able to run successfully the scimark benchmark.

I'm contributing the changes I've done upstream to Nyanga in the hope that this is useful for the project.

Some changes are absolutely not trivial.We can discuss these chages together if you want.

Cheers
Francesco