diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index c660ee37..5c5bbd09 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -501,7 +501,7 @@ CFLAGS += -DUSE_ALPHA
 
 else
 
-LDFLAGS1 = -Wl,-export-dynamic -g
+LDFLAGS1 = -Wl,-export-dynamic -g -fsanitize=undefined
 LDFLAGS2 = $(LDFLAGS)
 LINKER = $(CXX) -o $(OUTPUT)
 
diff --git a/cinelerra-5.1/cinelerra/ci b/cinelerra-5.1/cinelerra/ci
index bc987833..22858982 120000
--- a/cinelerra-5.1/cinelerra/ci
+++ b/cinelerra-5.1/cinelerra/ci
@@ -1 +1 @@
-../bin/cinelerra
\ No newline at end of file
+../bin/cin
\ No newline at end of file
diff --git a/cinelerra-5.1/cinelerra/mwindow.C b/cinelerra-5.1/cinelerra/mwindow.C
index 2a86aaae..c6a87626 100644
--- a/cinelerra-5.1/cinelerra/mwindow.C
+++ b/cinelerra-5.1/cinelerra/mwindow.C
@@ -240,7 +240,7 @@ MWindow::MWindow()
 	sighandler = 0;
 	restart_status = 0;
 	screens = 1;
-	appimageDir = getenv("APPDIR"); //NULL if not running as appimage
+	appimageDir = getenv("APPDIR"); //NULL if not running as appimage 
 	in_destructor = 0;
 	speed_edl = 0;
 	beeper = 0;
@@ -675,6 +675,15 @@ int MWindow::check_plugin_index(ArrayList<PluginServer*> &plugins,
 	}
 	return 0;
 }
+
+int MWindow::is_appimage()
+{
+	if (getenv("APPDIR"))
+	return 1;
+    return 0;
+}
+
+
 /*
 * @brief Load built-in and LV2 plugins as specified in index file,
 *        rebuild the index file if needed.
@@ -691,7 +700,7 @@ int MWindow::init_plugins(MWindow *mwindow, Preferences *preferences)
 	// index_id is 2nd line of the index file, normally full plugin path,
 	// but fixed value if AppImage because the path changes on each run.
 	// And if the second line does not match on the next run the index is rebuilt.
-	if( mwindow->appimageDir ) strcpy(index_id, getenv("CINGG_BUILD"));
+	if( mwindow->is_appimage() && getenv("CINGG_BUILD")) strcpy(index_id, getenv("CINGG_BUILD"));
 	else strcpy(index_id, plugin_path);
 	FILE *fp = fopen(index_path,"a+");
 	if( !fp ) {
diff --git a/cinelerra-5.1/cinelerra/mwindow.h b/cinelerra-5.1/cinelerra/mwindow.h
index 46e96643..780001e6 100644
--- a/cinelerra-5.1/cinelerra/mwindow.h
+++ b/cinelerra-5.1/cinelerra/mwindow.h
@@ -810,7 +810,7 @@ public:
 	void init_tipwindow();
 // Used by MWindow and RenderFarmClient
 	static void get_plugin_path(char *path, const char *plug_dir, const char *fs_path);
-	static int init_plugins(MWindow *mwindow, Preferences *preferences);
+	static int init_plugins(MWindow *mwindow, Preferences *preferences) __attribute__((no_sanitize("undefined")));
 	static int init_ladspa_plugins(MWindow *mwindow, Preferences *preferences);
 	static void init_plugin_tips(ArrayList<PluginServer*> &plugins, const char *lang);
 	static int check_plugin_index(ArrayList<PluginServer*> &plugins,
@@ -859,6 +859,7 @@ public:
 	int restart_status;
 	int screens;
 	const char *appimageDir;
+	int is_appimage();
 	int in_destructor;
 	Shuttle *shuttle;
 	WinTV *wintv;
diff --git a/cinelerra-5.1/plugin_config b/cinelerra-5.1/plugin_config
index 56f43511..08e0238c 100644
--- a/cinelerra-5.1/plugin_config
+++ b/cinelerra-5.1/plugin_config
@@ -4,6 +4,7 @@ CFLAGS += -I../ -I$(CINELERRA) -I$(GUICAST) -I../colors -fPIC
 CFLAGS += $(static_incs)
 LFLAGS += $(static_libs)
 LFLAGS += $(LDFLAGS)
+LFLAGS += -fsanitize=undefined
 LDLINKER ?= $(CXX) -shared
 $(shell mkdir -p $(OBJDIR))
 
