diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index c3b57f2ff3ad6d90945ec0596c9fd0fa5b1ba77f..f8c79763bf97a5b270257c0f24beda5e554397c7 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -111,7 +111,7 @@ static int env_print(char *name)
 
 		e.key = name;
 		e.data = NULL;
-		ep = hsearch (e, FIND);
+		hsearch_r(e, FIND, &ep, &env_htab);
 		if (ep == NULL)
 			return 0;
 		len = printf ("%s=%s\n", ep->key, ep->data);
@@ -119,7 +119,7 @@ static int env_print(char *name)
 	}
 
 	/* print whole list */
-	len = hexport('\n', &res, 0);
+	len = hexport_r(&env_htab, '\n', &res, 0);
 
 	if (len > 0) {
 		puts(res);
@@ -184,7 +184,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
 	 */
 	e.key = name;
 	e.data = NULL;
-	ep = hsearch (e, FIND);
+	hsearch_r(e, FIND, &ep, &env_htab);
 
 	/* Check for console redirection */
 	if (strcmp(name,"stdin") == 0) {
@@ -267,7 +267,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
 
 	/* Delete only ? */
 	if ((argc < 3) || argv[2] == NULL) {
-		int rc = hdelete(name);
+		int rc = hdelete_r(name, &env_htab);
 		return !rc;
 	}
 
@@ -293,7 +293,7 @@ int _do_env_set (int flag, int argc, char * const argv[])
 
 	e.key  = name;
 	e.data = value;
-	ep = hsearch(e, ENTER);
+	hsearch_r(e, ENTER, &ep, &env_htab);
 	free(value);
 	if (!ep) {
 		printf("## Error inserting \"%s\" variable, errno=%d\n",
@@ -456,7 +456,7 @@ char *getenv (char *name)
 
 		e.key  = name;
 		e.data = NULL;
-		ep = hsearch (e, FIND);
+		hsearch_r(e, FIND, &ep, &env_htab);
 
 		return (ep ? ep->data : NULL);
 	}
@@ -651,7 +651,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 	}
 
 	if (sep) {		/* export as text file */
-		len = hexport(sep, &addr, size);
+		len = hexport_r(&env_htab, sep, &addr, size);
 		if (len < 0) {
 			error("Cannot export environment: errno = %d\n",
 				errno);
@@ -670,7 +670,7 @@ static int do_env_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
 	else			/* export as raw binary data */
 		res = addr;
 
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n",
 			errno);
@@ -790,7 +790,7 @@ static int do_env_import(cmd_tbl_t * cmdtp, int flag, int argc, char * const arg
 		addr = (char *)ep->data;
 	}
 
-	if (himport(addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
+	if (himport_r(&env_htab, addr, size, sep, del ? 0 : H_NOCLEAR) == 0) {
 		error("Environment import failed: errno = %d\n", errno);
 		return 1;
 	}
diff --git a/common/env_common.c b/common/env_common.c
index a276efc634717eb4740b4ce5351402eb3c6ee483..ae710e5e60f3f562f548cd3127b08c69eaae796e 100644
--- a/common/env_common.c
+++ b/common/env_common.c
@@ -129,6 +129,8 @@ uchar default_environment[] = {
 	"\0"
 };
 
+struct hsearch_data env_htab;
+
 static uchar env_get_char_init (int index)
 {
 	uchar c;
@@ -187,7 +189,7 @@ void set_default_env(const char *s)
 		puts("Using default environment\n\n");
 	}
 
-	if (himport((char *)default_environment,
+	if (himport_r(&env_htab, (char *)default_environment,
 		    sizeof(default_environment), '\0', 0) == 0) {
 		error("Environment import failed: errno = %d\n", errno);
 	}
@@ -213,7 +215,7 @@ int env_import(const char *buf, int check)
 		}
 	}
 
-	if (himport((char *)ep->data, ENV_SIZE, '\0', 0)) {
+	if (himport_r(&env_htab, (char *)ep->data, ENV_SIZE, '\0', 0)) {
 		gd->flags |= GD_FLG_ENV_READY;
 		return 1;
 	}
diff --git a/common/env_dataflash.c b/common/env_dataflash.c
index 270f2b3272766e8a3117155071b20dfe5de77813..1d570790277b2393e24ec4a7591beb4ca984bc71 100644
--- a/common/env_dataflash.c
+++ b/common/env_dataflash.c
@@ -68,7 +68,7 @@ int saveenv(void)
 	char	*res;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_eeprom.c b/common/env_eeprom.c
index 792b44ffabb898f85cb15ec8ecb25656cc3efcd6..0a179ad3d25917104c271718aae19755ed16c587 100644
--- a/common/env_eeprom.c
+++ b/common/env_eeprom.c
@@ -143,7 +143,7 @@ int saveenv(void)
 	BUG_ON(env_ptr != NULL);
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_flash.c b/common/env_flash.c
index 54c0bfec7624192276886dbfa0c886fc13052a02..456f2e8375972303832b33bdaf7b12d71cdb2cb2 100644
--- a/common/env_flash.c
+++ b/common/env_flash.c
@@ -155,7 +155,7 @@ int saveenv(void)
 	}
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		goto done;
@@ -289,7 +289,7 @@ int saveenv(void)
 		goto done;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		goto done;
diff --git a/common/env_mmc.c b/common/env_mmc.c
index 7c9392c86fb932ef95c8d1989f1eeb8fc1f1c3a3..71dcc4c3e2547c54e104dc0ac10fac802b7a54b5 100644
--- a/common/env_mmc.c
+++ b/common/env_mmc.c
@@ -107,7 +107,7 @@ int saveenv(void)
 		return 1;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_nand.c b/common/env_nand.c
index 7f6c91751891de647649460a55cb000a0d103420..2682f07fdcd8c1173a2c89e160643138128924ba 100644
--- a/common/env_nand.c
+++ b/common/env_nand.c
@@ -199,7 +199,7 @@ int saveenv(void)
 		return 1;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
@@ -256,7 +256,7 @@ int saveenv(void)
 		return 1;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_nvram.c b/common/env_nvram.c
index 6e90f2bcb53d82c30422beff96933794444ea001..544ce4711ea210517ca7288b19f361ce39f306ce 100644
--- a/common/env_nvram.c
+++ b/common/env_nvram.c
@@ -94,7 +94,7 @@ int saveenv(void)
 	int	rcode = 0;
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_onenand.c b/common/env_onenand.c
index 02cb5354f182bceb933aed745ae768eed1e33118..5e04a06cf537c1faef56b1613ff66d6488d174b3 100644
--- a/common/env_onenand.c
+++ b/common/env_onenand.c
@@ -109,7 +109,7 @@ int saveenv(void)
 	};
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
diff --git a/common/env_sf.c b/common/env_sf.c
index 47c6a7066543d14ec01253b6067ee8266856abd2..41cc00aeabb141d83f37039af054136944a7ad6a 100644
--- a/common/env_sf.c
+++ b/common/env_sf.c
@@ -92,7 +92,7 @@ int saveenv(void)
 	}
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		return 1;
@@ -308,7 +308,7 @@ int saveenv(void)
 	}
 
 	res = (char *)&env_new.data;
-	len = hexport('\0', &res, ENV_SIZE);
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
 	if (len < 0) {
 		error("Cannot export environment: errno = %d\n", errno);
 		goto done;
diff --git a/include/environment.h b/include/environment.h
index bedbc5424202595c81d10db310de39906c3d93b9..082b3e15b954ac06fd9f4068614944b9e16c0add 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -149,6 +149,12 @@ typedef	struct environment_s {
 	unsigned char	data[ENV_SIZE]; /* Environment data		*/
 } env_t;
 
+#ifndef DO_DEPS_ONLY
+
+#include <search.h>
+
+extern struct hsearch_data env_htab;
+
 /* Function that returns a character from the environment */
 unsigned char env_get_char (int);
 
@@ -165,4 +171,6 @@ void set_default_env(const char *s);
 /* Import from binary representation into hash table */
 int env_import(const char *buf, int check);
 
+#endif
+
 #endif	/* _ENVIRONMENT_H_ */
diff --git a/include/search.h b/include/search.h
index fccc757e0e5882cb20f2955bc24bd78427ece13c..81ced7f48e68ecf89137744040523d1fd7d4f7f1 100644
--- a/include/search.h
+++ b/include/search.h
@@ -32,15 +32,6 @@
 
 #define __set_errno(val) do { errno = val; } while (0)
 
-/*
- * Prototype structure for a linked-list data structure.
- * This is the type used by the `insque' and `remque' functions.
- */
-
-/* For use with hsearch(3).  */
-typedef int (*__compar_fn_t) (__const void *, __const void *);
-typedef __compar_fn_t comparison_fn_t;
-
 /* Action which shall be performed in the call the hsearch.  */
 typedef enum {
 	FIND,
@@ -69,11 +60,9 @@ struct hsearch_data {
 };
 
 /* Create a new hashing table which will at most contain NEL elements.  */
-extern int hcreate(size_t __nel);
 extern int hcreate_r(size_t __nel, struct hsearch_data *__htab);
 
 /* Destroy current internal hashing table.  */
-extern void hdestroy(void);
 extern void hdestroy_r(struct hsearch_data *__htab);
 
 /*
@@ -82,25 +71,20 @@ extern void hdestroy_r(struct hsearch_data *__htab);
  * NULL.  If ACTION is `ENTER' replace existing data (if any) with
  * ITEM.data.
  * */
-extern ENTRY *hsearch(ENTRY __item, ACTION __action);
 extern int hsearch_r(ENTRY __item, ACTION __action, ENTRY ** __retval,
 		     struct hsearch_data *__htab);
 
 /* Search and delete entry matching ITEM.key in internal hash table. */
-extern int hdelete(const char *__key);
 extern int hdelete_r(const char *__key, struct hsearch_data *__htab);
 
-extern ssize_t hexport(const char __sep, char **__resp, size_t __size);
 extern ssize_t hexport_r(struct hsearch_data *__htab,
 		     const char __sep, char **__resp, size_t __size);
 
-extern int himport(const char *__env, size_t __size, const char __sep,
-		   int __flag);
 extern int himport_r(struct hsearch_data *__htab,
 		     const char *__env, size_t __size, const char __sep,
 		     int __flag);
 
-/* Flags for himport() / himport_r() */
+/* Flags for himport_r() */
 #define	H_NOCLEAR	1	/* do not clear hash table before importing */
 
 #endif /* search.h */
diff --git a/lib/hashtable.c b/lib/hashtable.c
index 7ac3dddda693897f2a08cfda4ea682e943ab3e39..b47f3b69b0e0e7d97d86c4a559bbf27c83782903 100644
--- a/lib/hashtable.c
+++ b/lib/hashtable.c
@@ -59,11 +59,6 @@
  * [Knuth]	      The Art of Computer Programming, part 3 (6.4)
  */
 
-/*
- * The non-reentrant version use a global space for storing the hash table.
- */
-static struct hsearch_data htab;
-
 /*
  * The reentrant version has no static variables to maintain the state.
  * Instead the interface of all functions is extended to take an argument
@@ -97,11 +92,6 @@ static int isprime(unsigned int number)
 	return number % div != 0;
 }
 
-int hcreate(size_t nel)
-{
-	return hcreate_r(nel, &htab);
-}
-
 /*
  * Before using the hash table we must allocate memory for it.
  * Test for an existing table are done. We allocate one element
@@ -110,6 +100,7 @@ int hcreate(size_t nel)
  * The contents of the table is zeroed, especially the field used
  * becomes zero.
  */
+
 int hcreate_r(size_t nel, struct hsearch_data *htab)
 {
 	/* Test for correct arguments.  */
@@ -143,15 +134,12 @@ int hcreate_r(size_t nel, struct hsearch_data *htab)
 /*
  * hdestroy()
  */
-void hdestroy(void)
-{
-	hdestroy_r(&htab);
-}
 
 /*
  * After using the hash table it has to be destroyed. The used memory can
  * be freed and the local static variable can be marked as not used.
  */
+
 void hdestroy_r(struct hsearch_data *htab)
 {
 	int i;
@@ -214,15 +202,6 @@ void hdestroy_r(struct hsearch_data *htab)
  *   example for functions like hdelete().
  */
 
-ENTRY *hsearch(ENTRY item, ACTION action)
-{
-	ENTRY *result;
-
-	(void) hsearch_r(item, action, &result, &htab);
-
-	return result;
-}
-
 int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
 	      struct hsearch_data *htab)
 {
@@ -369,11 +348,6 @@ int hsearch_r(ENTRY item, ACTION action, ENTRY ** retval,
  * do that.
  */
 
-int hdelete(const char *key)
-{
-	return hdelete_r(key, &htab);
-}
-
 int hdelete_r(const char *key, struct hsearch_data *htab)
 {
 	ENTRY e, *ep;
@@ -442,11 +416,6 @@ int hdelete_r(const char *key, struct hsearch_data *htab)
  *		bytes in the string will be '\0'-padded.
  */
 
-ssize_t hexport(const char sep, char **resp, size_t size)
-{
-	return hexport_r(&htab, sep, resp, size);
-}
-
 static int cmpkey(const void *p1, const void *p2)
 {
 	ENTRY *e1 = *(ENTRY **) p1;
@@ -605,11 +574,6 @@ ssize_t hexport_r(struct hsearch_data *htab, const char sep,
  * '\0' and '\n' have really been tested.
  */
 
-int himport(const char *env, size_t size, const char sep, int flag)
-{
-	return himport_r(&htab, env, size, sep, flag);
-}
-
 int himport_r(struct hsearch_data *htab,
 	      const char *env, size_t size, const char sep, int flag)
 {