Cleanup s_clib.c and improve performance loading libraries