Fixed memory leak issue after switching to static library