diff --git a/include/my_global.h b/include/my_global.h
index 9ae68e01ffd0da86f3666ae6a69d854634bbb235..be7b668fdc035b06e540a91883d1b992e46c6c8f 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1380,16 +1380,6 @@ do { doubleget_union _tmp; \
 #define dlerror() ""
 #endif
 
-#ifdef HAVE_DLOPEN
-#if defined(__WIN__)
-#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name)
-#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
-#define dlclose(lib) FreeLibrary((HMODULE)lib)
-#elif !defined(OS2)
-#include <dlfcn.h>
-#endif
-#endif
-
 /* FreeBSD 2.2.2 does not define RTLD_NOW) */
 #ifndef RTLD_NOW
 #define RTLD_NOW 1
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 4a3abfdb60257cdc97b8e37b47f4a79b76d8b2b7..37cfdba1937dd2596bf67aa9ad45bbb738585a4f 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -6303,9 +6303,6 @@ static void mysql_init_variables(void)
 	  sizeof(mysql_real_data_home)-1);
   mysql_data_home_buff[0]=FN_CURLIB;	// all paths are relative from here
   mysql_data_home_buff[1]=0;
-  strmake(opt_plugin_dir, get_relative_path(LIBDIR),
-          sizeof(opt_plugin_dir) - 1);
-  opt_plugin_dir_ptr= opt_plugin_dir;
 
   /* Replication parameters */
   master_user= (char*) "test";
@@ -7229,6 +7226,9 @@ static void fix_paths(void)
   (void) my_load_path(mysql_home,mysql_home,""); // Resolve current dir
   (void) my_load_path(mysql_real_data_home,mysql_real_data_home,mysql_home);
   (void) my_load_path(pidfile_name,pidfile_name,mysql_real_data_home);
+  strmake(opt_plugin_dir, get_relative_path(LIBDIR),
+          sizeof(opt_plugin_dir) - 1);
+  opt_plugin_dir_ptr= opt_plugin_dir;
   (void) my_load_path(opt_plugin_dir, opt_plugin_dir_ptr, mysql_home);
 
   char *sharedir=get_relative_path(SHAREDIR);
diff --git a/sql/table.cc b/sql/table.cc
index fbb4ce22f7e3b5f1b8c3e94730241bad9cba9c2d..39792b405c6d80a71342aee2a29fdead81b572e4 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1074,7 +1074,10 @@ int closefrm(register TABLE *table)
   for (idx= table->s->keys; idx; idx--, key_info++)
   {
     if (key_info->flags & HA_USES_PARSER)
+    {
       plugin_unlock(key_info->parser);
+      key_info->flags= 0;
+    }
   }
   my_free((char*) table->alias, MYF(MY_ALLOW_ZERO_PTR));
   table->alias= 0;