fix more potential segfaults