fix more memory leak bugs