Fixed memory leak patch