fix(memleak): possible improvements to leaked vars #4079