It should be noted that AddressSanitizer still reports a memory leak with these fixes, even though the use-after-free problem seems to be solved. Thanks in advance, Kei