--- a/minissdp.c
+++ b/minissdp.c
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <ctype.h>
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/un.h>
@@ -650,12 +651,12 @@
 		}
 		else if( !man || (strncmp(man, "\"ssdp:discover\"", 15) != 0) )
 		{
-			DPRINTF(E_INFO, L_SSDP, "WARNING: Ignoring invalid SSDP M-SEARCH from %s [bad MAN header %.*s]\n",
-			   inet_ntoa(sendername.sin_addr), man_len, man);
+			DPRINTF(E_INFO, L_SSDP, "WARNING: Ignoring invalid SSDP M-SEARCH from %s [bad %s header '%.*s']\n",
+			   inet_ntoa(sendername.sin_addr), "MAN", man_len, man);
 		}
 		else if( !mx || mx == mx_end || mx_val < 0 ) {
-			DPRINTF(E_INFO, L_SSDP, "WARNING: Ignoring invalid SSDP M-SEARCH from %s [bad MX header %.*s]\n",
-			   inet_ntoa(sendername.sin_addr), mx_len, mx);
+			DPRINTF(E_INFO, L_SSDP, "WARNING: Ignoring invalid SSDP M-SEARCH from %s [bad %s header '%.*s']\n",
+			   inet_ntoa(sendername.sin_addr), "MX", mx_len, mx);
 		}
 		else if( st && (st_len > 0) )
 		{
@@ -685,11 +686,26 @@
 			for(i = 0; known_service_types[i]; i++)
 			{
 				l = strlen(known_service_types[i]);
-				if(l<=st_len && (0 == memcmp(st, known_service_types[i], l)))
+				if( l <= st_len && (memcmp(st, known_service_types[i], l) == 0))
 				{
-					/* Check version number - must always be 1 currently. */
-					if( (st[st_len-2] == ':') && (atoi(st+st_len-1) != 1) )
-						break;
+					if( st_len != l )
+					{
+						/* Check version number - must always be 1 currently. */
+						if( (st[l-1] == ':') && (st[l] == '1') )
+							l++;
+						while( l < st_len )
+						{
+							if( !isspace(st[l]) )
+							{
+								DPRINTF(E_DEBUG, L_SSDP, "Ignoring SSDP M-SEARCH with bad extra data [%s]\n",
+									inet_ntoa(sendername.sin_addr));
+								break;
+							}
+							l++;
+						}
+						if( l != st_len )
+							break;
+					}
 					_usleep(random()>>20);
 					SendSSDPAnnounce2(s, sendername,
 					                  i,
@@ -731,6 +747,7 @@
 	struct sockaddr_in sockname;
 	int n, l;
 	int i, j;
+	int dup, ret = 0;
 	char bufr[512];
 
 	memset(&sockname, 0, sizeof(struct sockaddr_in));
@@ -738,31 +755,35 @@
 	sockname.sin_port = htons(SSDP_PORT);
 	sockname.sin_addr.s_addr = inet_addr(SSDP_MCAST_ADDR);
 
-	for(j=0; j<n_sockets; j++)
-	{
-		for(i=0; known_service_types[i]; i++)
-		{
-			l = snprintf(bufr, sizeof(bufr),
-			             "NOTIFY * HTTP/1.1\r\n"
-			             "HOST:%s:%d\r\n"
-			             "NT:%s%s\r\n"
-			             "USN:%s%s%s%s\r\n"
-			             "NTS:ssdp:byebye\r\n"
-			             "\r\n",
-			             SSDP_MCAST_ADDR, SSDP_PORT,
-			             known_service_types[i], (i>1?"1":""),
-			             uuidvalue, (i>0?"::":""), (i>0?known_service_types[i]:""), (i>1?"1":"") );
-			//DEBUG DPRINTF(E_DEBUG, L_SSDP, "Sending NOTIFY:\n%s", bufr);
-			n = sendto(sockets[j], bufr, l, 0,
-			           (struct sockaddr *)&sockname, sizeof(struct sockaddr_in) );
-			if(n < 0)
-			{
-				DPRINTF(E_ERROR, L_SSDP, "sendto(udp_shutdown=%d): %s\n", sockets[j], strerror(errno));
-				return -1;
-			}
-		}
-	}
-	return 0;
+	for (dup = 0; dup < 2; dup++)
+	{
+		for(j=0; j<n_sockets; j++)
+		{
+			for(i=0; known_service_types[i]; i++)
+			{
+				l = snprintf(bufr, sizeof(bufr),
+				             "NOTIFY * HTTP/1.1\r\n"
+				             "HOST:%s:%d\r\n"
+				             "NT:%s%s\r\n"
+				             "USN:%s%s%s%s\r\n"
+			        	     "NTS:ssdp:byebye\r\n"
+				             "\r\n",
+				             SSDP_MCAST_ADDR, SSDP_PORT,
+				             known_service_types[i], (i>1?"1":""),
+				             uuidvalue, (i>0?"::":""), (i>0?known_service_types[i]:""), (i>1?"1":"") );
+				//DEBUG DPRINTF(E_DEBUG, L_SSDP, "Sending NOTIFY:\n%s", bufr);
+				n = sendto(sockets[j], bufr, l, 0,
+				           (struct sockaddr *)&sockname, sizeof(struct sockaddr_in) );
+				if(n < 0)
+				{
+					DPRINTF(E_ERROR, L_SSDP, "sendto(udp_shutdown=%d): %s\n", sockets[j], strerror(errno));
+					ret = -1;
+					break;
+				}
+			}
+		}
+	}
+	return ret;
 }
 
 /* SubmitServicesToMiniSSDPD() :