Fixes buggy memory leak fix