fix memory leak

Hi, thanks for the library!
After using wih arryas of variants we found serious mem leaks, that we we are able to fix.