diff --git a/dev/js/src/menu.js b/dev/js/src/menu.js
index e575b7e..c3f7fa6 100644
--- a/dev/js/src/menu.js
+++ b/dev/js/src/menu.js
@@ -181,18 +181,44 @@
        * There is a prefix set, so filter the list!
        */
       var pos;
-      var prefix = " " + this.prefix().toLowerCase();
+      var prefixList = this.prefix().toLowerCase().split(" ");
+
+      var items = [];
+      var maxPoints = 1; // minimum 1
 
       // Iterate over all items and choose preferred matching items
       // i.e. the matching happens at the word start
       for (pos = 0; pos < this._items.length; pos++) {
-        if ((this.item(pos).lcField().indexOf(prefix)) >= 0)
+
+        var points = 0;
+
+        for (pref = 0; pref < prefixList.length; pref++) {
+          var prefix = " " + prefixList[pref];
+
+          // Check if it matches at the beginning
+          if ((this.item(pos).lcField().indexOf(prefix)) >= 0) {
+            points += 5;
+          }
+
+          // Check if it matches anywhere
+          else if ((this.item(pos).lcField().indexOf(prefix.substring(1))) >= 0) {
+            points += 1;
+          };
+        };
+
+        if (points > maxPoints) {
+          this._list = [pos];
+          maxPoints = points;
+        }
+        else if (points == maxPoints) {
           this._list.push(pos);
+        }
       };
 
       // The list is empty - so lower your expectations
       // Iterate over all items and choose matching items
       // i.e. the matching happens anywhere in the word
+      /*
       prefix = prefix.substring(1);
       if (this._list.length == 0) {
         for (pos = 0; pos < this._items.length; pos++) {
@@ -200,6 +226,7 @@
             this._list.push(pos);
         };
       };
+      */
 
       this._slider.length(this._list.length).reInit();
 
diff --git a/dev/js/src/menu/item.js b/dev/js/src/menu/item.js
index 3f955be..835f69f 100644
--- a/dev/js/src/menu/item.js
+++ b/dev/js/src/menu/item.js
@@ -5,6 +5,8 @@
  * further: action happen on right arrow
  */
 
+"use strict";
+
 /**
  * Item in the Dropdown menu
  */
@@ -153,13 +155,13 @@
     for (var i = marks.length - 1; i >= 0; i--) {
       // Create text node clone
       var x = document.createTextNode(
-	marks[i].firstChild.nodeValue
+	      marks[i].firstChild.nodeValue
       );
       
       // Replace with content
       marks[i].parentNode.replaceChild(
-	x,
-	marks[i]
+	      x,
+	      marks[i]
       );
     };
 
@@ -169,48 +171,114 @@
   },
 
   // Highlight a certain substring of the menu item
-  _highlight : function (elem, prefix) {
+  _highlight : function (elem, prefixString) {    
     if (elem.nodeType === 3) {
       
       var text   = elem.nodeValue;
       var textlc = text.toLowerCase();
-      var pos    = textlc.indexOf(prefix);
+
+      // Split prefixes
+      if (prefixString) {
+        var prefixes = prefixString.trim().split(" ");
+
+        var prefix;
+        var testPos;
+        var pos = -1;
+        var len = 0;
+
+        // Iterate over all prefixes and get the best one
+        for (var i = 0; i < prefixes.length; i++) {
+
+          // Get first pos of a matching prefix
+          testPos = textlc.indexOf(prefixes[i]);
+          if (testPos < 0)
+            continue;
+
+          if (pos === -1 || testPos < pos) {
+            pos = testPos;
+            len = prefixes[i].length;
+          }
+          else if (testPos === pos && prefixes[i].length > len) {
+            len = prefixes[i].length;
+          };
+        };
+
+        // Matches!
+        if (pos >= 0) {
+	
+	        // First element
+	        if (pos > 0) {
+	          elem.parentNode.insertBefore(
+	            document.createTextNode(text.substr(0, pos)),
+	            elem
+	          );
+	        };
+	
+	        // Second element
+	        var hl = document.createElement("mark");
+	        hl.appendChild(
+	          document.createTextNode(text.substr(pos, len))
+	        );
+	        elem.parentNode.insertBefore(hl, elem);
+	
+	        // Third element
+	        var third = text.substr(pos + len);
+
+	        if (third.length > 0) {
+	          var thirdE = document.createTextNode(third);
+	          elem.parentNode.insertBefore(
+	            thirdE,
+	            elem
+	          );
+	          this._highlight(thirdE, prefixString);
+	        };
+	
+	        var p = elem.parentNode;
+	        p.removeChild(elem);
+        };
+      };
+
+      /*
+      pos = textlc.indexOf(prefix);
+
+      // Matches!
       if (pos >= 0) {
 	
-	// First element
-	if (pos > 0) {
-	  elem.parentNode.insertBefore(
-	    document.createTextNode(text.substr(0, pos)),
-	    elem
-	  );
-	};
+	      // First element
+	      if (pos > 0) {
+	        elem.parentNode.insertBefore(
+	          document.createTextNode(text.substr(0, pos)),
+	          elem
+	        );
+	      };
 	
-	// Second element
-	var hl = document.createElement("mark");
-	hl.appendChild(
-	  document.createTextNode(text.substr(pos, prefix.length))
-	);
-	elem.parentNode.insertBefore(hl, elem);
+	      // Second element
+	      var hl = document.createElement("mark");
+	      hl.appendChild(
+	        document.createTextNode(text.substr(pos, prefix.length))
+	      );
+	      elem.parentNode.insertBefore(hl, elem);
 	
-	// Third element
-	var third = text.substr(pos + prefix.length);
-	if (third.length > 0) {
-	  var thirdE = document.createTextNode(third);
-	  elem.parentNode.insertBefore(
-	    thirdE,
-	    elem
-	  );
-	  this._highlight(thirdE, prefix);
-	};
+	      // Third element
+	      var third = text.substr(pos + prefix.length);
+	      if (third.length > 0) {
+	        var thirdE = document.createTextNode(third);
+	        elem.parentNode.insertBefore(
+	          thirdE,
+	          elem
+	        );
+	        this._highlight(thirdE, prefix);
+	      };
 	
-	var p = elem.parentNode;
-	p.removeChild(elem);
+	      var p = elem.parentNode;
+	      p.removeChild(elem);
       };
+      */
     }
     else {
       var children = elem.childNodes;
       for (var i = children.length -1; i >= 0; i--) {
-	this._highlight(children[i], prefix);
+	      this._highlight(children[i], prefixString);
       };
     };
   },
diff --git a/dev/js/src/menu/prefix.js b/dev/js/src/menu/prefix.js
index abcf66c..90924c9 100644
--- a/dev/js/src/menu/prefix.js
+++ b/dev/js/src/menu/prefix.js
@@ -107,7 +107,7 @@
     // Prefix is long enough for backspace
     if (this._string.length > 1) {
       this._string = this._string.substring(
-	0, this._string.length - 1
+	      0, this._string.length - 1
       );
     }
     else {
