about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libtools/threads.c6
-rw-r--r--src/wrapped/wrappedalure.c4
-rw-r--r--src/wrapped/wrappedalut.c4
-rw-r--r--src/wrapped/wrappedandroidsupport.c3
-rw-r--r--src/wrapped/wrappedatk.c4
-rw-r--r--src/wrapped/wrappedatkbridge.c8
-rw-r--r--src/wrapped/wrappedatspi.c6
-rw-r--r--src/wrapped/wrappedbz2.c6
-rw-r--r--src/wrapped/wrappedcrypto.c6
-rw-r--r--src/wrapped/wrappedcrypto3.c7
-rw-r--r--src/wrapped/wrappedcurl.c6
-rw-r--r--src/wrapped/wrappeddbus.c6
-rw-r--r--src/wrapped/wrappeddbusglib1.c8
-rw-r--r--src/wrapped/wrappeddbusmenuglib.c6
-rw-r--r--src/wrapped/wrappedevent21.c7
-rw-r--r--src/wrapped/wrappedexpat.c7
-rw-r--r--src/wrapped/wrappedfaudio.c8
-rw-r--r--src/wrapped/wrappedflac.c8
-rw-r--r--src/wrapped/wrappedfontconfig.c9
-rw-r--r--src/wrapped/wrappedfreetype.c6
-rw-r--r--src/wrapped/wrappedgbm.c6
-rw-r--r--src/wrapped/wrappedgconf2.c7
-rw-r--r--src/wrapped/wrappedgcrypt.c8
-rw-r--r--src/wrapped/wrappedgdk3.c27
-rw-r--r--src/wrapped/wrappedgdkpixbuf2.c7
-rw-r--r--src/wrapped/wrappedgdkx112.c17
-rw-r--r--src/wrapped/wrappedgio2.c17
-rw-r--r--src/wrapped/wrappedglib2.c8
-rw-r--r--src/wrapped/wrappedgmodule2.c6
-rw-r--r--src/wrapped/wrappedgmp.c6
-rw-r--r--src/wrapped/wrappedgnutls.c6
-rw-r--r--src/wrapped/wrappedgobject2.c30
-rw-r--r--src/wrapped/wrappedgomp.c7
-rw-r--r--src/wrapped/wrappedgstaudio.c16
-rw-r--r--src/wrapped/wrappedgstbase.c31
-rw-r--r--src/wrapped/wrappedgstgl.c7
-rw-r--r--src/wrapped/wrappedgstreamer.c34
-rw-r--r--src/wrapped/wrappedgstvideo.c31
-rw-r--r--src/wrapped/wrappedgthread2.c9
-rw-r--r--src/wrapped/wrappedgtk3.c43
-rw-r--r--src/wrapped/wrappedgtkx112.c42
-rw-r--r--src/wrapped/wrappediconv.c3
-rw-r--r--src/wrapped/wrappedicui18n66.c7
-rw-r--r--src/wrapped/wrappedicui18n67.c7
-rw-r--r--src/wrapped/wrappedicui18n72.c7
-rw-r--r--src/wrapped/wrappedicui18n74.c7
-rw-r--r--src/wrapped/wrappedicuuc66.c4
-rw-r--r--src/wrapped/wrappedicuuc67.c4
-rw-r--r--src/wrapped/wrappedicuuc72.c4
-rw-r--r--src/wrapped/wrappedicuuc74.c4
-rw-r--r--src/wrapped/wrappedkrb5.c7
-rw-r--r--src/wrapped/wrappedldapr.c12
-rw-r--r--src/wrapped/wrappedlib_init.h48
-rw-r--r--src/wrapped/wrappedlibasound.c6
-rw-r--r--src/wrapped/wrappedlibc.c8
-rw-r--r--src/wrapped/wrappedlibcmusl.c6
-rw-r--r--src/wrapped/wrappedlibcups.c6
-rw-r--r--src/wrapped/wrappedlibdrm.c7
-rw-r--r--src/wrapped/wrappedlibegl.c7
-rw-r--r--src/wrapped/wrappedlibformw.c3
-rw-r--r--src/wrapped/wrappedlibformw6.c3
-rw-r--r--src/wrapped/wrappedlibfuse.c6
-rw-r--r--src/wrapped/wrappedlibglu.c7
-rw-r--r--src/wrapped/wrappedlibglx.c9
-rw-r--r--src/wrapped/wrappedlibharfbuzz.c6
-rw-r--r--src/wrapped/wrappedlibibus.c3
-rw-r--r--src/wrapped/wrappedlibncurses.c7
-rw-r--r--src/wrapped/wrappedlibncurses6.c8
-rw-r--r--src/wrapped/wrappedlibncursesw.c8
-rw-r--r--src/wrapped/wrappedlibncursesw6.c8
-rw-r--r--src/wrapped/wrappedlibrt.c6
-rw-r--r--src/wrapped/wrappedlibsm.c6
-rw-r--r--src/wrapped/wrappedlibsndfile.c7
-rw-r--r--src/wrapped/wrappedlibssl.c7
-rw-r--r--src/wrapped/wrappedlibssl3.c8
-rw-r--r--src/wrapped/wrappedlibtinfo.c6
-rw-r--r--src/wrapped/wrappedlibtinfo6.c7
-rw-r--r--src/wrapped/wrappedlibusb1.c7
-rw-r--r--src/wrapped/wrappedlibva.c7
-rw-r--r--src/wrapped/wrappedlibvdpau.c7
-rw-r--r--src/wrapped/wrappedlibx11.c4
-rw-r--r--src/wrapped/wrappedlibx11xcb.c7
-rw-r--r--src/wrapped/wrappedlibxcb.c6
-rw-r--r--src/wrapped/wrappedlibxext.c21
-rw-r--r--src/wrapped/wrappedlibxfixes.c15
-rw-r--r--src/wrapped/wrappedlibxft.c15
-rw-r--r--src/wrapped/wrappedlibxi.c7
-rw-r--r--src/wrapped/wrappedlibxmu.c7
-rw-r--r--src/wrapped/wrappedlibxpm.c8
-rw-r--r--src/wrapped/wrappedlibxrandr.c12
-rw-r--r--src/wrapped/wrappedlibxrender.c15
-rw-r--r--src/wrapped/wrappedlibxss.c6
-rw-r--r--src/wrapped/wrappedlibxt.c11
-rw-r--r--src/wrapped/wrappedlibxtst.c11
-rw-r--r--src/wrapped/wrappedlibxxf86vm.c6
-rw-r--r--src/wrapped/wrappedlibz.c8
-rw-r--r--src/wrapped/wrappedlzma.c6
-rw-r--r--src/wrapped/wrappedmpg123.c7
-rw-r--r--src/wrapped/wrappednss3.c7
-rw-r--r--src/wrapped/wrappedopenal.c9
-rw-r--r--src/wrapped/wrappedopencl.c7
-rw-r--r--src/wrapped/wrappedpango.c11
-rw-r--r--src/wrapped/wrappedpangocairo.c6
-rw-r--r--src/wrapped/wrappedpangoft2.c3
-rw-r--r--src/wrapped/wrappedpng16.c9
-rw-r--r--src/wrapped/wrappedpulse.c7
-rw-r--r--src/wrapped/wrappedpulsemainloopglib.c7
-rw-r--r--src/wrapped/wrappedpulsesimple.c7
-rw-r--r--src/wrapped/wrappedsdl1.c15
-rw-r--r--src/wrapped/wrappedsdl1image.c8
-rw-r--r--src/wrapped/wrappedsdl1mixer.c4
-rw-r--r--src/wrapped/wrappedsdl1net.c5
-rw-r--r--src/wrapped/wrappedsdl1sound.c8
-rw-r--r--src/wrapped/wrappedsdl1ttf.c7
-rw-r--r--src/wrapped/wrappedsdl2.c15
-rw-r--r--src/wrapped/wrappedsdl2image.c9
-rw-r--r--src/wrapped/wrappedsdl2mixer.c7
-rw-r--r--src/wrapped/wrappedsdl2net.c3
-rw-r--r--src/wrapped/wrappedsdl2ttf.c9
-rw-r--r--src/wrapped/wrappedsmime3.c7
-rw-r--r--src/wrapped/wrappedsmpeg.c6
-rw-r--r--src/wrapped/wrappedsmpeg2.c7
-rw-r--r--src/wrapped/wrappedtermuxexec.c3
-rw-r--r--src/wrapped/wrappedudev0.c9
-rw-r--r--src/wrapped/wrappedudev1.c7
-rw-r--r--src/wrapped/wrappedvorbisfile.c7
-rw-r--r--src/wrapped/wrappedvulkan.c4
-rw-r--r--src/wrapped/wrappedxinerama.c7
-rw-r--r--src/wrapped/wrappedxml2.c6
-rw-r--r--src/wrapped/wrappedxslt.c6
-rw-r--r--src/wrapped/wrappercallback.h4
131 files changed, 238 insertions, 950 deletions
diff --git a/src/libtools/threads.c b/src/libtools/threads.c
index 0e4a962e..cedaec0c 100644
--- a/src/libtools/threads.c
+++ b/src/libtools/threads.c
@@ -530,10 +530,10 @@ void* my_prepare_thread(x64emu_t *emu, void* f, void* arg, int ssize, void** pet
 {
 	int stacksize = (ssize)?ssize:(2*1024*1024);	//default stack size is 2Mo
 	void* stack = internal_mmap(NULL, stacksize, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0);
-    if(stack!=MAP_FAILED)
-        setProtection((uintptr_t)stack, stacksize, PROT_READ|PROT_WRITE);
+	if(stack!=MAP_FAILED)
+		setProtection((uintptr_t)stack, stacksize, PROT_READ|PROT_WRITE);
 	emuthread_t *et = (emuthread_t*)box_calloc(1, sizeof(emuthread_t));
-    x64emu_t *emuthread = NewX64Emu(emu->context, (uintptr_t)f, (uintptr_t)stack, stacksize, 1);
+	x64emu_t *emuthread = NewX64Emu(emu->context, (uintptr_t)f, (uintptr_t)stack, stacksize, 1);
 	SetupX64Emu(emuthread, emu					);
 	//SetFS(emuthread, GetFS(emu));
 	et->emu = emuthread;
diff --git a/src/wrapped/wrappedalure.c b/src/wrapped/wrappedalure.c
index 6491903c..e21a9e35 100644
--- a/src/wrapped/wrappedalure.c
+++ b/src/wrapped/wrappedalure.c
@@ -14,8 +14,6 @@
 const char* alureName = "libalure.so.1";
 #define LIBNAME alure
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libopenal.so.1");
+#define NEEDED_LIBS "libopenal.so.1"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedalut.c b/src/wrapped/wrappedalut.c
index a74eaa76..6af697bd 100644
--- a/src/wrapped/wrappedalut.c
+++ b/src/wrapped/wrappedalut.c
@@ -14,8 +14,6 @@
 const char* alutName = "libalut.so.0";
 #define LIBNAME alut
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libopenal.so.1");
+#define NEEDED_LIBS "libopenal.so.1"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedandroidsupport.c b/src/wrapped/wrappedandroidsupport.c
index 909552fc..82c647ae 100644
--- a/src/wrapped/wrappedandroidsupport.c
+++ b/src/wrapped/wrappedandroidsupport.c
@@ -16,7 +16,6 @@ const char* androidsupportName = "libandroid-support.so";
 
 #define LIBNAME androidsupport
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libc.so");
+#define NEEDED_LIBS "libc.so"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedatk.c b/src/wrapped/wrappedatk.c
index 773212d9..c45d89e3 100644
--- a/src/wrapped/wrappedatk.c
+++ b/src/wrapped/wrappedatk.c
@@ -155,11 +155,7 @@ EXPORT uint32_t my_atk_add_global_event_listener(x64emu_t* emu, void* f, void* p
         return -1;
 
 #define CUSTOM_INIT \
-    getMy(lib);     \
     SetAtkObjectID(my->atk_object_get_type());  \
     SetAtkUtilID(my->atk_util_get_type());      \
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedatkbridge.c b/src/wrapped/wrappedatkbridge.c
index 88198faf..a4f0aec0 100644
--- a/src/wrapped/wrappedatkbridge.c
+++ b/src/wrapped/wrappedatkbridge.c
@@ -24,12 +24,6 @@ EXPORT int my_atk_bridge_adaptor_init(void* argc, void** argv)
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 5,               \
-        "libatk-1.0.so.0",              \
-        "libSM.so.6",                   \
-        "libICE.so.6",                  \
-        "libXau.so.6",                  \
-        "libxcb.so.1");
+#define NEEDED_LIBS "libatk-1.0.so.0", "libSM.so.6", "libICE.so.6", "libXau.so.6", "libxcb.so.1"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedatspi.c b/src/wrapped/wrappedatspi.c
index ee1bd0d5..2557a609 100644
--- a/src/wrapped/wrappedatspi.c
+++ b/src/wrapped/wrappedatspi.c
@@ -91,10 +91,4 @@ EXPORT void* my_atspi_event_listener_new(x64emu_t* emu, void* f, void* data, voi
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedbz2.c b/src/wrapped/wrappedbz2.c
index 85033983..ec3e4c42 100644
--- a/src/wrapped/wrappedbz2.c
+++ b/src/wrapped/wrappedbz2.c
@@ -179,10 +179,4 @@ EXPORT int my_BZ2_bzDecompressEnd(x64emu_t* emu, my_bz_stream_t* strm)
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedcrypto.c b/src/wrapped/wrappedcrypto.c
index d768555d..e3bfbaf8 100644
--- a/src/wrapped/wrappedcrypto.c
+++ b/src/wrapped/wrappedcrypto.c
@@ -713,10 +713,4 @@ EXPORT void my_OPENSSL_sk_pop_free(x64emu_t* emu, void* s, void* cb)
     my->OPENSSL_sk_pop_free(s, find_free_fnc_Fct(cb));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedcrypto3.c b/src/wrapped/wrappedcrypto3.c
index 31340b78..87e5e089 100644
--- a/src/wrapped/wrappedcrypto3.c
+++ b/src/wrapped/wrappedcrypto3.c
@@ -506,11 +506,6 @@ EXPORT void my3_EVP_MD_do_all_provided(x64emu_t* emu, void* ctx, void* cb, void*
     my->EVP_MD_do_all_provided(ctx, find_do_all_provided_cb_Fct(cb), arg);
 }
 
-#define CUSTOM_INIT \
-    SETALT(my3_);   \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
+#define ALTMY my3_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedcurl.c b/src/wrapped/wrappedcurl.c
index b758e74b..06a49a0c 100644
--- a/src/wrapped/wrappedcurl.c
+++ b/src/wrapped/wrappedcurl.c
@@ -796,10 +796,4 @@ EXPORT uint32_t my_curl_share_setopt(x64emu_t* emu, void* handle, CURLSHoption o
     }
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappeddbus.c b/src/wrapped/wrappeddbus.c
index 7f040916..fe2dd6c6 100644
--- a/src/wrapped/wrappeddbus.c
+++ b/src/wrapped/wrappeddbus.c
@@ -624,10 +624,4 @@ EXPORT int my_dbus_server_set_data(x64emu_t* emu, void* server, int slot, void*
     return my->dbus_server_set_data(server, slot, data, find_DBusFreeFunction_Fct(d));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappeddbusglib1.c b/src/wrapped/wrappeddbusglib1.c
index 6c9555a2..5218882c 100644
--- a/src/wrapped/wrappeddbusglib1.c
+++ b/src/wrapped/wrappeddbusglib1.c
@@ -225,12 +225,4 @@ EXPORT void my_dbus_g_proxy_disconnect_signal(x64emu_t* emu, void* proxy, void*
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappeddbusmenuglib.c b/src/wrapped/wrappeddbusmenuglib.c
index dd5f3183..db735115 100644
--- a/src/wrapped/wrappeddbusmenuglib.c
+++ b/src/wrapped/wrappeddbusmenuglib.c
@@ -106,10 +106,4 @@ EXPORT void my_dbusmenu_menuitem_send_about_to_show(x64emu_t* emu, void* mi, voi
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedevent21.c b/src/wrapped/wrappedevent21.c
index 1cf4fe3a..c962e4a5 100644
--- a/src/wrapped/wrappedevent21.c
+++ b/src/wrapped/wrappedevent21.c
@@ -61,11 +61,4 @@ EXPORT void my_event_set(x64emu_t* emu, void* evt, int sock, short i, void* f, v
     my->event_set(evt, sock, i, findevent_setFct(f), data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedexpat.c b/src/wrapped/wrappedexpat.c
index 783b0ca0..a848d436 100644
--- a/src/wrapped/wrappedexpat.c
+++ b/src/wrapped/wrappedexpat.c
@@ -709,11 +709,4 @@ EXPORT void my_XML_SetSkippedEntityHandler(x64emu_t* emu, void* p, void* f)
     my->XML_SetSkippedEntityHandler(p, find_SkippedEntity_Fct(f));
 }
 
-
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedfaudio.c b/src/wrapped/wrappedfaudio.c
index 619799ec..c5007302 100644
--- a/src/wrapped/wrappedfaudio.c
+++ b/src/wrapped/wrappedfaudio.c
@@ -444,12 +444,4 @@ EXPORT uint32_t my_FAPOFX_CreateFXWithCustomAllocatorEXT(x64emu_t* emu, void* cl
     return my->FAPOFX_CreateFXWithCustomAllocatorEXT(clsid, p, data, size, find_FAudioMalloc_Fct(customMalloc), find_FAudioFree_Fct(customFree), find_FAudioRealloc_Fct(customRealloc));
 }
 
-
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedflac.c b/src/wrapped/wrappedflac.c
index 8f0f3760..06f7617c 100644
--- a/src/wrapped/wrappedflac.c
+++ b/src/wrapped/wrappedflac.c
@@ -347,12 +347,4 @@ EXPORT int my_FLAC__stream_decoder_init_stream(x64emu_t* emu, void* decoder,
     return ret;
 }
 
-
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedfontconfig.c b/src/wrapped/wrappedfontconfig.c
index 9a5b2e71..a1561c7b 100644
--- a/src/wrapped/wrappedfontconfig.c
+++ b/src/wrapped/wrappedfontconfig.c
@@ -49,13 +49,6 @@ EXPORT void* my_FcObjectSetBuild(x64emu_t* emu, void* first, uint64_t* b)
     return my->FcObjectSetVaBuild(first, VARARGS);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);                     \
-    setNeededLibs(lib, 2,           \
-        "libexpat.so.1",            \
-        "libfreetype.so.6");
-
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libexpat.so.1", "libfreetype.so.6"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedfreetype.c b/src/wrapped/wrappedfreetype.c
index 86706b45..f1bec4f9 100644
--- a/src/wrapped/wrappedfreetype.c
+++ b/src/wrapped/wrappedfreetype.c
@@ -448,10 +448,4 @@ EXPORT int my_FT_Outline_Decompose(x64emu_t* emu, void* outline, my_FT_Outline_F
     return my->FT_Outline_Decompose(outline, tbl?(&f):tbl, data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgbm.c b/src/wrapped/wrappedgbm.c
index c060c10b..765f39eb 100644
--- a/src/wrapped/wrappedgbm.c
+++ b/src/wrapped/wrappedgbm.c
@@ -66,10 +66,4 @@ EXPORT void my_gbm_bo_set_user_data(x64emu_t* emu, void* bo, void* data, void *f
     my->gbm_bo_set_user_data(bo, data, find_destroy_user_data_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgconf2.c b/src/wrapped/wrappedgconf2.c
index ec651e6e..eefd223c 100644
--- a/src/wrapped/wrappedgconf2.c
+++ b/src/wrapped/wrappedgconf2.c
@@ -88,11 +88,4 @@ EXPORT uint32_t my_gconf_client_notify_add(x64emu_t* emu, void* client, void* se
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedgcrypt.c b/src/wrapped/wrappedgcrypt.c
index f04e5232..827e3924 100644
--- a/src/wrapped/wrappedgcrypt.c
+++ b/src/wrapped/wrappedgcrypt.c
@@ -85,12 +85,4 @@ EXPORT uint32_t my_gcry_sexp_build(x64emu_t* emu, void* r_sexp, void* erroff, co
     return my->gcry_sexp_build_array(r_sexp, erroff, (void*)fmt, array);
 }
 
-
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedgdk3.c b/src/wrapped/wrappedgdk3.c
index f7fe5f10..857e5886 100644
--- a/src/wrapped/wrappedgdk3.c
+++ b/src/wrapped/wrappedgdk3.c
@@ -25,8 +25,6 @@
 #endif
 #define LIBNAME gdk3
 
-static char* libname = NULL;
-
 //#define ADDED_FUNCTIONS()
 
 #include "generated/wrappedgdk3types.h"
@@ -185,33 +183,16 @@ EXPORT uint32_t my3_gdk_threads_add_timeout_full(x64emu_t* emu, int priotity, ui
     return my->gdk_threads_add_timeout_full(priotity, interval, findGSourceFunc(f), data, findGDestroyNotifyFct(d));
 }
 
-
 #define PRE_INIT    \
     if(box64_nogtk) \
         return -1;
 
+#define ALTMY my3_
+
 #ifdef ANDROID
-#define CUSTOM_INIT \
-    libname = lib->name;            \
-    SETALT(my3_);                   \
-    getMy(lib);                     \
-    setNeededLibs(lib, 3,           \
-        "libgobject-2.0.so",      \
-        "libgio-2.0.so",          \
-        "libgdk_pixbuf-2.0.so");
+#define NEEDED_LIBS "libgobject-2.0.so", "libgio-2.0.so", "libgdk_pixbuf-2.0.so"
 #else
-#define CUSTOM_INIT \
-    libname = lib->name;            \
-    SETALT(my3_);                   \
-    getMy(lib);                     \
-    setNeededLibs(lib, 3,           \
-        "libgobject-2.0.so.0",      \
-        "libgio-2.0.so.0",          \
-        "libgdk_pixbuf-2.0.so.0");
+#define NEEDED_LIBS "libgobject-2.0.so.0", "libgio-2.0.so.0", "libgdk_pixbuf-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgdkpixbuf2.c b/src/wrapped/wrappedgdkpixbuf2.c
index 8ba0dcb3..99fa1692 100644
--- a/src/wrapped/wrappedgdkpixbuf2.c
+++ b/src/wrapped/wrappedgdkpixbuf2.c
@@ -64,15 +64,8 @@ EXPORT void* my_gdk_pixbuf_new_from_data(x64emu_t* emu, void* data, int32_t colo
     return my->gdk_pixbuf_new_from_data(data, colorspace, has_alpha, bpp, w, h, stride, finddestroy_pixbufFct(destroy_func), destroy_data);
 }
 
-
 #define PRE_INIT    \
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgdkx112.c b/src/wrapped/wrappedgdkx112.c
index 3c3f3fb9..a9b6cd5c 100644
--- a/src/wrapped/wrappedgdkx112.c
+++ b/src/wrapped/wrappedgdkx112.c
@@ -178,20 +178,13 @@ EXPORT uint32_t my_gdk_threads_add_timeout_full(x64emu_t* emu, int priotity, uin
     if(box64_nogtk) \
         return -1;
 
-#ifdef ANDROID
 #define CUSTOM_INIT         \
-    libname = lib->name;    \
-    getMy(lib);             \
-    setNeededLibs(lib, 3, "libgobject-2.0.so", "libgio-2.0.so", "libgdk_pixbuf-2.0.so");
+    libname = lib->name;
+
+#ifdef ANDROID
+#define NEEDED_LIBS "libgobject-2.0.so", "libgio-2.0.so", "libgdk_pixbuf-2.0.so"
 #else
-#define CUSTOM_INIT         \
-    libname = lib->name;    \
-    getMy(lib);             \
-    setNeededLibs(lib, 3, "libgobject-2.0.so.0", "libgio-2.0.so.0", "libgdk_pixbuf-2.0.so.0");
+#define NEEDED_LIBS "libgobject-2.0.so.0", "libgio-2.0.so.0", "libgdk_pixbuf-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy(); \
-
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgio2.c b/src/wrapped/wrappedgio2.c
index 07c86969..638bc14c 100644
--- a/src/wrapped/wrappedgio2.c
+++ b/src/wrapped/wrappedgio2.c
@@ -629,21 +629,14 @@ EXPORT void my_g_input_stream_read_async(x64emu_t* emu, void* stream, void* buff
     if(box64_nogtk) \
         return -1;
 
-#ifdef ANDROID
 #define CUSTOM_INIT \
-    getMy(lib);                                         \
     SetGApplicationID(my->g_application_get_type());    \
-    SetGDBusProxyID(my->g_dbus_proxy_get_type());       \
-    setNeededLibs(lib, 1, "libgmodule-2.0.so");
+    SetGDBusProxyID(my->g_dbus_proxy_get_type());
+
+#ifdef ANDROID
+#define NEEDED_LIBS "libgmodule-2.0.so"
 #else
-#define CUSTOM_INIT \
-    getMy(lib);                                         \
-    SetGApplicationID(my->g_application_get_type());    \
-    SetGDBusProxyID(my->g_dbus_proxy_get_type());       \
-    setNeededLibs(lib, 1, "libgmodule-2.0.so.0");
+#define NEEDED_LIBS "libgmodule-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedglib2.c b/src/wrapped/wrappedglib2.c
index 18ae3f3e..df87f222 100644
--- a/src/wrapped/wrappedglib2.c
+++ b/src/wrapped/wrappedglib2.c
@@ -1443,12 +1443,4 @@ EXPORT void* my_g_once_impl(x64emu_t* emu, void* once, void* f, void* arg)
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    my_lib = lib;       \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedgmodule2.c b/src/wrapped/wrappedgmodule2.c
index c926238d..d4233e11 100644
--- a/src/wrapped/wrappedgmodule2.c
+++ b/src/wrapped/wrappedgmodule2.c
@@ -24,11 +24,9 @@
         return -1;
 
 #ifdef ANDROID
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libglib-2.0.so");
+#define NEEDED_LIBS "libglib-2.0.so"
 #else
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libglib-2.0.so.0");
+#define NEEDED_LIBS "libglib-2.0.so.0"
 #endif
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgmp.c b/src/wrapped/wrappedgmp.c
index 731d2d8c..b9a2bbee 100644
--- a/src/wrapped/wrappedgmp.c
+++ b/src/wrapped/wrappedgmp.c
@@ -147,10 +147,4 @@ EXPORT void my___gmp_set_memory_functions(x64emu_t* emu, void* f_alloc, void* f_
     my->__gmp_set_memory_functions(find_alloc_func_Fct(f_alloc), find_realloc_func_Fct(f_realloc), find_free_func_Fct(f_free));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgnutls.c b/src/wrapped/wrappedgnutls.c
index 1edf28de..6af45d64 100644
--- a/src/wrapped/wrappedgnutls.c
+++ b/src/wrapped/wrappedgnutls.c
@@ -137,10 +137,4 @@ EXPORT void my_gnutls_transport_set_pull_timeout_function(x64emu_t* emu, void* s
     my->gnutls_transport_set_pull_timeout_function(session, find_timeout_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgobject2.c b/src/wrapped/wrappedgobject2.c
index 19091269..21c5f20a 100644
--- a/src/wrapped/wrappedgobject2.c
+++ b/src/wrapped/wrappedgobject2.c
@@ -39,7 +39,12 @@ typedef void*(*pFL_t)(size_t);
 #include "generated/wrappedgobject2types.h"
 static void addGObject2Alternate(library_t* lib);
 
-#define ADDED_INIT()   addGObject2Alternate(lib);
+#define ADDED_INIT() \
+    addGObject2Alternate(lib);   \
+    InitGTKClass(lib->w.bridge);
+
+#define ADDED_FINI() \
+    FiniGTKClass();
 
 #include "wrappercallback.h"
 
@@ -928,30 +933,17 @@ EXPORT void* my_g_type_value_table_peek(x64emu_t* emu, size_t type)
     if(box64_nogtk) \
         return -1;
 
-#ifdef ANDROID
 #define CUSTOM_INIT \
-    InitGTKClass(lib->w.bridge);       \
-    getMy(lib);                             \
     SetGObjectID(my->g_object_get_type());  \
     SetGInitiallyUnownedID(my->g_initially_unowned_get_type()); \
     SetGTypeName(my->g_type_name);          \
     SetGClassPeek(my->g_type_class_peek);   \
-    SetGTypeParent(my->g_type_parent);      \
-    setNeededLibs(lib, 1, "libglib-2.0.so");
+    SetGTypeParent(my->g_type_parent);
+
+#ifdef ANDROID
+#define NEEDED_LIBS "libglib-2.0.so"
 #else
-#define CUSTOM_INIT \
-    InitGTKClass(lib->w.bridge);       \
-    getMy(lib);                             \
-    SetGObjectID(my->g_object_get_type());  \
-    SetGInitiallyUnownedID(my->g_initially_unowned_get_type()); \
-    SetGTypeName(my->g_type_name);          \
-    SetGClassPeek(my->g_type_class_peek);   \
-    SetGTypeParent(my->g_type_parent);      \
-    setNeededLibs(lib, 1, "libglib-2.0.so.0");
+#define NEEDED_LIBS "libglib-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    FiniGTKClass(); \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgomp.c b/src/wrapped/wrappedgomp.c
index 6cf9f200..679b1a94 100644
--- a/src/wrapped/wrappedgomp.c
+++ b/src/wrapped/wrappedgomp.c
@@ -63,11 +63,4 @@ EXPORT void my_GOMP_parallel(x64emu_t* emu, void* f, void* data, unsigned num_th
     my->GOMP_parallel(find_parallel_Fct(f), data, num_threads, flags);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedgstaudio.c b/src/wrapped/wrappedgstaudio.c
index cde06e01..952100ad 100644
--- a/src/wrapped/wrappedgstaudio.c
+++ b/src/wrapped/wrappedgstaudio.c
@@ -41,19 +41,13 @@ typedef size_t  (*LFv_t)();
     if(box64_nogtk) \
         return -1;
 
+#define CUSTOM_INIT \
+    SetGstAudioDecoderID(my->gst_audio_decoder_get_type());
+
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstAudioDecoderID(my->gst_audio_decoder_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so");
+#define NEEDED_LIBS "libgstreamer-1.0.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstAudioDecoderID(my->gst_audio_decoder_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so.0");
+#define NEEDED_LIBS "libgstreamer-1.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgstbase.c b/src/wrapped/wrappedgstbase.c
index 495357dc..b3d85b35 100644
--- a/src/wrapped/wrappedgstbase.c
+++ b/src/wrapped/wrappedgstbase.c
@@ -229,29 +229,18 @@ EXPORT void my_gst_collect_pads_set_buffer_function(x64emu_t* emu, void* pads, v
     if(box64_nogtk) \
         return -1;
 
+#define CUSTOM_INIT \
+    SetGstBaseTransformID(my->gst_base_transform_get_type());\
+    SetGstBaseSinkID(my->gst_base_sink_get_type());\
+    SetGstAggregatorID(my->gst_aggregator_get_type());\
+    SetGstPushSrcID(my->gst_push_src_get_type());\
+    SetGstBaseSrcID(my->gst_base_src_get_type());\
+    SetGstAggregatorPadID(my->gst_aggregator_pad_get_type());
+
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstBaseTransformID(my->gst_base_transform_get_type());\
-        SetGstBaseSinkID(my->gst_base_sink_get_type());\
-        SetGstAggregatorID(my->gst_aggregator_get_type());\
-        SetGstPushSrcID(my->gst_push_src_get_type());\
-        SetGstBaseSrcID(my->gst_base_src_get_type());\
-        SetGstAggregatorPadID(my->gst_aggregator_pad_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so");
+#define NEEDED_LIBS "libgstreamer-1.0.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstBaseTransformID(my->gst_base_transform_get_type());\
-        SetGstBaseSinkID(my->gst_base_sink_get_type());\
-        SetGstAggregatorID(my->gst_aggregator_get_type());\
-        SetGstPushSrcID(my->gst_push_src_get_type());\
-        SetGstBaseSrcID(my->gst_base_src_get_type());\
-        SetGstAggregatorPadID(my->gst_aggregator_pad_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so.0");
+#define NEEDED_LIBS "libgstreamer-1.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgstgl.c b/src/wrapped/wrappedgstgl.c
index fd82eda9..176df13b 100644
--- a/src/wrapped/wrappedgstgl.c
+++ b/src/wrapped/wrappedgstgl.c
@@ -272,13 +272,10 @@ EXPORT void my_gst_gl_window_set_resize_callback(x64emu_t* emu, void* window, vo
         return -1;
 
 #define CUSTOM_INIT \
-    getMy(lib);     \
     SetGstGLBaseFilterID(my->gst_gl_base_filter_get_type());        \
     SetGstGLFilterID(my->gst_gl_filter_get_type());                 \
-    SetGstGLBaseSrcID(my->gst_gl_base_src_get_type());              \
-    setNeededLibs(lib, 2, "libGL.so.1", "libgstreamer-1.0.so.0");
+    SetGstGLBaseSrcID(my->gst_gl_base_src_get_type());
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libGL.so.1", "libgstreamer-1.0.so.0"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgstreamer.c b/src/wrapped/wrappedgstreamer.c
index 847ea46d..93adcd7f 100644
--- a/src/wrapped/wrappedgstreamer.c
+++ b/src/wrapped/wrappedgstreamer.c
@@ -1058,31 +1058,19 @@ EXPORT int my_gst_type_find_register(x64emu_t* emu, void* plugin, void* name, ui
     if(box64_nogtk) \
         return -1;
 
+#define CUSTOM_INIT \
+    SetGstObjectID(my->gst_object_get_type());                 \
+    SetGstAllocatorID(my->gst_allocator_get_type());           \
+    SetGstTaskPoolID(my->gst_task_pool_get_type());            \
+    SetGstElementID(my->gst_element_get_type());               \
+    SetGstBinID(my->gst_bin_get_type());                       \
+    SetGstPadID(my->gst_pad_get_type());                       \
+    SetGstURIHandlerID(my->gst_uri_handler_get_type());
+
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstObjectID(my->gst_object_get_type());                 \
-        SetGstAllocatorID(my->gst_allocator_get_type());           \
-        SetGstTaskPoolID(my->gst_task_pool_get_type());            \
-        SetGstElementID(my->gst_element_get_type());               \
-        SetGstBinID(my->gst_bin_get_type());                       \
-        SetGstPadID(my->gst_pad_get_type());                       \
-        SetGstURIHandlerID(my->gst_uri_handler_get_type());        \
-        setNeededLibs(lib, 1, "libgtk-3.so");
+#define NEEDED_LIBS "libgtk-3.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstObjectID(my->gst_object_get_type());                 \
-        SetGstAllocatorID(my->gst_allocator_get_type());           \
-        SetGstTaskPoolID(my->gst_task_pool_get_type());            \
-        SetGstElementID(my->gst_element_get_type());               \
-        SetGstBinID(my->gst_bin_get_type());                       \
-        SetGstPadID(my->gst_pad_get_type());                       \
-        SetGstURIHandlerID(my->gst_uri_handler_get_type());        \
-        setNeededLibs(lib, 1, "libgtk-3.so.0");
+#define NEEDED_LIBS "libgtk-3.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgstvideo.c b/src/wrapped/wrappedgstvideo.c
index ef63ce4c..37538d35 100644
--- a/src/wrapped/wrappedgstvideo.c
+++ b/src/wrapped/wrappedgstvideo.c
@@ -46,29 +46,18 @@ typedef size_t  (*LFv_t)();
     if(box64_nogtk) \
         return -1;
 
+#define CUSTOM_INIT \
+    SetGstVideoDecoderID(my->gst_video_decoder_get_type());\
+    SetGstVideoEncoderID(my->gst_video_encoder_get_type());\
+    SetGstVideoSinkID(my->gst_video_sink_get_type());\
+    SetGstVideoAggregatorID(my->gst_video_aggregator_get_type());\
+    SetGstVideoAggregatorPadID(my->gst_video_aggregator_pad_get_type());\
+    SetGstVideoFilterID(my->gst_video_filter_get_type());
+
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstVideoDecoderID(my->gst_video_decoder_get_type());\
-        SetGstVideoEncoderID(my->gst_video_encoder_get_type());\
-        SetGstVideoSinkID(my->gst_video_sink_get_type());\
-        SetGstVideoAggregatorID(my->gst_video_aggregator_get_type());\
-        SetGstVideoAggregatorPadID(my->gst_video_aggregator_pad_get_type());\
-        SetGstVideoFilterID(my->gst_video_filter_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so");
+#define NEEDED_LIBS "libgstreamer-1.0.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        SetGstVideoDecoderID(my->gst_video_decoder_get_type());\
-        SetGstVideoEncoderID(my->gst_video_encoder_get_type());\
-        SetGstVideoSinkID(my->gst_video_sink_get_type());\
-        SetGstVideoAggregatorID(my->gst_video_aggregator_get_type());\
-        SetGstVideoAggregatorPadID(my->gst_video_aggregator_pad_get_type());\
-        SetGstVideoFilterID(my->gst_video_filter_get_type());\
-        setNeededLibs(lib, 1, "libgstreamer-1.0.so.0");
+#define NEEDED_LIBS "libgstreamer-1.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgthread2.c b/src/wrapped/wrappedgthread2.c
index 6e66c729..66b64623 100644
--- a/src/wrapped/wrappedgthread2.c
+++ b/src/wrapped/wrappedgthread2.c
@@ -96,17 +96,8 @@ void** my_GetGthreadsGotInitialized()
     return (void**)&g_threads_got_initialized;
 }
 
-
-
 #define PRE_INIT    \
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedgtk3.c b/src/wrapped/wrappedgtk3.c
index 7339effa..92192fcb 100644
--- a/src/wrapped/wrappedgtk3.c
+++ b/src/wrapped/wrappedgtk3.c
@@ -25,7 +25,6 @@
     const char* gtk3Name = "libgtk-3.so.0";
 #endif
 
-static char* libname = NULL;
 #define LIBNAME gtk3
 
 typedef size_t        (*LFv_t)(void);
@@ -821,11 +820,9 @@ EXPORT void my3_gtk_tree_store_set(x64emu_t* emu, void* tree, void* iter, uintpt
     if(box64_nogtk) \
         return -1;
 
-#ifdef ANDROID
+#define ALTMY my3_
+
 #define CUSTOM_INIT \
-    libname = lib->name;                                        \
-    getMy(lib);                                                 \
-    SETALT(my3_);                                               \
     SetGtkApplicationID(my->gtk_application_get_type());        \
     SetGtkWidget3ID(my->gtk_widget_get_type());                 \
     SetGtkFixed3ID(my->gtk_fixed_get_type());                   \
@@ -846,38 +843,12 @@ EXPORT void my3_gtk_tree_store_set(x64emu_t* emu, void* tree, void* iter, uintpt
     SetGtkGestureID(my->gtk_gesture_get_type());                \
     SetGtkGestureSingleID(my->gtk_gesture_single_get_type());   \
     SetGtkGestureLongPressID(my->gtk_gesture_long_press_get_type());\
-    SetGtkActionID(my->gtk_action_get_type());                  \
-    setNeededLibs(lib, 3, "libgdk-3.so", "libpangocairo-1.0.so", "libgio-2.0.so");
+    SetGtkActionID(my->gtk_action_get_type());
+
+#ifdef ANDROID
+#define NEEDED_LIBS "libgdk-3.so", "libpangocairo-1.0.so", "libgio-2.0.so"
 #else
-#define CUSTOM_INIT \
-    libname = lib->name;                                        \
-    getMy(lib);                                                 \
-    SETALT(my3_);                                               \
-    SetGtkApplicationID(my->gtk_application_get_type());        \
-    SetGtkWidget3ID(my->gtk_widget_get_type());                 \
-    SetGtkFixed3ID(my->gtk_fixed_get_type());                   \
-    SetGtkContainer3ID(my->gtk_container_get_type());           \
-    SetGtkBin3ID(my->gtk_bin_get_type());                       \
-    SetGtkButton3ID(my->gtk_button_get_type());                 \
-    SetGtkMenuButton3ID(my->gtk_menu_button_get_type());        \
-    SetGtkWindow3ID(my->gtk_window_get_type());                 \
-    SetGtkApplicationWindowID(my->gtk_application_window_get_type());\
-    SetGtkListBoxID(my->gtk_list_box_get_type());               \
-    SetGtkListBoxRowID(my->gtk_list_box_row_get_type());        \
-    SetGtkTextView3ID(my->gtk_text_view_get_type());            \
-    SetGtkGrid3ID(my->gtk_grid_get_type());                     \
-    SetGtkMisc3ID(my->gtk_misc_get_type());                     \
-    SetGtkLabel3ID(my->gtk_label_get_type());                   \
-    SetGtkImage3ID(my->gtk_image_get_type());                   \
-    SetGtkEventControllerID(my->gtk_event_controller_get_type());\
-    SetGtkGestureID(my->gtk_gesture_get_type());                \
-    SetGtkGestureSingleID(my->gtk_gesture_single_get_type());   \
-    SetGtkGestureLongPressID(my->gtk_gesture_long_press_get_type());\
-    SetGtkActionID(my->gtk_action_get_type());                  \
-    setNeededLibs(lib, 3, "libgdk-3.so.0", "libpangocairo-1.0.so.0", "libgio-2.0.so.0");
+#define NEEDED_LIBS "libgdk-3.so.0", "libpangocairo-1.0.so.0", "libgio-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedgtkx112.c b/src/wrapped/wrappedgtkx112.c
index bb06839d..4b069d16 100644
--- a/src/wrapped/wrappedgtkx112.c
+++ b/src/wrapped/wrappedgtkx112.c
@@ -24,7 +24,7 @@
 #else
     const char* gtkx112Name = "libgtk-x11-2.0.so.0";
 #endif
-static char* libname = NULL;
+
 #define LIBNAME gtkx112
 
 typedef size_t        (*LFv_t)(void);
@@ -1192,10 +1192,7 @@ EXPORT void my_gtk_print_job_send(x64emu_t* emu, void* job, void* f, void* data,
     if(box64_nogtk) \
         return -1;
 
-#ifdef ANDROID
 #define CUSTOM_INIT \
-    libname = lib->name;                                                        \
-    getMy(lib);                                                                 \
     SetGtkObjectID(my->gtk_object_get_type());                                  \
     SetGtkWidget2ID(my->gtk_widget_get_type());                                 \
     SetGtkContainer2ID(my->gtk_container_get_type());                           \
@@ -1218,39 +1215,12 @@ EXPORT void my_gtk_print_job_send(x64emu_t* emu, void* job, void* f, void* data,
     SetGtkFrame2ID(my->gtk_frame_get_type());                                   \
     SetGtkMenuShell2ID(my->gtk_menu_shell_get_type());                          \
     SetGtkMenuBar2ID(my->gtk_menu_bar_get_type());                              \
-    SetGtkTextView2ID(my->gtk_text_view_get_type());                            \
-    setNeededLibs(lib, 2, "libgdk-x11-2.0.so", "libpangocairo-1.0.so");
+    SetGtkTextView2ID(my->gtk_text_view_get_type());
+
+#ifdef ANDROID
+#define NEEDED_LIBS "libgdk-x11-2.0.so", "libpangocairo-1.0.so"
 #else
-#define CUSTOM_INIT \
-    libname = lib->name;                                                        \
-    getMy(lib);                                                                 \
-    SetGtkObjectID(my->gtk_object_get_type());                                  \
-    SetGtkWidget2ID(my->gtk_widget_get_type());                                 \
-    SetGtkContainer2ID(my->gtk_container_get_type());                           \
-    SetGtkActionID(my->gtk_action_get_type());                                  \
-    SetGtkMisc2ID(my->gtk_misc_get_type());                                     \
-    SetGtkLabel2ID(my->gtk_label_get_type());                                   \
-    SetGtkTreeView2ID(my->gtk_tree_view_get_type());                            \
-    SetGtkBin2ID(my->gtk_bin_get_type());                                       \
-    SetGtkWindow2ID(my->gtk_window_get_type());                                 \
-    SetGtkTable2ID(my->gtk_table_get_type());                                   \
-    SetGtkFixed2ID(my->gtk_fixed_get_type());                                   \
-    SetGtkButton2ID(my->gtk_button_get_type());                                 \
-    SetGtkComboBox2ID(my->gtk_combo_box_get_type());                            \
-    SetGtkToggleButton2ID(my->gtk_toggle_button_get_type());                    \
-    SetGtkCheckButton2ID(my->gtk_check_button_get_type());                      \
-    SetGtkEntry2ID(my->gtk_entry_get_type());                                   \
-    SetGtkSpinButton2ID(my->gtk_spin_button_get_type());                        \
-    SetGtkProgress2ID(my->gtk_progress_get_type());                             \
-    SetGtkProgressBar2ID(my->gtk_progress_bar_get_type());                      \
-    SetGtkFrame2ID(my->gtk_frame_get_type());                                   \
-    SetGtkMenuShell2ID(my->gtk_menu_shell_get_type());                          \
-    SetGtkMenuBar2ID(my->gtk_menu_bar_get_type());                              \
-    SetGtkTextView2ID(my->gtk_text_view_get_type());                            \
-    setNeededLibs(lib, 2, "libgdk-x11-2.0.so.0", "libpangocairo-1.0.so.0");
+#define NEEDED_LIBS "libgdk-x11-2.0.so.0", "libpangocairo-1.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappediconv.c b/src/wrapped/wrappediconv.c
index dea2ff8c..2eb30d18 100644
--- a/src/wrapped/wrappediconv.c
+++ b/src/wrapped/wrappediconv.c
@@ -16,7 +16,6 @@ const char* iconvName = "libiconv.so";
 
 #define LIBNAME iconv
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libc.so");
+#define NEEDED_LIBS "libc.so"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedicui18n66.c b/src/wrapped/wrappedicui18n66.c
index 9a5fd095..050c0cb8 100644
--- a/src/wrapped/wrappedicui18n66.c
+++ b/src/wrapped/wrappedicui18n66.c
@@ -21,9 +21,8 @@
 const char* icui18n66Name = "libicui18n.so.66";
 #define LIBNAME icui18n66
 
-#define CUSTOM_INIT \
-    SETALT(my66_);                          \
-    setNeededLibs(lib, 1, "libicuuc.so.66");
+#define ALTMY my66_
 
-#include "wrappedlib_init.h"
+#define NEEDED_LIBS "libicuuc.so.66"
 
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedicui18n67.c b/src/wrapped/wrappedicui18n67.c
index 13630f37..16bdca20 100644
--- a/src/wrapped/wrappedicui18n67.c
+++ b/src/wrapped/wrappedicui18n67.c
@@ -21,9 +21,8 @@
 const char* icui18n67Name = "libicui18n.so.67";
 #define LIBNAME icui18n67
 
-#define CUSTOM_INIT \
-    SETALT(my67_);                          \
-    setNeededLibs(lib, 1, "libicuuc.so.67");
+#define ALTMY my67_
 
-#include "wrappedlib_init.h"
+#define NEEDED_LIBS "libicuuc.so.67"
 
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedicui18n72.c b/src/wrapped/wrappedicui18n72.c
index 7a39dd1c..eceee3aa 100644
--- a/src/wrapped/wrappedicui18n72.c
+++ b/src/wrapped/wrappedicui18n72.c
@@ -21,9 +21,8 @@
 const char* icui18n72Name = "libicui18n.so.72";
 #define LIBNAME icui18n72
 
-#define CUSTOM_INIT \
-    SETALT(my72_);                          \
-    setNeededLibs(lib, 1, "libicuuc.so.72");
+#define ALTMY my72_
 
-#include "wrappedlib_init.h"
+#define NEEDED_LIBS "libicuuc.so.72"
 
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedicui18n74.c b/src/wrapped/wrappedicui18n74.c
index 4434b556..43150c4a 100644
--- a/src/wrapped/wrappedicui18n74.c
+++ b/src/wrapped/wrappedicui18n74.c
@@ -21,9 +21,8 @@
 const char* icui18n74Name = "libicui18n.so.74";
 #define LIBNAME icui18n74
 
-#define CUSTOM_INIT \
-    SETALT(my74_);                          \
-    setNeededLibs(lib, 1, "libicuuc.so.74");
+#define ALTMY my74_
 
-#include "wrappedlib_init.h"
+#define NEEDED_LIBS "libicuuc.so.74"
 
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedicuuc66.c b/src/wrapped/wrappedicuuc66.c
index de2c0c49..5d23c432 100644
--- a/src/wrapped/wrappedicuuc66.c
+++ b/src/wrapped/wrappedicuuc66.c
@@ -21,8 +21,6 @@
 const char* icuuc66Name = "libicuuc.so.66";
 #define LIBNAME icuuc66
 
-#define CUSTOM_INIT \
-    SETALT(my66_);                          \
+#define ALTMY my66_
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedicuuc67.c b/src/wrapped/wrappedicuuc67.c
index a2c2cb4a..0648da3e 100644
--- a/src/wrapped/wrappedicuuc67.c
+++ b/src/wrapped/wrappedicuuc67.c
@@ -21,8 +21,6 @@
 const char* icuuc67Name = "libicuuc.so.67";
 #define LIBNAME icuuc67
 
-#define CUSTOM_INIT \
-    SETALT(my67_);                          \
+#define ALTMY my67_
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedicuuc72.c b/src/wrapped/wrappedicuuc72.c
index 65827801..e58cb7ab 100644
--- a/src/wrapped/wrappedicuuc72.c
+++ b/src/wrapped/wrappedicuuc72.c
@@ -21,8 +21,6 @@
 const char* icuuc72Name = "libicuuc.so.72";
 #define LIBNAME icuuc72
 
-#define CUSTOM_INIT \
-    SETALT(my72_);                          \
+#define ALTMY my72_
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedicuuc74.c b/src/wrapped/wrappedicuuc74.c
index 8b5fdb1a..431e8d06 100644
--- a/src/wrapped/wrappedicuuc74.c
+++ b/src/wrapped/wrappedicuuc74.c
@@ -21,8 +21,6 @@
 const char* icuuc74Name = "libicuuc.so.74";
 #define LIBNAME icuuc74
 
-#define CUSTOM_INIT \
-    SETALT(my74_);                          \
+#define ALTMY my74_
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedkrb5.c b/src/wrapped/wrappedkrb5.c
index 526d6aa5..19b3c10e 100644
--- a/src/wrapped/wrappedkrb5.c
+++ b/src/wrapped/wrappedkrb5.c
@@ -66,11 +66,4 @@ EXPORT int my_krb5_get_init_creds_password(x64emu_t* emu, void* context, void* c
     return my->krb5_get_init_creds_password(context, creds, client, password, find_krb5_prompter_Fct(f), data, delta, service, options);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedldapr.c b/src/wrapped/wrappedldapr.c
index fbaee982..fca96197 100644
--- a/src/wrapped/wrappedldapr.c
+++ b/src/wrapped/wrappedldapr.c
@@ -69,17 +69,9 @@ EXPORT int my_ldap_sasl_interactive_bind_s(x64emu_t* emu, void* ld, void* dn, vo
 }
 
 #ifdef ANDROID
-#define NEEDED_LIB "liblber-2.4.so"
+#define NEEDED_LIBS "liblber-2.4.so"
 #else
-#define NEEDED_LIB "liblber-2.4.so.2"
+#define NEEDED_LIBS "liblber-2.4.so.2"
 #endif
 
-#define CUSTOM_INIT \
-    getMy(lib);         \
-    setNeededLibs(lib, 1, NEEDED_LIB);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlib_init.h b/src/wrapped/wrappedlib_init.h
index 75459d70..44af7c90 100644
--- a/src/wrapped/wrappedlib_init.h
+++ b/src/wrapped/wrappedlib_init.h
@@ -114,6 +114,18 @@ static const map_onedata_t MAPNAME(mydatamap)[] = {
 #undef DOIT
 #undef _DOIT
 
+#if !defined(ALTNAME) && defined(ALTNAME2)
+#error Please define ALTNAME before defining ALTNAME2
+#endif
+
+#define COUNT_NARGS(...) COUNT_NARGS_AUX(__VA_ARGS__, 5, 4, 3, 2, 1, 0)
+#define COUNT_NARGS_AUX(_1, _2, _3, _4, _5, n, ...) COUNT_NARGS_AUX##n(This should not appear, too many libraries)
+#define COUNT_NARGS_AUX1(v1, v2) 1
+#define COUNT_NARGS_AUX2(v1, v2) 2
+#define COUNT_NARGS_AUX3(v1, v2) 3
+#define COUNT_NARGS_AUX4(v1, v2) 4
+#define COUNT_NARGS_AUX5(v1, v2) 5
+
 int FUNC(_init)(library_t* lib, box64context_t* box64)
 {
     (void)box64;
@@ -127,17 +139,18 @@ int FUNC(_init)(library_t* lib, box64context_t* box64)
         lib->w.lib = dlopen(MAPNAME(Name), RTLD_LAZY | RTLD_GLOBAL);
         if(!lib->w.lib) {
 #ifdef ALTNAME
-        lib->w.lib = dlopen(ALTNAME, RTLD_LAZY | RTLD_GLOBAL);
-        if(!lib->w.lib)
-#endif
+            lib->w.lib = dlopen(ALTNAME, RTLD_LAZY | RTLD_GLOBAL);
+            if(!lib->w.lib) {
 #ifdef ALTNAME2
-            {
-            lib->w.lib = dlopen(ALTNAME2, RTLD_LAZY | RTLD_GLOBAL);
-            if(!lib->w.lib)
+                lib->w.lib = dlopen(ALTNAME2, RTLD_LAZY | RTLD_GLOBAL);
+                if(!lib->w.lib)
+#endif
 #endif
                 return -1;
+#ifdef ALTNAME
 #ifdef ALTNAME2
                 else lib->path = box_strdup(ALTNAME2);
+#endif
             } else lib->path = box_strdup(ALTNAME);
 #endif
         } else lib->path = box_strdup(MAPNAME(Name));
@@ -150,8 +163,8 @@ int FUNC(_init)(library_t* lib, box64context_t* box64)
 
     // populates maps...
 #define DOIT(mapname) \
-	cnt = sizeof(MAPNAME(mapname))/sizeof(map_onesymbol_t);                         \
-	for (int i = 0; i < cnt; ++i) {                                                 \
+    cnt = sizeof(MAPNAME(mapname))/sizeof(map_onesymbol_t);                         \
+    for (int i = 0; i < cnt; ++i) {                                                 \
         if (MAPNAME(mapname)[i].weak) {                                             \
             k = kh_put(symbolmap, lib->w.w##mapname, MAPNAME(mapname)[i].name, &ret); \
             kh_value(lib->w.w##mapname, k).w = MAPNAME(mapname)[i].w;               \
@@ -163,9 +176,9 @@ int FUNC(_init)(library_t* lib, box64context_t* box64)
         }                                                                           \
         if (strchr(MAPNAME(mapname)[i].name, '@'))                                  \
             AddDictionnary(box64->versym, MAPNAME(mapname)[i].name);                \
-	}
-	DOIT(symbolmap)
-	DOIT(mysymbolmap)
+    }
+    DOIT(symbolmap)
+    DOIT(mysymbolmap)
 #undef DOIT
     cnt = sizeof(MAPNAME(stsymbolmap))/sizeof(map_onesymbol_t);
     for (int i=0; i<cnt; ++i) {
@@ -200,18 +213,29 @@ int FUNC(_init)(library_t* lib, box64context_t* box64)
         k = kh_put(datamap, lib->w.mydatamap, MAPNAME(mydatamap)[i].name, &ret);
         kh_value(lib->w.mydatamap, k) = MAPNAME(mydatamap)[i].sz;
     }
+#ifdef ALTMY
+    SETALT(ALTMY);
+#endif
+#ifdef HAS_MY
+    getMy(lib);
+#endif
 #ifdef CUSTOM_INIT
     CUSTOM_INIT
 #endif
+#ifdef NEEDED_LIBS
+    setNeededLibs(lib, COUNT_NARGS(NEEDED_LIBS), NEEDED_LIBS);
+#endif
 
     return 0;
 }
 
 void FUNC(_fini)(library_t* lib)
 {
+#ifdef HAS_MY
+    freeMy();
+#endif
 #ifdef CUSTOM_FINI
     CUSTOM_FINI
 #endif
     WrappedLib_FinishFini(lib);
 }
-
diff --git a/src/wrapped/wrappedlibasound.c b/src/wrapped/wrappedlibasound.c
index c49f3912..f9919cc5 100644
--- a/src/wrapped/wrappedlibasound.c
+++ b/src/wrapped/wrappedlibasound.c
@@ -163,10 +163,4 @@ EXPORT void* my_snd_dlsym(x64emu_t* emu, void* handle, void* name, void* version
     return my_dlvsym(emu, handle, name, version);
 }
 
-#define CUSTOM_INIT                     \
-    getMy(lib);
-
-#define CUSTOM_FINI                     \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 428946b9..1c7c5a25 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -3454,7 +3454,7 @@ EXPORT char my___libc_single_threaded = 0;
     else
 
 #ifdef ANDROID
-#define NEEDED_LIBS   1,    \
+#define NEEDED_LIBS_DEF   1,\
     "libbsd.so"
 #define NEEDED_LIBS_234 4,  \
     "libpthread.so.0",      \
@@ -3462,7 +3462,7 @@ EXPORT char my___libc_single_threaded = 0;
     "libm.so",              \
     "libbsd.so"
 #else
-#define NEEDED_LIBS   6,    \
+#define NEEDED_LIBS_DEF   6,\
     "ld-linux-x86-64.so.2", \
     "libpthread.so.0",      \
     "libdl.so.2",           \
@@ -3479,6 +3479,8 @@ EXPORT char my___libc_single_threaded = 0;
     "libbsd.so.0"
 #endif
 
+#undef HAS_MY
+
 #define CUSTOM_INIT         \
     box64->libclib = lib;   \
     /*InitCpuModel();*/         \
@@ -3492,7 +3494,7 @@ EXPORT char my___libc_single_threaded = 0;
     if(box64_isglibc234)                                                        \
         setNeededLibs(lib, NEEDED_LIBS_234);                                    \
     else                                                                        \
-        setNeededLibs(lib, NEEDED_LIBS);
+        setNeededLibs(lib, NEEDED_LIBS_DEF);
 
 #define CUSTOM_FINI \
     freeMy();       \
diff --git a/src/wrapped/wrappedlibcmusl.c b/src/wrapped/wrappedlibcmusl.c
index acef30b3..213fecd1 100644
--- a/src/wrapped/wrappedlibcmusl.c
+++ b/src/wrapped/wrappedlibcmusl.c
@@ -27,9 +27,9 @@ const char* libcmuslName = "libc.musl-x86_64.so.1";
     else
 
 #define CUSTOM_INIT \
-    box64_musl = 1; \
-    setNeededLibs(lib, 4, "libc.so.6", "libdl.so.2", "libm.so.6", "libpthread.so.0");
+    box64_musl = 1;
+
+#define NEEDED_LIBS "libc.so.6", "libdl.so.2", "libm.so.6", "libpthread.so.0"
 
 // define all standard library functions
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibcups.c b/src/wrapped/wrappedlibcups.c
index 72b2a531..cc25e980 100644
--- a/src/wrapped/wrappedlibcups.c
+++ b/src/wrapped/wrappedlibcups.c
@@ -71,10 +71,4 @@ EXPORT int my_cupsEnumDests(x64emu_t* emu, uint32_t flags, int msec, int* cancel
     return my->cupsEnumDests(flags, msec, cancel, type, mask, find_cups_dest_cb_t_Fct(f), data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibdrm.c b/src/wrapped/wrappedlibdrm.c
index 762d05a1..a1d15e03 100644
--- a/src/wrapped/wrappedlibdrm.c
+++ b/src/wrapped/wrappedlibdrm.c
@@ -37,11 +37,4 @@ EXPORT void my_drmMsg(x64emu_t* emu, void* fmt, void* b) {
     free(buf);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibegl.c b/src/wrapped/wrappedlibegl.c
index 2a19ed94..256ea1b3 100644
--- a/src/wrapped/wrappedlibegl.c
+++ b/src/wrapped/wrappedlibegl.c
@@ -31,11 +31,4 @@ EXPORT void* my_eglGetProcAddress(x64emu_t* emu, void* name)
     return getGLProcAddress(emu, (glprocaddress_t)my->eglGetProcAddress, name);
 }
 
-#define CUSTOM_INIT                 \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibformw.c b/src/wrapped/wrappedlibformw.c
index 686aacdf..0b02baeb 100644
--- a/src/wrapped/wrappedlibformw.c
+++ b/src/wrapped/wrappedlibformw.c
@@ -14,7 +14,6 @@
 const char* libformwName = "libformw.so.5";
 #define LIBNAME libformw
 
-#define CUSTOM_INIT \
-    SETALT(myw_);   \
+#define ALTMY myw_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibformw6.c b/src/wrapped/wrappedlibformw6.c
index 92e80699..e7b99d1f 100644
--- a/src/wrapped/wrappedlibformw6.c
+++ b/src/wrapped/wrappedlibformw6.c
@@ -14,7 +14,6 @@
 const char* libformw6Name = "libformw.so.6";
 #define LIBNAME libformw6
 
-#define CUSTOM_INIT \
-    SETALT(my6_);   \
+#define ALTMY my6_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibfuse.c b/src/wrapped/wrappedlibfuse.c
index 2bac5099..bca9c4cc 100644
--- a/src/wrapped/wrappedlibfuse.c
+++ b/src/wrapped/wrappedlibfuse.c
@@ -2371,10 +2371,4 @@ box64_showsegv=1;
     return ret;
 }
 
-#define CUSTOM_INIT                 \
-    getMy(lib);
-
-#define CUSTOM_FINI             \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibglu.c b/src/wrapped/wrappedlibglu.c
index 8c370876..c3467ba4 100644
--- a/src/wrapped/wrappedlibglu.c
+++ b/src/wrapped/wrappedlibglu.c
@@ -131,11 +131,6 @@ void EXPORT my_gluNurbsCallback(x64emu_t* emu, void* a, int32_t b, void* cb)
     my->gluNurbsCallback(a, b, findglu_callbackFct(cb));
 }
 
-#define CUSTOM_INIT                     \
-    getMy(lib);                         \
-    setNeededLibs(lib, 1, "libGL.so.1");
-
-#define CUSTOM_FINI             \
-    freeMy();
+#define NEEDED_LIBS "libGL.so.1"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibglx.c b/src/wrapped/wrappedlibglx.c
index 52bae55d..6b30a790 100644
--- a/src/wrapped/wrappedlibglx.c
+++ b/src/wrapped/wrappedlibglx.c
@@ -49,13 +49,6 @@ EXPORT void* myx_glXGetProcAddressARB(x64emu_t* emu, void* name)
     return getGLProcAddress(emu, (glprocaddress_t)my->glXGetProcAddressARB, rname);
 }
 
-
-
-#define CUSTOM_INIT     \
-    getMy(lib);         \
-    SETALT(myx_);       \
-
-#define CUSTOM_FINI     \
-    freeMy();
+#define ALTMY myx_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibharfbuzz.c b/src/wrapped/wrappedlibharfbuzz.c
index 1d88201f..e90eae0b 100644
--- a/src/wrapped/wrappedlibharfbuzz.c
+++ b/src/wrapped/wrappedlibharfbuzz.c
@@ -1208,10 +1208,4 @@ EXPORT int my_hb_font_set_user_data(x64emu_t* emu, void* font, void* key, void*
     return (int)my->hb_font_set_user_data(font, key, data, find_destroy_Fct(destroy), replace);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibibus.c b/src/wrapped/wrappedlibibus.c
index 22d83a2c..f1ee4262 100644
--- a/src/wrapped/wrappedlibibus.c
+++ b/src/wrapped/wrappedlibibus.c
@@ -117,7 +117,6 @@ EXPORT void my_ibus_input_context_process_key_event_async(x64emu_t* emu, void* b
     if(box64_nogtk) \
         return -1;
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 3, "libgio-2.0.so.0", "libgobject-2.0.so.0", "libglib-2.0.so.0");
+#define NEEDED_LIBS "libgio-2.0.so.0", "libgobject-2.0.so.0", "libglib-2.0.so.0"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibncurses.c b/src/wrapped/wrappedlibncurses.c
index 61dbbaf0..d602cf16 100644
--- a/src/wrapped/wrappedlibncurses.c
+++ b/src/wrapped/wrappedlibncurses.c
@@ -88,11 +88,6 @@ EXPORT void* my_initscr()
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib); \
-    setNeededLibs(lib,  1, "libtinfo.so.5");
-
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libtinfo.so.5"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibncurses6.c b/src/wrapped/wrappedlibncurses6.c
index 4fe26c72..1880a267 100644
--- a/src/wrapped/wrappedlibncurses6.c
+++ b/src/wrapped/wrappedlibncurses6.c
@@ -87,12 +87,8 @@ EXPORT void* my6_initscr()
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-    SETALT(my6_);   \
-    setNeededLibs(lib, 1, "libtinfo.so.6");
+#define ALTMY my6_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libtinfo.so.6"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibncursesw.c b/src/wrapped/wrappedlibncursesw.c
index 2beb3e7e..26eec25e 100644
--- a/src/wrapped/wrappedlibncursesw.c
+++ b/src/wrapped/wrappedlibncursesw.c
@@ -78,12 +78,8 @@ EXPORT void* myw_initscr()
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-    SETALT(myw_);   \
-    setNeededLibs(lib, 1, "libtinfo.so.5");
+#define ALTMY myw_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libtinfo.so.5"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibncursesw6.c b/src/wrapped/wrappedlibncursesw6.c
index 4e440dc1..c2837432 100644
--- a/src/wrapped/wrappedlibncursesw6.c
+++ b/src/wrapped/wrappedlibncursesw6.c
@@ -78,12 +78,8 @@ EXPORT void* myw6_initscr()
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-    SETALT(myw6_);  \
-    setNeededLibs(lib, 1, "libtinfo.so.6");
+#define ALTMY myw6_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libtinfo.so.6"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibrt.c b/src/wrapped/wrappedlibrt.c
index f54f62b7..3b90c84a 100644
--- a/src/wrapped/wrappedlibrt.c
+++ b/src/wrapped/wrappedlibrt.c
@@ -155,10 +155,4 @@ EXPORT int mylio_listio(x64emu_t* emu, int mode, void* list[], int nent, struct
 }
 #endif
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibsm.c b/src/wrapped/wrappedlibsm.c
index 1ab0c30f..e9907413 100644
--- a/src/wrapped/wrappedlibsm.c
+++ b/src/wrapped/wrappedlibsm.c
@@ -135,10 +135,4 @@ EXPORT int my_SmcRequestSaveYourselfPhase2(x64emu_t* emu, void* smcConn, void* c
     return my->SmcRequestSaveYourselfPhase2(smcConn, findRequestFct(cb), data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibsndfile.c b/src/wrapped/wrappedlibsndfile.c
index af3bad5a..eaa54230 100644
--- a/src/wrapped/wrappedlibsndfile.c
+++ b/src/wrapped/wrappedlibsndfile.c
@@ -180,11 +180,4 @@ EXPORT int my_sf_close(x64emu_t* emu, void* sf)
     return my->sf_close(sf);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibssl.c b/src/wrapped/wrappedlibssl.c
index 056c2ef9..6860531f 100644
--- a/src/wrapped/wrappedlibssl.c
+++ b/src/wrapped/wrappedlibssl.c
@@ -514,11 +514,6 @@ EXPORT void my_SSL_CTX_set_alpn_select_cb(x64emu_t* emu, void* ctx, void* f ,voi
     my->SSL_CTX_set_alpn_select_cb(ctx, find_alpn_select_Fct(f), arg);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-    setNeededLibs(lib, 2, "libcrypto.so.1.1", "libpthread.so.0");
-
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libcrypto.so.1.1", "libpthread.so.0"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibssl3.c b/src/wrapped/wrappedlibssl3.c
index 0460651c..4c75d921 100644
--- a/src/wrapped/wrappedlibssl3.c
+++ b/src/wrapped/wrappedlibssl3.c
@@ -437,12 +437,8 @@ EXPORT void my3_SSL_set_msg_callback(x64emu_t* emu, void* ctx, void* cb)
     my->SSL_set_msg_callback(ctx, find_msg_cb_Fct(cb));
 }
 
-#define CUSTOM_INIT \
-    SETALT(my3_);   \
-    getMy(lib);     \
-    setNeededLibs(lib, 2, "libcrypto.so.3", "libpthread.so.0");
+#define ALTMY my3_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libcrypto.so.3", "libpthread.so.0"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibtinfo.c b/src/wrapped/wrappedlibtinfo.c
index f3ee96a4..42249897 100644
--- a/src/wrapped/wrappedlibtinfo.c
+++ b/src/wrapped/wrappedlibtinfo.c
@@ -65,10 +65,4 @@ EXPORT int my_tputs(x64emu_t* emu, void* str, int affcnt, void* f)
     return my->tputs(str, affcnt, find_putc_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibtinfo6.c b/src/wrapped/wrappedlibtinfo6.c
index c14c8ae0..034b75ed 100644
--- a/src/wrapped/wrappedlibtinfo6.c
+++ b/src/wrapped/wrappedlibtinfo6.c
@@ -64,11 +64,6 @@ EXPORT int my6_tputs(x64emu_t* emu, void* str, int affcnt, void* f)
     return my->tputs(str, affcnt, find_putc_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    SETALT(my6_); \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
+#define ALTMY my6_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibusb1.c b/src/wrapped/wrappedlibusb1.c
index 38dd589f..77010dc3 100644
--- a/src/wrapped/wrappedlibusb1.c
+++ b/src/wrapped/wrappedlibusb1.c
@@ -152,11 +152,4 @@ EXPORT int my_libusb_cancel_transfer(x64emu_t* emu, my_libusb_transfer_t* t)
     return my->libusb_cancel_transfer(t);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibva.c b/src/wrapped/wrappedlibva.c
index 8c331324..df18e412 100644
--- a/src/wrapped/wrappedlibva.c
+++ b/src/wrapped/wrappedlibva.c
@@ -77,11 +77,4 @@ EXPORT void* my_vaSetInfoCallback(x64emu_t* emu, void* dpy, void* f, void* ctx)
     return reverse_VAMessageCallbackFct(my->vaSetInfoCallback(dpy, findVAMessageCallbackFct(f), ctx));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibvdpau.c b/src/wrapped/wrappedlibvdpau.c
index 16eef5ae..ba6264c5 100644
--- a/src/wrapped/wrappedlibvdpau.c
+++ b/src/wrapped/wrappedlibvdpau.c
@@ -32,11 +32,4 @@ EXPORT uint32_t my_vdp_device_create_x11(x64emu_t* emu, void* display, int scree
     return 1;   // VDP_STATUS_NO_IMPLEMENTATION
 }
 
-#define CUSTOM_INIT                 \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibx11.c b/src/wrapped/wrappedlibx11.c
index 8e6f5a33..d34de369 100644
--- a/src/wrapped/wrappedlibx11.c
+++ b/src/wrapped/wrappedlibx11.c
@@ -1413,10 +1413,6 @@ EXPORT void* my_XOpenDisplay(x64emu_t* emu, void* d)
 }
 
 #define CUSTOM_INIT                 \
-    getMy(lib);                     \
     if(box64_x11threads) my->XInitThreads();
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibx11xcb.c b/src/wrapped/wrappedlibx11xcb.c
index d7b44e26..bac92703 100644
--- a/src/wrapped/wrappedlibx11xcb.c
+++ b/src/wrapped/wrappedlibx11xcb.c
@@ -31,11 +31,4 @@ EXPORT void* my_XGetXCBConnection(x64emu_t* emu, void* a)
     return add_xcb_connection(my->XGetXCBConnection(a));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxcb.c b/src/wrapped/wrappedlibxcb.c
index 0beee090..f049dac4 100644
--- a/src/wrapped/wrappedlibxcb.c
+++ b/src/wrapped/wrappedlibxcb.c
@@ -42,10 +42,4 @@ EXPORT void my_xcb_disconnect(x64emu_t* emu, void* conn)
 	del_xcb_connection(conn);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxext.c b/src/wrapped/wrappedlibxext.c
index 06088a83..0b7cfd92 100644
--- a/src/wrapped/wrappedlibxext.c
+++ b/src/wrapped/wrappedlibxext.c
@@ -391,26 +391,9 @@ EXPORT void* my_XextAddDisplay(x64emu_t* emu, void* extinfo, void* dpy, void* ex
 }
 
 #ifdef ANDROID
-    #define CUSTOM_INIT                 \
-        getMy(lib);                     \
-        setNeededLibs(lib, 5,           \
-            "libX11.so",              \
-            "libxcb.so",              \
-            "libXau.so",              \
-            "libdl.so",               \
-            "libXdmcp.so");
+#define NEEDED_LIBS "libX11.so", "libxcb.so", "libXau.so", "libdl.so", "libXdmcp.so"
 #else
-    #define CUSTOM_INIT                 \
-        getMy(lib);                     \
-        setNeededLibs(lib, 5,           \
-            "libX11.so.6",              \
-            "libxcb.so.1",              \
-            "libXau.so.6",              \
-            "libdl.so.2",               \
-            "libXdmcp.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libxcb.so.1", "libXau.so.6", "libdl.so.2", "libXdmcp.so.6"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxfixes.c b/src/wrapped/wrappedlibxfixes.c
index 90dbecc0..1def73a2 100644
--- a/src/wrapped/wrappedlibxfixes.c
+++ b/src/wrapped/wrappedlibxfixes.c
@@ -20,20 +20,9 @@
 #define LIBNAME libxfixes
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so",              \
-            "libxcb.so",              \
-            "libXau.so",              \
-            "libXdmcp.so");
+#define NEEDED_LIBS "libX11.so", "libxcb.so", "libXau.so", "libXdmcp.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so.6",              \
-            "libxcb.so.1",              \
-            "libXau.so.6",              \
-            "libXdmcp.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libxcb.so.1", "libXau.so.6", "libXdmcp.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxft.c b/src/wrapped/wrappedlibxft.c
index 175b9872..633e4066 100644
--- a/src/wrapped/wrappedlibxft.c
+++ b/src/wrapped/wrappedlibxft.c
@@ -20,20 +20,9 @@
 #define LIBNAME libxft
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so",              \
-            "libfontconfig.so",       \
-            "libXrender.so",          \
-            "libfreetype.so");
+#define NEEDED_LIBS "libX11.so", "libfontconfig.so", "libXrender.so", "libfreetype.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so.6",              \
-            "libfontconfig.so.1",       \
-            "libXrender.so.1",          \
-            "libfreetype.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libfontconfig.so.1", "libXrender.so.1", "libfreetype.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxi.c b/src/wrapped/wrappedlibxi.c
index d2d69be8..271048cd 100644
--- a/src/wrapped/wrappedlibxi.c
+++ b/src/wrapped/wrappedlibxi.c
@@ -20,12 +20,9 @@
 #define LIBNAME libxi
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxmu.c b/src/wrapped/wrappedlibxmu.c
index 16617cbc..f4229dfd 100644
--- a/src/wrapped/wrappedlibxmu.c
+++ b/src/wrapped/wrappedlibxmu.c
@@ -20,12 +20,9 @@
 #define LIBNAME libxmu
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxpm.c b/src/wrapped/wrappedlibxpm.c
index c4abc7f0..418ee87b 100644
--- a/src/wrapped/wrappedlibxpm.c
+++ b/src/wrapped/wrappedlibxpm.c
@@ -20,11 +20,9 @@
 #define LIBNAME libxpm
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+    #define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+    #define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
-#include "wrappedlib_init.h"
\ No newline at end of file
+#include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxrandr.c b/src/wrapped/wrappedlibxrandr.c
index 9303775d..eb8a4185 100644
--- a/src/wrapped/wrappedlibxrandr.c
+++ b/src/wrapped/wrappedlibxrandr.c
@@ -26,17 +26,9 @@
 #define LIBNAME libxrandr
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 3,           \
-            "libX11.so",              \
-            "libXext.so",             \
-            "libXrender.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so", "libXrender.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 3,           \
-            "libX11.so.6",              \
-            "libXext.so.6",             \
-            "libXrender.so.1");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6", "libXrender.so.1"
 #endif
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxrender.c b/src/wrapped/wrappedlibxrender.c
index 73fd2662..e6eb2df8 100644
--- a/src/wrapped/wrappedlibxrender.c
+++ b/src/wrapped/wrappedlibxrender.c
@@ -20,20 +20,9 @@
 #define LIBNAME libxrender
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so",              \
-            "libxcb.so",              \
-            "libXau.so",              \
-            "libXdmcp.so");
+#define NEEDED_LIBS "libX11.so", "libxcb.so", "libXau.so", "libXdmcp.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 4,           \
-            "libX11.so.6",              \
-            "libxcb.so.1",              \
-            "libXau.so.6",              \
-            "libXdmcp.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libxcb.so.1", "libXau.so.6", "libXdmcp.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedlibxss.c b/src/wrapped/wrappedlibxss.c
index 34c16828..b6359369 100644
--- a/src/wrapped/wrappedlibxss.c
+++ b/src/wrapped/wrappedlibxss.c
@@ -20,11 +20,9 @@
 #define LIBNAME libxss
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxt.c b/src/wrapped/wrappedlibxt.c
index f221f2a0..94f28659 100644
--- a/src/wrapped/wrappedlibxt.c
+++ b/src/wrapped/wrappedlibxt.c
@@ -128,16 +128,9 @@ EXPORT long my_XtAppAddInput(x64emu_t* emu, void* context, int source, void* con
 }
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);   \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);   \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxtst.c b/src/wrapped/wrappedlibxtst.c
index 4977f938..ba71efef 100644
--- a/src/wrapped/wrappedlibxtst.c
+++ b/src/wrapped/wrappedlibxtst.c
@@ -72,16 +72,9 @@ EXPORT int my_XRecordEnableContext(x64emu_t* emu, void* display, void* context,
 }
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        getMy(lib);     \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibxxf86vm.c b/src/wrapped/wrappedlibxxf86vm.c
index d6e7371e..72924824 100644
--- a/src/wrapped/wrappedlibxxf86vm.c
+++ b/src/wrapped/wrappedlibxxf86vm.c
@@ -26,11 +26,9 @@
 #define LIBNAME libxxf86vm
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibz.c b/src/wrapped/wrappedlibz.c
index 39468d47..843ab95a 100644
--- a/src/wrapped/wrappedlibz.c
+++ b/src/wrapped/wrappedlibz.c
@@ -195,12 +195,4 @@ EXPORT int my_inflate(x64emu_t* emu, void* str, int flush)
     return ret;
 }
 
-
-
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlzma.c b/src/wrapped/wrappedlzma.c
index 8592037b..387208f0 100644
--- a/src/wrapped/wrappedlzma.c
+++ b/src/wrapped/wrappedlzma.c
@@ -252,10 +252,4 @@ EXPORT void my_lzma_end(x64emu_t* emu, lzma_stream_t* stream)
     my->lzma_end(stream);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedmpg123.c b/src/wrapped/wrappedmpg123.c
index dc538abf..642c01fa 100644
--- a/src/wrapped/wrappedmpg123.c
+++ b/src/wrapped/wrappedmpg123.c
@@ -118,11 +118,4 @@ EXPORT int my_mpg123_replace_reader_handle_64(x64emu_t* emu, void* mh, void* r_r
     return my->mpg123_replace_reader_handle_64(mh, find_r_read_Fct(r_read), find_r_lseek_Fct(r_lseek), find_cleanup_Fct(cleanup));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappednss3.c b/src/wrapped/wrappednss3.c
index a655bebd..bb77bcfa 100644
--- a/src/wrapped/wrappednss3.c
+++ b/src/wrapped/wrappednss3.c
@@ -233,11 +233,4 @@ EXPORT int my_NSS_RegisterShutdown(x64emu_t* emu, void* f, void* data)
     return my->NSS_RegisterShutdown(find_NSS_ShutdownFunc_Fct(f), data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedopenal.c b/src/wrapped/wrappedopenal.c
index 80f58c46..75695c6c 100644
--- a/src/wrapped/wrappedopenal.c
+++ b/src/wrapped/wrappedopenal.c
@@ -20,8 +20,6 @@
 const char* openalName = "libopenal.so.1";
 #define LIBNAME openal
 
-static char* libname = NULL;
-
 #include "generated/wrappedopenaltypes.h"
 
 #include "wrappercallback.h"
@@ -63,13 +61,6 @@ void* my_alcGetProcAddress(x64emu_t* emu, void* device, void* name);
 void my_alRequestFoldbackStart(x64emu_t *emu, int32_t mode, int32_t count, int32_t length, void* mem, void* cb);
 void my_alRequestFoldbackStop(x64emu_t* emu);
 
-#define CUSTOM_INIT \
-    libname = lib->name;                \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
 
 
diff --git a/src/wrapped/wrappedopencl.c b/src/wrapped/wrappedopencl.c
index 067482e7..9ac1fd70 100644
--- a/src/wrapped/wrappedopencl.c
+++ b/src/wrapped/wrappedopencl.c
@@ -93,11 +93,4 @@ EXPORT void* my_clCreateContextFromType(x64emu_t* emu, void* prop, uint32_t type
     return my->clCreateContextFromType(prop, type, find_notity_context_Fct(f), data, ret);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedpango.c b/src/wrapped/wrappedpango.c
index d5d0d3bc..5a47288a 100644
--- a/src/wrapped/wrappedpango.c
+++ b/src/wrapped/wrappedpango.c
@@ -101,16 +101,9 @@ EXPORT void my_pango_attribute_init(x64emu_t* emu, void* attr, my_PangoAttrClass
         return -1;
 
 #ifdef ANDROID
-#define CUSTOM_INIT \
-    getMy(lib); \
-    setNeededLibs(lib, 2, "libgobject-2.0.so", "libglib-2.0.so");
+#define NEEDED_LIBS "libgobject-2.0.so", "libglib-2.0.so"
 #else
-#define CUSTOM_INIT \
-    getMy(lib); \
-    setNeededLibs(lib, 2, "libgobject-2.0.so.0", "libglib-2.0.so.0");
+#define NEEDED_LIBS "libgobject-2.0.so.0", "libglib-2.0.so.0"
 #endif
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedpangocairo.c b/src/wrapped/wrappedpangocairo.c
index 6218fb1f..6ef8f878 100644
--- a/src/wrapped/wrappedpangocairo.c
+++ b/src/wrapped/wrappedpangocairo.c
@@ -20,11 +20,9 @@
 #define LIBNAME pangocairo
 
 #ifdef ANDROID
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libpango-1.0.so");
+#define NEEDED_LIBS "libpango-1.0.so"
 #else
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libpango-1.0.so.0");
+#define NEEDED_LIBS "libpango-1.0.so.0"
 #endif
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedpangoft2.c b/src/wrapped/wrappedpangoft2.c
index 3a9838b9..fff605ea 100644
--- a/src/wrapped/wrappedpangoft2.c
+++ b/src/wrapped/wrappedpangoft2.c
@@ -14,7 +14,6 @@
 const char* pangoft2Name = "libpangoft2-1.0.so.0";
 #define LIBNAME pangoft2
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 2, "libfontconfig.so.1", "libfreetype.so.6");
+#define NEEDED_LIBS "libfontconfig.so.1", "libfreetype.so.6"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedpng16.c b/src/wrapped/wrappedpng16.c
index ba00808d..c1953f83 100644
--- a/src/wrapped/wrappedpng16.c
+++ b/src/wrapped/wrappedpng16.c
@@ -326,12 +326,9 @@ EXPORT void* my16_png_create_read_struct(x64emu_t* emu, void* png_ptr, void* use
     return my->png_create_read_struct(png_ptr, user_ptr, finderrorFct(errorfn), findwarningFct(warnfn));
 }
 
-#define CUSTOM_INIT \
-    SETALTPREFIX("yes");\
-    SETALT(my16_);      \
-    getMy(lib);
+#define ALTMY my16_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define CUSTOM_INIT \
+    SETALTPREFIX("yes");
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedpulse.c b/src/wrapped/wrappedpulse.c
index c2ad381e..a6090c38 100644
--- a/src/wrapped/wrappedpulse.c
+++ b/src/wrapped/wrappedpulse.c
@@ -1584,11 +1584,4 @@ void my_autobridge_mainloop_api(x64emu_t* emu, void* api)
     if(box64_nopulse)   \
         return -1;
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedpulsemainloopglib.c b/src/wrapped/wrappedpulsemainloopglib.c
index b8ef0d50..b2d7aa94 100644
--- a/src/wrapped/wrappedpulsemainloopglib.c
+++ b/src/wrapped/wrappedpulsemainloopglib.c
@@ -42,13 +42,10 @@ EXPORT void* my_pa_glib_mainloop_get_api(x64emu_t* emu, void* mainloop)
         return -1;
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 1, "libpulse.so");
+#define NEEDED_LIBS "libpulse.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 1, "libpulse.so.0");
+#define NEEDED_LIBS "libpulse.so.0"
 #endif
 
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedpulsesimple.c b/src/wrapped/wrappedpulsesimple.c
index c0685051..b448040a 100644
--- a/src/wrapped/wrappedpulsesimple.c
+++ b/src/wrapped/wrappedpulsesimple.c
@@ -30,12 +30,9 @@
         return -1;
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 1, "libpulse.so");
+#define NEEDED_LIBS "libpulse.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 1, "libpulse.so.0");
+#define NEEDED_LIBS "libpulse.so.0"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl1.c b/src/wrapped/wrappedsdl1.c
index b8e5bc31..1ffdfac0 100644
--- a/src/wrapped/wrappedsdl1.c
+++ b/src/wrapped/wrappedsdl1.c
@@ -51,6 +51,10 @@ typedef void  (*vFv_t)();
     GO(SDL_Quit, vFv_t)           \
     GO(SDL_AllocRW, sdl1_allocrw) \
     GO(SDL_FreeRW, sdl1_freerw)
+
+#define ADDED_FINI() \
+    my->SDL_Quit();
+
 #include "generated/wrappedsdl1types.h"
 
 #include "wrappercallback.h"
@@ -409,17 +413,12 @@ EXPORT int32_t my_SDL_GetWMInfo(x64emu_t* emu, void* p)
 }
 
 #define CUSTOM_INIT \
-    getMy(lib);                             \
     box64->sdl1allocrw = my->SDL_AllocRW;   \
-    box64->sdl1freerw  = my->SDL_FreeRW;    \
-    setNeededLibs(lib, 3,                   \
-        "libm.so.6",                        \
-        "libdl.so.2",                       \
-        "librt.so.1");
+    box64->sdl1freerw  = my->SDL_FreeRW;
+
+#define NEEDED_LIBS "libm.so.6", "libdl.so.2", "librt.so.1"
 
 #define CUSTOM_FINI \
-    my->SDL_Quit();                         \
-    freeMy();                               \
     my_context->sdl1allocrw = NULL;         \
     my_context->sdl1freerw = NULL;
 
diff --git a/src/wrapped/wrappedsdl1image.c b/src/wrapped/wrappedsdl1image.c
index ad405d90..83eb01b2 100644
--- a/src/wrapped/wrappedsdl1image.c
+++ b/src/wrapped/wrappedsdl1image.c
@@ -66,12 +66,6 @@ void EXPORT *my_IMG_Load_RW(x64emu_t* emu, void* a, int32_t b)
     return r;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);   \
-    setNeededLibs(lib, 2, "libSDL-1.2.so.0", "libz.so.1");
-
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libSDL-1.2.so.0", "libz.so.1"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl1mixer.c b/src/wrapped/wrappedsdl1mixer.c
index d9287be4..19b33fbf 100644
--- a/src/wrapped/wrappedsdl1mixer.c
+++ b/src/wrapped/wrappedsdl1mixer.c
@@ -209,11 +209,9 @@ EXPORT int my_Mix_UnregisterEffect(x64emu_t* emu, int channel, void* f)
 }
 
 #define CUSTOM_INIT \
-    box64->sdl1mixerlib = lib; \
-    getMy(lib);
+    box64->sdl1mixerlib = lib;
 
 #define CUSTOM_FINI \
-    freeMy();       \
     my_context->sdl1mixerlib = NULL;
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedsdl1net.c b/src/wrapped/wrappedsdl1net.c
index ee16dbe7..0e49d59a 100644
--- a/src/wrapped/wrappedsdl1net.c
+++ b/src/wrapped/wrappedsdl1net.c
@@ -19,9 +19,6 @@
 const char* sdl1netName = "libSDL_net-1.2.so.0";
 #define LIBNAME sdl1net
 
-#define CUSTOM_INIT \
-    SETALT(my_);
-
+#define ALTMY my_
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl1sound.c b/src/wrapped/wrappedsdl1sound.c
index e77d2a0b..d929440a 100644
--- a/src/wrapped/wrappedsdl1sound.c
+++ b/src/wrapped/wrappedsdl1sound.c
@@ -30,12 +30,6 @@ EXPORT void* my_Sound_NewSample(x64emu_t* emu, void* a, void* ext, void* desired
     return r;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);   \
-    setNeededLibs(lib, 1, "libSDL-1.2.so.0");
-
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libSDL-1.2.so.0"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl1ttf.c b/src/wrapped/wrappedsdl1ttf.c
index d0bb80c0..8e4cf53e 100644
--- a/src/wrapped/wrappedsdl1ttf.c
+++ b/src/wrapped/wrappedsdl1ttf.c
@@ -42,11 +42,4 @@ void EXPORT *my_TTF_OpenFontRW(x64emu_t* emu, void* a, int32_t b, int32_t c)
     return r;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl2.c b/src/wrapped/wrappedsdl2.c
index 930264c6..d12cea24 100644
--- a/src/wrapped/wrappedsdl2.c
+++ b/src/wrapped/wrappedsdl2.c
@@ -820,17 +820,17 @@ EXPORT void my2_SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, uint16_t *vend, u
     }
 }
 
+#undef HAS_MY
+
+#define ALTMY my2_
+
 #define CUSTOM_INIT \
     box64->sdl2lib = lib;                   \
     getMy(lib);                             \
     box64->sdl2allocrw = my->SDL_AllocRW;   \
-    box64->sdl2freerw  = my->SDL_FreeRW;    \
-    SETALT(my2_);                           \
-    setNeededLibs(lib, 4,                   \
-        "libdl.so.2",                       \
-        "libm.so.6",                        \
-        "librt.so.1",                       \
-        "libpthread.so.0");
+    box64->sdl2freerw  = my->SDL_FreeRW;
+
+#define NEEDED_LIBS "libdl.so.2", "libm.so.6", "librt.so.1", "libpthread.so.0"
 
 #define CUSTOM_FINI \
     my->SDL_Quit();                                             \
@@ -841,5 +841,4 @@ EXPORT void my2_SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, uint16_t *vend, u
     my_context->sdl2allocrw = NULL;                             \
     my_context->sdl2freerw = NULL;
 
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedsdl2image.c b/src/wrapped/wrappedsdl2image.c
index 290d3155..af45e391 100644
--- a/src/wrapped/wrappedsdl2image.c
+++ b/src/wrapped/wrappedsdl2image.c
@@ -101,13 +101,8 @@ EXPORT void* my2_IMG_LoadTextureTyped_RW(x64emu_t* emu, void* rend, void* a, int
     return r;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);     \
-    SETALT(my2_);   \
-    setNeededLibs(lib, 1, "libSDL2-2.0.so.0");
+#define ALTMY my2_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libSDL2-2.0.so.0"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsdl2mixer.c b/src/wrapped/wrappedsdl2mixer.c
index 56a2a0e8..4a462153 100644
--- a/src/wrapped/wrappedsdl2mixer.c
+++ b/src/wrapped/wrappedsdl2mixer.c
@@ -225,13 +225,12 @@ EXPORT int my2_MinorityMix_SetPosition(x64emu_t* emu, int channel, int16_t angle
     return my->Mix_SetPosition(channel, angle, 0);
 }
 
+#define ALTMY my2_
+
 #define CUSTOM_INIT \
-    box64->sdl2mixerlib = lib; \
-    getMy(lib); \
-    SETALT(my2_);
+    box64->sdl2mixerlib = lib;
 
 #define CUSTOM_FINI \
-    freeMy();       \
     my_context->sdl2mixerlib = NULL;
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedsdl2net.c b/src/wrapped/wrappedsdl2net.c
index 7009e4b7..651bb6aa 100644
--- a/src/wrapped/wrappedsdl2net.c
+++ b/src/wrapped/wrappedsdl2net.c
@@ -19,7 +19,6 @@
 const char* sdl2netName = "libSDL2_net-2.0.so.0";
 #define LIBNAME sdl2net
 
-#define CUSTOM_INIT      \
-    SETALT(my2_);        \
+#define ALTMY my2_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedsdl2ttf.c b/src/wrapped/wrappedsdl2ttf.c
index b0075b37..a427e6f0 100644
--- a/src/wrapped/wrappedsdl2ttf.c
+++ b/src/wrapped/wrappedsdl2ttf.c
@@ -42,13 +42,8 @@ void EXPORT *my2_TTF_OpenFontRW(x64emu_t* emu, void* a, int32_t b, int32_t c)
     return r;
 }
 
-#define CUSTOM_INIT                     \
-    SETALT(my2_);                       \
-    getMy(lib);                         \
-    setNeededLibs(lib, 1, "libSDL2-2.0.so.0");
+#define ALTMY my2_
 
-#define CUSTOM_FINI                     \
-    freeMy();
+#define NEEDED_LIBS "libSDL2-2.0.so.0"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsmime3.c b/src/wrapped/wrappedsmime3.c
index 858c16b9..dde3c4d9 100644
--- a/src/wrapped/wrappedsmime3.c
+++ b/src/wrapped/wrappedsmime3.c
@@ -302,11 +302,4 @@ EXPORT int my_CERT_DecodeCertPackage(x64emu_t* emu, void* cert, int len, void* f
     return my->CERT_DecodeCertPackage(cert, len, find_CERTImportCertificateFunc_Fct(f), data);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedsmpeg.c b/src/wrapped/wrappedsmpeg.c
index c2bac565..943af3c5 100644
--- a/src/wrapped/wrappedsmpeg.c
+++ b/src/wrapped/wrappedsmpeg.c
@@ -71,10 +71,4 @@ EXPORT void* my_SMPEG_new_rwops(x64emu_t* emu, void* src, void* info, int32_t sd
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedsmpeg2.c b/src/wrapped/wrappedsmpeg2.c
index e285c215..9c7a74a6 100644
--- a/src/wrapped/wrappedsmpeg2.c
+++ b/src/wrapped/wrappedsmpeg2.c
@@ -74,11 +74,6 @@ EXPORT void* my2_SMPEG_new_rwops(x64emu_t* emu, void* src, void* info, int32_t f
     return ret;
 }
 
-#define CUSTOM_INIT \
-    getMy(lib); \
-    SETALT(my2_);
-
-#define CUSTOM_FINI \
-    freeMy();
+#define ALTMY my2_
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedtermuxexec.c b/src/wrapped/wrappedtermuxexec.c
index a3336b59..d1da0106 100644
--- a/src/wrapped/wrappedtermuxexec.c
+++ b/src/wrapped/wrappedtermuxexec.c
@@ -16,7 +16,6 @@ const char* termuxexecName = "libtermux-exec.so";
 
 #define LIBNAME termuxexec
 
-#define CUSTOM_INIT \
-    setNeededLibs(lib, 1, "libc.so");
+#define NEEDED_LIBS "libc.so"
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedudev0.c b/src/wrapped/wrappedudev0.c
index 4f2182a3..3c13853e 100644
--- a/src/wrapped/wrappedudev0.c
+++ b/src/wrapped/wrappedudev0.c
@@ -74,13 +74,8 @@ EXPORT void my0_udev_set_log_fn(x64emu_t* emu, void* udev, void* f)
     my->udev_set_log_fn(udev, find_log_fn_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    SETALT(my0_);   \
-    getMy(lib);     \
-    setNeededLibs(lib, 1, "libudev.so.1");
+#define ALTMY my0_
 
-#define CUSTOM_FINI \
-    freeMy();
+#define NEEDED_LIBS "libudev.so.1"
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedudev1.c b/src/wrapped/wrappedudev1.c
index a82b61c0..b16b3a59 100644
--- a/src/wrapped/wrappedudev1.c
+++ b/src/wrapped/wrappedudev1.c
@@ -74,11 +74,4 @@ EXPORT void my_udev_set_log_fn(x64emu_t* emu, void* udev, void* f)
     my->udev_set_log_fn(udev, find_log_fn_Fct(f));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedvorbisfile.c b/src/wrapped/wrappedvorbisfile.c
index af912660..5ab7a557 100644
--- a/src/wrapped/wrappedvorbisfile.c
+++ b/src/wrapped/wrappedvorbisfile.c
@@ -170,11 +170,4 @@ EXPORT int32_t my_ov_test_callbacks(x64emu_t* emu, void* datasource, void* vf, v
     vorbisfileName = (box86->sdl1mixerlib || box86->sdl2mixerlib)?vorbisfileNameAlt:vorbisfileNameReg;
 #endif
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedvulkan.c b/src/wrapped/wrappedvulkan.c
index 34154b37..96dfba75 100644
--- a/src/wrapped/wrappedvulkan.c
+++ b/src/wrapped/wrappedvulkan.c
@@ -409,13 +409,9 @@ static void* find_DebugUtilsMessengerCallback_Fct(void* fct)
         return -1;
 
 #define CUSTOM_INIT \
-    getMy(lib);     \
     lib->w.priv = dlsym(lib->w.lib, "vkGetInstanceProcAddr"); \
     box64->vkprocaddress = lib->w.priv;
 
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
 
 void fillVulkanProcWrapper(box64context_t* context)
diff --git a/src/wrapped/wrappedxinerama.c b/src/wrapped/wrappedxinerama.c
index eeebec45..a3807b85 100644
--- a/src/wrapped/wrappedxinerama.c
+++ b/src/wrapped/wrappedxinerama.c
@@ -20,12 +20,9 @@
 #define LIBNAME xinerama
 
 #ifdef ANDROID
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so", "libXext.so");
+#define NEEDED_LIBS "libX11.so", "libXext.so"
 #else
-    #define CUSTOM_INIT \
-        setNeededLibs(lib, 2, "libX11.so.6", "libXext.so.6");
+#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
 #endif
 
 #include "wrappedlib_init.h"
-
diff --git a/src/wrapped/wrappedxml2.c b/src/wrapped/wrappedxml2.c
index 4b08797c..1c352c6b 100644
--- a/src/wrapped/wrappedxml2.c
+++ b/src/wrapped/wrappedxml2.c
@@ -1495,10 +1495,4 @@ EXPORT void* my_xmlCtxtReadIO(x64emu_t* emu, void* ctxt, void* ioread, void* ioc
     return my->xmlCtxtReadIO(ctxt, find_xmlInputReadCallback_Fct(ioread), find_xmlInputCloseCallback_Fct(ioclose), ioctx, url, encoding, options);
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedxslt.c b/src/wrapped/wrappedxslt.c
index ad145b2d..d07213b7 100644
--- a/src/wrapped/wrappedxslt.c
+++ b/src/wrapped/wrappedxslt.c
@@ -153,10 +153,4 @@ EXPORT void my_xsltSetCtxtSortFunc(x64emu_t* emu, void* ctx, void* handler)
     return my->xsltSetCtxtSortFunc(ctx, find_xsltSortFunc_Fct(handler));
 }
 
-#define CUSTOM_INIT \
-    getMy(lib);
-
-#define CUSTOM_FINI \
-    freeMy();
-
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappercallback.h b/src/wrapped/wrappercallback.h
index b86ed14e..74c2670d 100644
--- a/src/wrapped/wrappercallback.h
+++ b/src/wrapped/wrappercallback.h
@@ -29,12 +29,14 @@ static void getMy(library_t* lib)
 
 static void freeMy()
 {
-    my_lib = NULL;
     #ifdef ADDED_FINI
     ADDED_FINI()
     #endif
+    my_lib = NULL;
 }
 
+#define HAS_MY
+
 #ifndef ADDED_SUPER
 #undef SUPER
 #endif