more bugs fixed -- found doing regression testing
 -Erik
diff --git a/busybox.c b/busybox.c
index 0439fb5..5eb9dfa 100644
--- a/busybox.c
+++ b/busybox.c
@@ -89,7 +89,37 @@
 {
 	struct BB_applet search_applet, *applet;
 	const char				*s;
-	applet_name = "busybox";
+
+	for (s = applet_name = argv[0]; *s != '\0';) {
+		if (*s++ == '/')
+			applet_name = s;
+	}
+
+#ifdef BB_SH
+	/* Add in a special case hack -- whenever **argv == '-'
+	 * (i.e. '-su' or '-sh') always invoke the shell */
+	if (**argv == '-' && *(*argv+1)!= '-') {
+		exit(((*(shell_main)) (argc, argv)));
+	}
+#endif
+
+	/* Do a binary search to find the applet entry given the name. */
+	search_applet.name = applet_name;
+	applet = bsearch(&search_applet, applets, NUM_APPLETS,
+			sizeof(struct BB_applet), applet_name_compare);
+	if (applet != NULL) {
+		if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
+			usage(applet->usage); 
+		exit((*(applet->main)) (argc, argv));
+	}
+
+	error_msg_and_die("applet not found\n");
+}
+
+
+int busybox_main(int argc, char **argv)
+{
+	int col = 0, len, i;
 
 #ifdef BB_FEATURE_INSTALLER	
 	/* 
@@ -121,37 +151,6 @@
 	}
 #endif /* BB_FEATURE_INSTALLER */
 
-	for (s = applet_name = argv[0]; *s != '\0';) {
-		if (*s++ == '/')
-			applet_name = s;
-	}
-
-#ifdef BB_SH
-	/* Add in a special case hack -- whenever **argv == '-'
-	 * (i.e. '-su' or '-sh') always invoke the shell */
-	if (**argv == '-' && *(*argv+1)!= '-') {
-		exit(((*(shell_main)) (argc, argv)));
-	}
-#endif
-
-	/* Do a binary search to find the applet entry given the name. */
-	search_applet.name = applet_name;
-	applet = bsearch(&search_applet, applets, NUM_APPLETS,
-			sizeof(struct BB_applet), applet_name_compare);
-	if (applet != NULL) {
-		if (applet->usage && argv[1] && strcmp(argv[1], "--help") == 0)
-			usage(applet->usage); 
-		exit((*(applet->main)) (argc, argv));
-	}
-
-	return(busybox_main(argc, argv));
-}
-
-
-int busybox_main(int argc, char **argv)
-{
-	int col = 0, len, i;
-
 	argc--;
 
 	/* If we've already been here once, exit now */