small fix for #3 memory leak problem

I sort of needed this fix, and this works for my case. I haven't spent too much time thinking about nested structures and arrays, as my case is very similar to the one described in the issue, and now everything works perfectly with no memory leaks.

I want to stress again, that this solution might not be correct, but it solves my problems until the correct one is created.