fix memory leak issues

review only, do not merge