Index: help.c
===================================================================
--- help.c	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ help.c	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -71,19 +71,18 @@
 		{
 			/* FIXME: Clean up */
-//			help_close( *help );
-			*help = NULL;
+			help_free( help );
 			g_free( s );
-			return( NULL );
+			return NULL;
 		}
 		i = strchr( s, '\n' ) - s;
 		
-		if( h->string )
+		if( h->title )
 		{
 			h = h->next = g_new0( help_t, 1 );
 		}
-		h->string = g_new ( char, i );
+		h->title = g_new ( char, i );
 		
-		strncpy( h->string, s + 1, i - 1 );
-		h->string[i-1] = 0;
+		strncpy( h->title, s + 1, i - 1 );
+		h->title[i-1] = 0;
 		h->fd = (*help)->fd;
 		h->offset.file_offset = lseek( h->fd, 0, SEEK_CUR ) - buflen + i + 1;
@@ -103,5 +102,29 @@
 }
 
-char *help_get( help_t **help, char *string )
+void help_free( help_t **help )
+{
+	help_t *h, *oh;
+	int last_fd = -1; /* Weak de-dupe */
+	
+	if( help == NULL || *help == NULL )
+		return;
+	
+	h = *help;
+	while( h )
+	{
+		if( h->fd != last_fd )
+		{
+			close( h->fd );
+			last_fd = h->fd;
+		}
+		g_free( h->title );
+		h = (oh=h)->next;
+		g_free( oh );
+	}
+	
+	*help = NULL;
+}
+
+char *help_get( help_t **help, char *title )
 {
 	time_t mtime;
@@ -111,6 +134,5 @@
 	for( h = *help; h; h = h->next )
 	{
-		if( h->string != NULL && 
-			g_strcasecmp( h->string, string ) == 0 ) 
+		if( h->title != NULL && g_strcasecmp( h->title, title ) == 0 )
 			break;
 	}
@@ -119,18 +141,20 @@
 		char *s = g_new( char, h->length + 1 );
 		
-		if( fstat( h->fd, stat ) != 0 )
-		{
-			g_free( h );
-			*help = NULL;
-			return NULL;
-		}
-		mtime = stat->st_mtime;
-		
-		if( mtime > h->mtime )
-			return NULL;
-		
 		s[h->length] = 0;
 		if( h->fd >= 0 )
 		{
+			if( fstat( h->fd, stat ) != 0 )
+			{
+				g_free( s );
+				return NULL;
+			}
+			mtime = stat->st_mtime;
+		
+			if( mtime > h->mtime )
+			{
+				g_free( s );
+				return NULL;
+			}
+			
 			lseek( h->fd, h->offset.file_offset, SEEK_SET );
 			read( h->fd, s, h->length );
Index: help.h
===================================================================
--- help.h	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ help.h	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -37,5 +37,5 @@
 	int fd;
 	time_t mtime;
-	char *string;
+	char *title;
 	help_off_t offset;
 	int length;
@@ -44,5 +44,6 @@
 
 G_GNUC_MALLOC help_t *help_init( help_t **help, const char *helpfile );
-char *help_get( help_t **help, char *string );
+void help_free( help_t **help );
+char *help_get( help_t **help, char *title );
 
 #endif
Index: irc.c
===================================================================
--- irc.c	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ irc.c	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -189,5 +189,4 @@
 	account_t *account;
 	user_t *user, *usertmp;
-	help_t *helpnode, *helpnodetmp;
 	
 	log_message( LOGLVL_INFO, "Destroying connection with fd %d", irc->fd );
@@ -266,14 +265,4 @@
 	g_hash_table_destroy(irc->watches);
 	
-	if (irc->help != NULL) {
-		helpnode = irc->help;
-		while (helpnode != NULL) {
-			g_free(helpnode->string);
-			
-			helpnodetmp = helpnode;
-			helpnode = helpnode->next;
-			g_free(helpnodetmp);
-		}
-	}
 	g_free(irc);
 	
Index: irc.h
===================================================================
--- irc.h	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ irc.h	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -89,5 +89,4 @@
 	GHashTable *watches;
 	struct __NICK *nicks;
-	struct help *help;
 	struct set *set;
 
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ irc_commands.c	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -556,5 +556,5 @@
 	
 	for( h = global.help; h; h = h->next )
-		irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->string );
+		irc_privmsg( irc, u, "NOTICE", irc->nick, "COMPLETIONS help ", h->title );
 	
 	for( s = irc->set; s; s = s->next )
Index: unix.c
===================================================================
--- unix.c	(revision f774e01cdb34e339455671f51413ecdc6de3208d)
+++ unix.c	(revision 0fbda19314c806e3e677847f3c977eb5a1bc2b61)
@@ -124,8 +124,11 @@
 	if( !getuid() || !geteuid() )
 		log_message( LOGLVL_WARNING, "BitlBee is running with root privileges. Why?" );
-	if( help_init( &(global.help), global.helpfile ) == NULL )
+	if( help_init( &global.help, global.helpfile ) == NULL )
 		log_message( LOGLVL_WARNING, "Error opening helpfile %s.", HELP_FILE );
 	
 	b_main_run();
+	
+	/* Mainly good for restarting, to make sure we close the help.txt fd. */
+	help_free( &global.help );
 	
 	if( global.restart )
