Index: irc.c
===================================================================
--- irc.c	(revision b23c5c758097e7c7e9e0141ba9467177c0c32114)
+++ irc.c	(revision de3e100b7fa676bb628ead4cca2b8cee91fc3a84)
@@ -293,28 +293,43 @@
 int irc_process( irc_t *irc )
 {
-	char **lines, *temp;	
+	char **lines, *temp, **cmd;
 	int i;
 
-	if( irc->readbuffer != NULL ) {
-		lines = irc_tokenize(irc->readbuffer );
-		for( i = 0; *lines[i] != '\0'; i++ ) {
-			if( lines[i+1] == NULL ) {
+	if( irc->readbuffer != NULL )
+	{
+		lines = irc_tokenize( irc->readbuffer );
+		
+		for( i = 0; *lines[i] != '\0'; i ++ )
+		{
+			if( lines[i+1] == NULL )
+			{
 				temp = g_strdup( lines[i] );
 				g_free( irc->readbuffer );
 				irc->readbuffer = temp;
-				i++;
+				i ++;
 				break;
 			}			
-			if (!irc_process_line(irc, lines[i])) {
+			
+			if( ( cmd = irc_parse_line( irc, lines[i] ) ) == NULL )
+				continue;
+			if( !irc_exec( irc, cmd ) )
+			{
+				g_free( cmd );
 				g_free( lines );
 				return 0;
 			}
-		}
-		if(lines[i]!=NULL) {
-			g_free(irc->readbuffer);
-			irc->readbuffer=NULL;	
-		}
+			
+			g_free( cmd );
+		}
+		
+		if( lines[i] != NULL )
+		{
+			g_free( irc->readbuffer );
+			irc->readbuffer = NULL;	
+		}
+		
 		g_free( lines );
 	}
+	
 	return 1;	
 }
@@ -326,40 +341,39 @@
 
 	/* Count the number of elements we're gonna need. */
-	for(i=0, j=1; buffer[i]!='\0'; i++ ) {
-		if(buffer[i]=='\n' )
-			if(buffer[i+1]!='\r' && buffer[i+1]!='\n')
-				j++;
+	for( i = 0, j = 1; buffer[i] != '\0'; i ++ )
+	{
+		if( buffer[i] == '\n' )
+			if( buffer[i+1] != '\r' && buffer[i+1] != '\n' )
+				j ++;
 	}
 	
 	/* Allocate j+1 elements. */
-	lines=g_new (char *, j+1);
+	lines = g_new( char *, j + 1 );
 	
 	/* NULL terminate our list. */ 
-	lines[j]=NULL;
-	
-	lines[0]=buffer;
+	lines[j] = NULL;
+	
+	lines[0] = buffer;
 	
 	/* Split the buffer in several strings, using \r\n as our seperator, where \r is optional.
 	 * Although this is not in the RFC, some braindead ircds (newnet's) use this, so some clients might too. 
 	 */
-	for( i=0, j=0; buffer[i]!='\0'; i++) {
-		if(buffer[i]=='\n') {
-			buffer[i]='\0';
-
-			/* We dont want to read 1 byte before our buffer
-			 * and (in rare cases) generate a SIGSEGV.
-			 */
-			if(i!=0)
-				if(buffer[i-1]=='\r')
-					buffer[i-1]='\0';
-			if(buffer[i+1]!='\r'&&buffer[i+1]!='\n')
-				lines[++j]=buffer+i+1;
-		}
-	}
-
-	return(lines);
-}
-
-int irc_process_line( irc_t *irc, char *line )
+	for( i = 0, j = 0; buffer[i] != '\0'; i ++)
+	{
+		if( buffer[i] == '\n' )
+		{
+			buffer[i] = '\0';
+			
+			if( i > 0 && buffer[i-1] == '\r' )
+				buffer[i-1] = '\0';
+			if( buffer[i+1] != '\r' && buffer[i+1] != '\n' )
+				lines[++j] = buffer + i + 1;
+		}
+	}
+	
+	return( lines );
+}
+
+char **irc_parse_line( irc_t *irc, char *line )
 {
 	int i, j;
@@ -367,31 +381,32 @@
 	
 	/* Move the line pointer to the start of the command, skipping spaces and the optional prefix. */
-	if(line[0]==':') {
-		for(i=0; line[i]!=32; i++);
-		line=line+i;
-	}
-	for(i=0; line[i]==32; i++);
-	line=line+i;
-
+	if( line[0] == ':' )
+	{
+		for( i = 0; line[i] != ' '; i ++ );
+		line = line + i;
+	}
+	for( i = 0; line[i] == ' '; i ++ );
+	line = line + i;
+	
 	/* If we're already at the end of the line, return. If not, we're going to need at least one element. */
-	if(line[0]=='\0')
-		return 1;
-	else
-		j=1;	
-	
-	/* Count the number of char **cmd elements we're going to need. */	
-	for(i=0; line[i]!='\0'; i++) {
-		if((line[i]==32) && (line[i+1]!=32) && (line[i+1]!='\0') && (line[i+1]!=':'))		
-			j++;
-		else if((line[i]==':') && (line[i+1]!='\0') && (line[i-1]==32)) {
-			j++;
-			break;
-		}
+	if( line[0] == '\0')
+		return NULL;
+	
+	/* Count the number of char **cmd elements we're going to need. */
+	j = 1;
+	for( i = 0; line[i] != '\0'; i ++ )
+	{
+		if( line[i] == ' ' )
+		{
+			j ++;
 			
+			if( line[i+1] == ':' )
+				break;
+		}
 	}	
 
 	/* Allocate the space we need. */
-	cmd=g_new(char *, j+1);
-	cmd[j]=NULL;
+	cmd = g_new( char *, j + 1 );
+	cmd[j] = NULL;
 	
 	/* Do the actual line splitting, format is:
@@ -400,21 +415,21 @@
 	 */
 
-	cmd[0]=line;
-	for(i=0, j=0; line[i]!='\0'; i++) {
-		if((line[i]==32)) {
-			line[i]='\0';
-			if((line[i+1]!=32) && (line[i+1]!='\0') && (line[i+1]!=':')) 		
-				cmd[++j]=line+i+1;
-		}
-		else if((line[i]==':') && (line[i+1]!='\0') && (line[i-1]=='\0')) {
-			cmd[++j]=line+i+1;
-			break;
-		}
-	}
-	
-	i=irc_exec(irc, cmd);
-	g_free(cmd);
-
-	return(i);	
+	cmd[0] = line;
+	for( i = 0, j = 0; line[i] != '\0'; i ++ )
+	{
+		if( line[i] == ' ' )
+		{
+			line[i] = '\0';
+			cmd[++j] = line + i + 1;
+			
+			if( line[i+1] == ':' )
+			{
+				cmd[j] ++;
+				break;
+			}
+		}
+	}
+	
+	return cmd;
 }
 
Index: irc.h
===================================================================
--- irc.h	(revision b23c5c758097e7c7e9e0141ba9467177c0c32114)
+++ irc.h	(revision de3e100b7fa676bb628ead4cca2b8cee91fc3a84)
@@ -108,5 +108,5 @@
 int irc_exec( irc_t *irc, char **cmd );
 int irc_process( irc_t *irc );
-int irc_process_line( irc_t *irc, char *line );
+char **irc_parse_line( irc_t *irc, char *line );
 
 void irc_vawrite( irc_t *irc, char *format, va_list params );
Index: irc_commands.c
===================================================================
--- irc_commands.c	(revision b23c5c758097e7c7e9e0141ba9467177c0c32114)
+++ irc_commands.c	(revision de3e100b7fa676bb628ead4cca2b8cee91fc3a84)
@@ -32,5 +32,5 @@
 	{
 		irc->status = USTATUS_AUTHORIZED;
-		irc_check_login();
+		irc_check_login( irc );
 	}
 	else
