diff --git a/public/css/vc.css b/public/css/vc.css
index 377f19a..e05c3cb 100644
--- a/public/css/vc.css
+++ b/public/css/vc.css
@@ -31,23 +31,28 @@
 }
 
 .vc .rewritten .rewrite {
-  color: red;
-  font-weight: bold;
-  background-color: yellow;
-  width: 1.5em;
-  height: 1.2em;
-  margin-left: 2px;
-  border-radius: 8pt;
+  margin-left: 4pt;
   display: inline-block;
+  color: #ffa500;
+}
+
+.vc .rewritten .rewrite:after {
+  font-family: FontAwesome;
+  font-style: normal;
+  font-weight: normal;
+  content: "\f040"; // "\f14b";
+  text-decoration: underline;
 }
 
 .vc .rewritten .rewrite span {
   display: none;
 }
 
+/*
 .vc .rewritten .rewrite:hover span {
   display: block;
 }
+*/
 
 .vc .docGroup .docGroup {
   display: block;
diff --git a/public/js/demo/vc.html b/public/js/demo/vc.html
index 9254d68..ea4a53c 100644
--- a/public/js/demo/vc.html
+++ b/public/js/demo/vc.html
@@ -3,6 +3,7 @@
   <head>
     <title>Virtual Collection demo</title>
     <meta charset="utf-8" />
+    <script src="../src/menu.js"></script>
     <script src="../src/vc.js"></script>
     <link href="../../css/vc.css" rel="stylesheet" type="text/css"></link>
     <style type="text/css" rel="stylesheet">
@@ -16,46 +17,47 @@
   </head>
   <body>
     <div id="vc"></div>
+    <div id="menu"></div>
 
     <script>
     var json = {
-      "@type":"korap:docGroup",
+      "@type":"koral:docGroup",
       "operation":"operation:or",
       "operands":[
         {
-          "@type":"korap:docGroup",
+          "@type":"koral:docGroup",
           "operation":"operation:and",
           "operands":[
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Titel",
               "value":"Baum",
               "match":"match:eq"
             },
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Veröffentlichungsort",
               "value":"hihi",
               "match":"match:eq"
             },
             {
-              "@type":"korap:docGroup",
+              "@type":"koral:docGroup",
               "operation":"operation:or",
               "operands":[
                 {
-                  "@type":"korap:doc",
+                  "@type":"koral:doc",
                   "key":"Titel",
                   "value":"Baum",
                   "match":"match:eq"
                 },
                 {
-                  "@type":"korap:doc",
+                  "@type":"koral:doc",
                   "key":"Veröffentlichungsort",
                   "value":"hihi",
                   "match":"match:eq",
                   "rewrites" : [
                     {
-                      "@type": "korap:rewrite",
+                      "@type": "koral:rewrite",
                       "src" : "policy",
                       "operation" : "operation:injection",
                     }
@@ -66,7 +68,7 @@
           ]
         },
         {
-          "@type":"korap:doc",
+          "@type":"koral:doc",
           "key":"Untertitel",
           "value":"huhu",
           "match":"match:eq"
@@ -87,6 +89,19 @@
       document.getElementById("query").innerHTML = vc.root().toQuery();
     };
 
+    var menu = KorAP.FieldMenu.create([
+      ['Titel', 'title', 'string'],
+      ['Untertitel', 'subTitle', 'string'],
+      ['Veröffentlichungsdatum', 'pubDate', 'date']
+    ]);
+    menu.limit(4);
+    menu.show();
+
+    document.getElementById('menu').appendChild(menu.element());
+
+    menu.focus();
+
+
     </script>
 
     <hr />
diff --git a/public/js/runner/vc.html b/public/js/runner/vc.html
index e010587..f0e8179 100644
--- a/public/js/runner/vc.html
+++ b/public/js/runner/vc.html
@@ -8,6 +8,7 @@
   <script src="../lib/jasmine-2.1.1/jasmine.js"></script>
   <script src="../lib/jasmine-2.1.1/jasmine-html.js"></script>
   <script src="../lib/jasmine-2.1.1/boot.js"></script>
+  <script src="../src/menu.js"></script>
   <script src="../src/vc.js"></script>
   <script src="../spec/vcSpec.js"></script>
 </head>
diff --git a/public/js/spec/hintSpec.js b/public/js/spec/hintSpec.js
index 80807ff..a7232d4 100644
--- a/public/js/spec/hintSpec.js
+++ b/public/js/spec/hintSpec.js
@@ -705,4 +705,81 @@
     var hint = KorAP.Hint.create();
   });
 });
+
+
+describe('KorAP.ContextAnalyzer', function () {
+
+  it('should be initializable', function () {
+    var analyzer = KorAP.ContextAnalyzer.create(")");
+    expect(analyzer).toBe(undefined);
+
+    analyzer = KorAP.ContextAnalyzer.create(".+?");
+    expect(analyzer).not.toBe(undefined);
+
+  });
+
+  it('should check correctly', function () {
+    analyzer = KorAP.ContextAnalyzer.create(KorAP.context);
+    expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
+    expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
+    expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
+    expect(analyzer.test("impcnx/")).toEqual("impcnx/");
+    expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/");
+    expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600="))
+      .toEqual("corenlp/ne_dewac_175m_600=");
+  });
+});
+
+describe('KorAP.InputField', function () {
+  var input;
+
+  beforeAll(function () {
+    input = document.createElement("input");
+    input.setAttribute("type", "text");
+    input.setAttribute("value", "abcdefghijklmno");
+    input.style.position = 'absolute';
+    input.style.top  = "20px";
+    input.style.left = "30px";
+    input.focus();
+    input.selectionStart = 5;
+  });
+
+  afterAll(function () {
+    document.getElementsByTagName("body")[0].removeChild(input);
+    document.getElementsByTagName("body")[0].removeChild(
+      document.getElementById("searchMirror")
+    );
+  });
+
+  it('should be initializable', function () {
+    // Supports: context, searchField
+    var inputField = KorAP.InputField.create(input);
+    expect(inputField._element).not.toBe(undefined);
+  });
+
+  it('should have text', function () {
+    var inputField = KorAP.InputField.create(input);
+
+    expect(inputField.value).toEqual("abcdefghijklmno");
+    expect(inputField.element.selectionStart).toEqual(5);
+    expect(inputField.split()[0]).toEqual("abcde");
+    expect(inputField.split()[1]).toEqual("fghijklmno");
+
+    inputField.insert("xyz");
+    expect(inputField.split()[0]).toEqual("abcdexyz");
+    expect(inputField.split()[1]).toEqual("fghijklmno");
+
+  });
+
+  it('should be correctly positioned', function () {
+    var inputField = KorAP.InputField.create(input);
+    document.getElementsByTagName("body")[0].appendChild(input);
+    inputField.reposition();
+    expect(inputField.mirror.style.left).toEqual("30px");
+    expect(inputField.mirror.style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
+  });
+});
+
+
+
 */
diff --git a/public/js/spec/menuSpec.js b/public/js/spec/menuSpec.js
index 98f6e72..cc569a8 100644
--- a/public/js/spec/menuSpec.js
+++ b/public/js/spec/menuSpec.js
@@ -1,3 +1,4 @@
+// The OwnMenu item
 KorAP.OwnMenuItem = {
   create : function (params) {
     return Object.create(KorAP.MenuItem).upgradeTo(KorAP.OwnMenuItem)._init(params);
@@ -19,36 +20,8 @@
   }
 };
 
-KorAP.ComplexMenuItem = {
-  create : function (params) {
-    return Object.create(KorAP.MenuItem)
-      .upgradeTo(KorAP.ComplexMenuItem)
-      ._init(params);
-  },
-  content : function (content) {
-    if (arguments.length === 1) {
-      this._content = content;
-    };
-    return this._content;
-  },
-  _init : function (params) {
-    if (params[0] === undefined)
-      throw new Error("Missing parameters");
 
-    var r = document.createElement('div');
-    for (var i = 1; i <= params.length; i++) {
-      var h = document.createElement('h' + i);
-      h.appendChild(document.createTextNode(params[i-1]));
-      r.appendChild(h);
-    };
-
-    this._content = r;
-    this._lcField = ' ' + this.content().textContent.toLowerCase();
-
-    return this;
-  }
-};
-
+// The OwnMenu
 KorAP.OwnMenu = {
   create : function (params) {
     return Object.create(KorAP.Menu)
@@ -58,17 +31,7 @@
 };
 
 
-// Support for hint
-KorAP.HintMenu = {
-  create : function (context, params) {
-    var obj = Object.create(KorAP.Menu)
-      .upgradeTo(KorAP.HintMenu)
-      ._init(KorAP.HintMenuItem, params);
-    obj._context = context;
-    return obj;
-  }
-};
-
+// HintMenuItem
 KorAP.HintMenuItem = {
   create : function (params) {
    return Object.create(KorAP.MenuItem)
@@ -131,6 +94,50 @@
 };
 
 
+// HintMenu
+KorAP.HintMenu = {
+  create : function (context, params) {
+    var obj = Object.create(KorAP.Menu)
+      .upgradeTo(KorAP.HintMenu)
+      ._init(KorAP.HintMenuItem, params);
+    obj._context = context;
+    return obj;
+  }
+};
+
+
+// The ComplexMenuItem
+KorAP.ComplexMenuItem = {
+  create : function (params) {
+    return Object.create(KorAP.MenuItem)
+      .upgradeTo(KorAP.ComplexMenuItem)
+      ._init(params);
+  },
+  content : function (content) {
+    if (arguments.length === 1) {
+      this._content = content;
+    };
+    return this._content;
+  },
+  _init : function (params) {
+    if (params[0] === undefined)
+      throw new Error("Missing parameters");
+
+    var r = document.createElement('div');
+    for (var i = 1; i <= params.length; i++) {
+      var h = document.createElement('h' + i);
+      h.appendChild(document.createTextNode(params[i-1]));
+      r.appendChild(h);
+    };
+
+    this._content = r;
+    this._lcField = ' ' + this.content().textContent.toLowerCase();
+
+    return this;
+  }
+};
+
+
 
 describe('KorAP.MenuItem', function () {
   it('should be initializable', function () {
@@ -305,6 +312,14 @@
 
 
 describe('KorAP.Menu', function () {
+  var list = [
+    ["Constituency", "c=", "Example 1"],
+    ["Lemma", "l="],
+    ["Morphology", "m=", "Example 2"],
+    ["Part-of-Speech", "p="],
+    ["Syntax", "syn="]
+  ];
+
   it('should be initializable', function () {
     var list = [
       ["Constituency"],
@@ -342,13 +357,6 @@
   });
 
   it('should be visible', function () {
-    var list = [
-      ["Constituency", "c=", "Example 1"],
-      ["Lemma", "l="],
-      ["Morphology", "m=", "Example 2"],
-      ["Part-of-Speech", "p="],
-      ["Syntax", "syn="]
-    ];
     var menu = KorAP.HintMenu.create("cnx/", list);
     expect(menu.delete()).toBe(undefined);
     menu.limit(3);
@@ -368,14 +376,6 @@
   });
 
   it('should be filterable', function () {
-    var list = [
-      ["Constituency", "c=", "Example 1"],
-      ["Lemma", "l="],
-      ["Morphology", "m=", "Example 2"],
-      ["Part-of-Speech", "p="],
-      ["Syntax", "syn="]
-    ];
-
     var menu = KorAP.HintMenu.create("cnx/", list);
     menu.limit(3);
 
@@ -421,14 +421,6 @@
 
 
   it('should be nextable', function () {
-    var list = [
-      ["Constituency", "c=", "Example 1"],
-      ["Lemma", "l="],
-      ["Morphology", "m=", "Example 2"],
-      ["Part-of-Speech", "p="],
-      ["Syntax", "syn="]
-    ];
-
     var menu = KorAP.HintMenu.create("cnx/", list);
 
     // Show only 3 items
@@ -464,332 +456,249 @@
     expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate next (3)
+    // scroll!
     menu.next();
-//    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Lemma</strong>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Lemma</strong>");
+
     expect(menu.shownItem(0).active()).toBe(false);
-//    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
-//    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
     expect(menu.shownItem(2).active()).toBe(true);
     expect(menu.element().childNodes[3]).toBe(undefined);
-  });
-});
-
-
-/*
-describe('KorAP.Menu', function () {
-
-
 
     // Activate next (4)
     menu.next();
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
     expect(menu.shownItem(2).active()).toBe(true);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate next (5) - ROLL
     menu.next();
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Active next (6)
     menu.next();
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
     expect(menu.shownItem(1).active()).toBe(true);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
-
+    expect(menu.element().childNodes[3]).toBe(undefined);
   });
 
-
   it('should be prevable', function () {
-    var menu = KorAP.Menu.create("cnx/", list);
+    var menu = KorAP.HintMenu.create("cnx/", list);
 
-    KorAP.limit = 3;
+    menu.limit(3);
     expect(menu.show()).toBe(undefined);
 
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Lemma</strong>");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (1) - roll to bottom
     menu.prev();
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
     expect(menu.shownItem(2).active()).toBe(true);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (2)
     menu.prev();
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Morphology</strong><span>Example 2</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-of-Speech</strong>");
     expect(menu.shownItem(1).active()).toBe(true);
-    expect(menu.element.childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
+    expect(menu.element().childNodes[2].innerHTML).toEqual("<strong>Syntax</strong>");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (3)
     menu.prev();
-    expect(menu.shownItem(0).name).toEqual("Morphology");
+    expect(menu.shownItem(0).name()).toEqual("Morphology");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
+    expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.shownItem(2).name).toEqual("Syntax");
+    expect(menu.shownItem(2).name()).toEqual("Syntax");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (4)
     menu.prev();
-    expect(menu.shownItem(0).name).toEqual("Lemma");
+    expect(menu.shownItem(0).name()).toEqual("Lemma");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.shownItem(2).name).toEqual("Part-of-Speech");
+    expect(menu.shownItem(2).name()).toEqual("Part-of-Speech");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (5)
     menu.prev();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Lemma");
+    expect(menu.shownItem(1).name()).toEqual("Lemma");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.shownItem(2).name).toEqual("Morphology");
+    expect(menu.shownItem(2).name()).toEqual("Morphology");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate next (1)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Lemma");
+    expect(menu.shownItem(1).name()).toEqual("Lemma");
     expect(menu.shownItem(1).active()).toBe(true);
-    expect(menu.shownItem(2).name).toEqual("Morphology");
+    expect(menu.shownItem(2).name()).toEqual("Morphology");
     expect(menu.shownItem(2).active()).toBe(false);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
 
     // Activate prev (6)
     menu.prev();
 
     // Activate prev (7)
     menu.prev();
-    expect(menu.shownItem(0).name).toEqual("Morphology");
+    expect(menu.shownItem(0).name()).toEqual("Morphology");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
+    expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
     expect(menu.shownItem(1).active()).toBe(false);
-    expect(menu.shownItem(2).name).toEqual("Syntax");
+    expect(menu.shownItem(2).name()).toEqual("Syntax");
     expect(menu.shownItem(2).active()).toBe(true);
-    expect(menu.element.childNodes[3]).toBe(undefined);
+    expect(menu.element().childNodes[3]).toBe(undefined);
   });
 
-  it('should be navigatable and filterable (prefix = "o")', function () {
-    var menu = KorAP.Menu.create("cnx/", list);
 
-    KorAP.limit = 2;
+  it('should be navigatable and filterable (prefix = "o")', function () {
+    var menu = KorAP.HintMenu.create("cnx/", list);
+    menu.limit(2);
 
     expect(menu.show("o")).toBe(undefined);
 
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (1)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
     expect(menu.shownItem(1).active()).toBe(true);
     expect(menu.shownItem(2)).toBe(undefined);
 
-
     // Next (2)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Morphology");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+    expect(menu.shownItem(0).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Part-of-Speech");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Part-<em>o</em>f-Speech</strong>");
+    expect(menu.shownItem(1).name()).toEqual("Part-of-Speech");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Part-<mark>o</mark>f-Speech</strong>");
     expect(menu.shownItem(1).active()).toBe(true);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (3)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>C<em>o</em>nstituency</strong><span>Example 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>C<mark>o</mark>nstituency</strong><span>Example 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>M<em>o</em>rphology</strong><span>Example 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>M<mark>o</mark>rph<mark>o</mark>l<mark>o</mark>gy</strong><span>Example 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
   });
 
+
   it('should be navigatable and filterable (prefix = "ex", "e")', function () {
-    var menu = KorAP.Menu.create("cnx/", list);
+    var menu = KorAP.HintMenu.create("cnx/", list);
 
-    KorAP.limit = 2;
-
+    menu.limit(2);
     expect(menu.show("ex")).toBe(undefined);
 
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (1)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
     expect(menu.shownItem(1).active()).toBe(true);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (2)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><em>Ex</em>ample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constituency</strong><span><mark>Ex</mark>ample 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>Ex</em>ample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>Ex</mark>ample 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Reset limit
-    KorAP.limit = 5;
+    menu.limit(5);
 
     // Change show
     expect(menu.show("e")).toBe(undefined);
 
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (1)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
     expect(menu.shownItem(0).active()).toBe(false);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
     expect(menu.shownItem(1).active()).toBe(true);
     expect(menu.shownItem(2)).toBe(undefined);
 
     // Next (2)
     menu.next();
-    expect(menu.shownItem(0).name).toEqual("Constituency");
-    expect(menu.element.childNodes[0].innerHTML).toEqual("<strong>Constitu<em>e</em>ncy</strong><span><em>E</em>xample 1</span>");
+    expect(menu.shownItem(0).name()).toEqual("Constituency");
+    expect(menu.element().childNodes[0].innerHTML).toEqual("<strong>Constitu<mark>e</mark>ncy</strong><span><mark>E</mark>xampl<mark>e</mark> 1</span>");
     expect(menu.shownItem(0).active()).toBe(true);
-    expect(menu.shownItem(1).name).toEqual("Morphology");
-    expect(menu.element.childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><em>E</em>xample 2</span>");
+    expect(menu.shownItem(1).name()).toEqual("Morphology");
+    expect(menu.element().childNodes[1].innerHTML).toEqual("<strong>Morphology</strong><span><mark>E</mark>xampl<mark>e</mark> 2</span>");
     expect(menu.shownItem(1).active()).toBe(false);
     expect(menu.shownItem(2)).toBe(undefined);
   });
 });
-
-describe('KorAP.ContextAnalyzer', function () {
-
-  it('should be initializable', function () {
-    var analyzer = KorAP.ContextAnalyzer.create(")");
-    expect(analyzer).toBe(undefined);
-
-    analyzer = KorAP.ContextAnalyzer.create(".+?");
-    expect(analyzer).not.toBe(undefined);
-
-  });
-
-  it('should check correctly', function () {
-    analyzer = KorAP.ContextAnalyzer.create(KorAP.context);
-    expect(analyzer.test("cnx/]cnx/c=")).toEqual("cnx/c=");
-    expect(analyzer.test("cnx/c=")).toEqual("cnx/c=");
-    expect(analyzer.test("cnx/c=np mate/m=mood:")).toEqual("mate/m=mood:");
-    expect(analyzer.test("impcnx/")).toEqual("impcnx/");
-    expect(analyzer.test("cnx/c=npcnx/")).toEqual("npcnx/");
-    expect(analyzer.test("mate/m=degree:pos corenlp/ne_dewac_175m_600="))
-      .toEqual("corenlp/ne_dewac_175m_600=");
-  });
-});
-
-describe('KorAP.InputField', function () {
-  var input;
-
-  beforeAll(function () {
-    input = document.createElement("input");
-    input.setAttribute("type", "text");
-    input.setAttribute("value", "abcdefghijklmno");
-    input.style.position = 'absolute';
-    input.style.top  = "20px";
-    input.style.left = "30px";
-    input.focus();
-    input.selectionStart = 5;
-  });
-
-  afterAll(function () {
-    document.getElementsByTagName("body")[0].removeChild(input);
-    document.getElementsByTagName("body")[0].removeChild(
-      document.getElementById("searchMirror")
-    );
-  });
-
-  it('should be initializable', function () {
-    // Supports: context, searchField
-    var inputField = KorAP.InputField.create(input);
-    expect(inputField._element).not.toBe(undefined);
-  });
-
-  it('should have text', function () {
-    var inputField = KorAP.InputField.create(input);
-
-    expect(inputField.value).toEqual("abcdefghijklmno");
-    expect(inputField.element.selectionStart).toEqual(5);
-    expect(inputField.split()[0]).toEqual("abcde");
-    expect(inputField.split()[1]).toEqual("fghijklmno");
-
-    inputField.insert("xyz");
-    expect(inputField.split()[0]).toEqual("abcdexyz");
-    expect(inputField.split()[1]).toEqual("fghijklmno");
-
-  });
-
-  it('should be correctly positioned', function () {
-    var inputField = KorAP.InputField.create(input);
-    document.getElementsByTagName("body")[0].appendChild(input);
-    inputField.reposition();
-    expect(inputField.mirror.style.left).toEqual("30px");
-    expect(inputField.mirror.style.top.match(/^(\d+)px$/)[1]).toBeGreaterThan(20);
-  });
-});
-*/
diff --git a/public/js/spec/vcSpec.js b/public/js/spec/vcSpec.js
index 49e9275..1a24fb6 100644
--- a/public/js/spec/vcSpec.js
+++ b/public/js/spec/vcSpec.js
@@ -35,37 +35,37 @@
 };
 
 var demoFactory = buildFactory(KorAP.VirtualCollection, {
-  "@type":"korap:docGroup",
+  "@type":"koral:docGroup",
   "operation":"operation:or",
   "operands":[
     {
-      "@type":"korap:docGroup",
+      "@type":"koral:docGroup",
       "operation":"operation:and",
       "operands":[
         {
-          "@type":"korap:doc",
+          "@type":"koral:doc",
           "key":"Titel",
           "value":"Baum",
           "match":"match:eq"
         },
         {
-          "@type":"korap:doc",
+          "@type":"koral:doc",
           "key":"Veröffentlichungsort",
           "value":"hihi",
           "match":"match:eq"
         },
         {
-          "@type":"korap:docGroup",
+          "@type":"koral:docGroup",
           "operation":"operation:or",
           "operands":[
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Titel",
               "value":"Baum",
               "match":"match:eq"
             },
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Veröffentlichungsort",
               "value":"hihi",
               "match":"match:eq"
@@ -75,7 +75,7 @@
       ]
     },
     {
-      "@type":"korap:doc",
+      "@type":"koral:doc",
       "key":"Untertitel",
       "value":"huhu",
       "match":"match:eq"
@@ -90,7 +90,7 @@
   var stringFactory = buildFactory(KorAP.Doc, {
     "key"   : "author",
     "value" : "Max Birkendale",
-    "@type" : "korap:doc"
+    "@type" : "koral:doc"
   });
 
   // Create example factories
@@ -99,7 +99,7 @@
     "type"  : "type:date",
     "match" : "match:eq",
     "value" : "2014-11-05",
-    "@type" : "korap:doc"
+    "@type" : "koral:doc"
   });
 
   // Create example factories
@@ -107,7 +107,7 @@
     "key"   : "title",
     "type"  : "type:regex",
     "value" : "[^b]ee.+?",
-    "@type" : "korap:doc"
+    "@type" : "koral:doc"
   });
 
   it('should be initializable', function () {
@@ -251,7 +251,7 @@
     // Serialize string
     doc = stringFactory.create();
     expect(doc.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "type" : "type:string",
       "key" : "author",
       "value" : "Max Birkendale",
@@ -261,7 +261,7 @@
     // Serialize regex
     doc = regexFactory.create();
     expect(doc.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "type" : "type:regex",
       "value" : "[^b]ee.+?",
       "match" : "match:eq",
@@ -272,7 +272,7 @@
       match: "match:ne"
     });
     expect(doc.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "type" : "type:regex",
       "value" : "[^b]ee.+?",
       "match" : "match:ne",
@@ -281,7 +281,7 @@
 
     doc = dateFactory.create();
     expect(doc.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "type" : "type:date",
       "value" : "2014-11-05",
       "match" : "match:eq",
@@ -292,7 +292,7 @@
       value : "2014"
     });
     expect(doc.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "type" : "type:date",
       "value" : "2014",
       "match" : "match:eq",
@@ -339,7 +339,7 @@
   var docFactory = buildFactory(
     KorAP.Doc,
     {
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "match":"match:eq",
       "key" : "author",
       "value" : "Max Birkendale"
@@ -348,7 +348,7 @@
 
   var docGroupFactory = buildFactory(
     KorAP.DocGroup, {
-      "@type" : "korap:docGroup",
+      "@type" : "koral:docGroup",
       "operation" : "operation:and",
       "operands" : [
 	docFactory.create().toJson(),
@@ -455,18 +455,18 @@
     var docGroup = docGroupFactory.create();
 
     expect(docGroup.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:docGroup",
+      "@type" : "koral:docGroup",
       "operation" : "operation:and",
       "operands" : [
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key" : 'author',
 	  "match": 'match:eq',
 	  "value": 'Max Birkendale',
 	  "type": 'type:string'
 	},
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key": 'pubDate',
 	  "match": 'match:eq',
 	  "value": '2014-12-05',
@@ -481,36 +481,36 @@
     expect(docGroup.toQuery()).toEqual('author = "Max Birkendale" & pubDate in 2014-12-05');
 
     docGroup = docGroupFactory.create({
-      "@type" : "korap:docGroup",
+      "@type" : "koral:docGroup",
       "operation" : "operation:or",
       "operands" : [
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key" : 'author',
 	  "match": 'match:eq',
 	  "value": 'Max Birkendale',
 	  "type": 'type:string'
 	},
 	{
-	  "@type" : "korap:docGroup",
+	  "@type" : "koral:docGroup",
 	  "operation" : "operation:and",
 	  "operands" : [
 	    {
-	      "@type": 'korap:doc',
+	      "@type": 'koral:doc',
 	      "key": 'pubDate',
 	      "match": 'match:geq',
 	      "value": '2014-05-12',
 	      "type": 'type:date'
 	    },
 	    {
-	      "@type": 'korap:doc',
+	      "@type": 'koral:doc',
 	      "key": 'pubDate',
 	      "match": 'match:leq',
 	      "value": '2014-12-05',
 	      "type": 'type:date'
 	    },
 	    {
-	      "@type": 'korap:doc',
+	      "@type": 'koral:doc',
 	      "key": 'foo',
 	      "match": 'match:ne',
 	      "value": '[a]?bar',
@@ -545,7 +545,7 @@
     expect(docGroup.operation()).toEqual('or');
 
     docGroup.append({
-      "@type": 'korap:doc',
+      "@type": 'koral:doc',
       "key": 'pubDate',
       "match": 'match:eq',
       "value": '2014-12-05',
@@ -577,7 +577,7 @@
     expect(docGroup.operation()).toEqual('or');
 
     docGroup.append({
-      "@type": 'korap:doc',
+      "@type": 'koral:doc',
       "key": 'pubDate',
       "match": 'match:eq',
       "value": '2014-12-05',
@@ -643,7 +643,7 @@
 describe('KorAP.Doc element', function () {
   it('should be initializable', function () {
     var docElement = KorAP.Doc.create(undefined, {
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "key":"Titel",
       "value":"Baum",
       "match":"match:eq"
@@ -660,7 +660,7 @@
     expect(docE.children[2].getAttribute('data-type')).toEqual('string');
 
     expect(docElement.toJson()).toEqual(jasmine.objectContaining({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "key":"Titel",
       "value":"Baum",
       "match":"match:eq"
@@ -672,18 +672,18 @@
   it('should be initializable', function () {
 
     var docGroup = KorAP.DocGroup.create(undefined, {
-      "@type" : "korap:docGroup",
+      "@type" : "koral:docGroup",
       "operation" : "operation:and",
       "operands" : [
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key" : 'author',
 	  "match": 'match:eq',
 	  "value": 'Max Birkendale',
 	  "type": 'type:string'
 	},
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key": 'pubDate',
 	  "match": 'match:eq',
 	  "value": '2014-12-05',
@@ -721,29 +721,29 @@
 
   it('should be deserializable with nested groups', function () {
     var docGroup = KorAP.DocGroup.create(undefined, {
-      "@type" : "korap:docGroup",
+      "@type" : "koral:docGroup",
       "operation" : "operation:or",
       "operands" : [
 	{
-	  "@type": 'korap:doc',
+	  "@type": 'koral:doc',
 	  "key" : 'author',
 	  "match": 'match:eq',
 	  "value": 'Max Birkendale',
 	  "type": 'type:string'
 	},
 	{
-	  "@type" : "korap:docGroup",
+	  "@type" : "koral:docGroup",
 	  "operation" : "operation:and",
 	  "operands" : [
 	    {
-	      "@type": 'korap:doc',
+	      "@type": 'koral:doc',
 	      "key": 'pubDate',
 	      "match": 'match:geq',
 	      "value": '2014-05-12',
 	      "type": 'type:date'
 	    },
 	    {
-	      "@type": 'korap:doc',
+	      "@type": 'koral:doc',
 	      "key": 'pubDate',
 	      "match": 'match:leq',
 	      "value": '2014-12-05',
@@ -787,18 +787,18 @@
 describe('KorAP.VirtualCollection', function () {
 
   var simpleGroupFactory = buildFactory(KorAP.DocGroup, {
-    "@type" : "korap:docGroup",
+    "@type" : "koral:docGroup",
     "operation" : "operation:and",
     "operands" : [
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key" : 'author',
 	"match": 'match:eq',
 	"value": 'Max Birkendale',
 	"type": 'type:string'
       },
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:eq',
 	"value": '2014-12-05',
@@ -808,29 +808,29 @@
   });
 
   var nestedGroupFactory = buildFactory(KorAP.VirtualCollection, {
-    "@type" : "korap:docGroup",
+    "@type" : "koral:docGroup",
     "operation" : "operation:or",
     "operands" : [
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key" : 'author',
 	"match": 'match:eq',
 	"value": 'Max Birkendale',
 	"type": 'type:string'
       },
       {
-	"@type" : "korap:docGroup",
+	"@type" : "koral:docGroup",
 	"operation" : "operation:and",
 	"operands" : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:geq',
 	    "value": '2014-05-12',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:leq',
 	    "value": '2014-12-05',
@@ -842,25 +842,25 @@
   });
 
   var flatGroupFactory = buildFactory(KorAP.VirtualCollection, {
-    "@type" : "korap:docGroup",
+    "@type" : "koral:docGroup",
     "operation" : "operation:and",
     "operands" : [
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:geq',
 	"value": '2014-05-12',
 	"type": 'type:date'
       },
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:leq',
 	"value": '2014-12-05',
 	"type": 'type:date'
       },
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'foo',
 	"match": 'match:eq',
 	"value": 'bar',
@@ -880,7 +880,7 @@
 
   it('should be based on a doc', function () {
     var vc = KorAP.VirtualCollection.render({
-      "@type" : "korap:doc",
+      "@type" : "koral:doc",
       "key":"Titel",
       "value":"Baum",
       "match":"match:eq"
@@ -1115,37 +1115,37 @@
 
   it('should flatten on import', function () {
     var vc = KorAP.VirtualCollection.create().render({
-      "@type":"korap:docGroup",
+      "@type":"koral:docGroup",
       "operation":"operation:or",
       "operands":[
 	{
-	  "@type":"korap:docGroup",
+	  "@type":"koral:docGroup",
 	  "operation":"operation:or",
 	  "operands":[
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Titel",
               "value":"Baum",
               "match":"match:eq"
             },
             {
-              "@type":"korap:doc",
+              "@type":"koral:doc",
               "key":"Veröffentlichungsort",
               "value":"hihi",
               "match":"match:eq"
             },
             {
-              "@type":"korap:docGroup",
+              "@type":"koral:docGroup",
               "operation":"operation:or",
               "operands":[
 		{
-		  "@type":"korap:doc",
+		  "@type":"koral:doc",
 		  "key":"Titel",
 		  "value":"Baum",
 		  "match":"match:eq"
 		},
 		{
-		  "@type":"korap:doc",
+		  "@type":"koral:doc",
 		  "key":"Veröffentlichungsort",
 		  "value":"hihi",
 		  "match":"match:eq"
@@ -1155,7 +1155,7 @@
 	  ]
 	},
 	{
-	  "@type":"korap:doc",
+	  "@type":"koral:doc",
 	  "key":"Untertitel",
 	  "value":"huhu",
 	  "match":"match:eq"
@@ -1211,27 +1211,27 @@
 
 describe('KorAP._delete (event)', function () {
   var complexVCFactory = buildFactory(KorAP.VirtualCollection,{
-    "@type": 'korap:docGroup',
+    "@type": 'koral:docGroup',
     'operation' : 'operation:and',
     'operands' : [
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:eq',
 	"value": '2014-12-05',
 	"type": 'type:date'
       },
       {
-	"@type" : 'korap:docGroup',
+	"@type" : 'koral:docGroup',
 	'operation' : 'operation:or',
 	'operands' : [
 	  {
-	    '@type' : 'korap:doc',
+	    '@type' : 'koral:doc',
 	    'key' : 'title',
 	    'value' : 'Hello World!'
 	  },
 	  {
-	    '@type' : 'korap:doc',
+	    '@type' : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1242,7 +1242,7 @@
 
   it('should clean on root docs', function () {
     var vc = KorAP.VirtualCollection.render({
-      "@type": 'korap:doc',
+      "@type": 'koral:doc',
       "key": 'pubDate',
       "match": 'match:eq',
       "value": '2014-12-05',
@@ -1261,18 +1261,18 @@
   it ('should remove on nested docs', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:and',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1291,18 +1291,18 @@
   it ('should clean on doc groups', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:and',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1364,43 +1364,43 @@
   it ('should remove on nested doc groups (list flattening)', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:or',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  },
 	  {
-	    "@type": 'korap:docGroup',
+	    "@type": 'koral:docGroup',
 	    'operation' : 'operation:and',
 	    'operands' : [
 	      {
-		"@type": 'korap:doc',
+		"@type": 'koral:doc',
 		"key": 'pubDate',
 		"match": 'match:eq',
 		"value": '2014-12-05',
 		"type": 'type:date'
 	      },
 	      {
-		"@type" : 'korap:docGroup',
+		"@type" : 'koral:docGroup',
 		'operation' : 'operation:or',
 		'operands' : [
 		  {
-		    '@type' : 'korap:doc',
+		    '@type' : 'koral:doc',
 		    'key' : 'title',
 		    'value' : 'Hello World!'
 		  },
 		  {
-		    '@type' : 'korap:doc',
+		    '@type' : 'koral:doc',
 		    'key' : 'yeah',
 		    'value' : 'juhu'
 		  }
@@ -1443,27 +1443,27 @@
 
 describe('KorAP._add (event)', function () {
   var complexVCFactory = buildFactory(KorAP.VirtualCollection,{
-    "@type": 'korap:docGroup',
+    "@type": 'koral:docGroup',
     'operation' : 'operation:and',
     'operands' : [
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:eq',
 	"value": '2014-12-05',
 	"type": 'type:date'
       },
       {
-	"@type" : 'korap:docGroup',
+	"@type" : 'koral:docGroup',
 	'operation' : 'operation:or',
 	'operands' : [
 	  {
-	    '@type' : 'korap:doc',
+	    '@type' : 'koral:doc',
 	    'key' : 'title',
 	    'value' : 'Hello World!'
 	  },
 	  {
-	    '@type' : 'korap:doc',
+	    '@type' : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1475,18 +1475,18 @@
   it ('should add new unspecified doc with "and"', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:and',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1520,18 +1520,18 @@
   it ('should add new unspecified doc with "or"', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:and',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1710,18 +1710,18 @@
   it ('should wrap on root', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:and',
 	'operands' : [
 	  {
-	    "@type": 'korap:doc',
+	    "@type": 'koral:doc',
 	    "key": 'pubDate',
 	    "match": 'match:eq',
 	    "value": '2014-12-05',
 	    "type": 'type:date'
 	  },
 	  {
-	    "@type" : 'korap:doc',
+	    "@type" : 'koral:doc',
 	    'key' : 'foo',
 	    'value' : 'bar'
 	  }
@@ -1744,7 +1744,7 @@
   it ('should add on root (case "and")', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:eq',
 	"value": '2014-12-05',
@@ -1766,7 +1766,7 @@
   it ('should add on root (case "or")', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:doc',
+	"@type": 'koral:doc',
 	"key": 'pubDate',
 	"match": 'match:eq',
 	"value": '2014-12-05',
@@ -1787,36 +1787,36 @@
   it ('should support multiple sub groups per group', function () {
     var vc = KorAP.VirtualCollection.render(
       {
-	"@type": 'korap:docGroup',
+	"@type": 'koral:docGroup',
 	'operation' : 'operation:or',
 	'operands' : [
 	  {
-	    "@type": 'korap:docGroup',
+	    "@type": 'koral:docGroup',
 	    'operation' : 'operation:and',
 	    'operands' : [
 	      {
-		"@type": 'korap:doc',
+		"@type": 'koral:doc',
 		"key": 'title',
 		"value": 't1',
 	      },
 	      {
-		"@type" : 'korap:doc',
+		"@type" : 'koral:doc',
 		'key' : 'title',
 		'value' : 't2'
 	      }
 	    ]
 	  },
 	  {
-	    "@type": 'korap:docGroup',
+	    "@type": 'koral:docGroup',
 	    'operation' : 'operation:and',
 	    'operands' : [
 	      {
-		"@type": 'korap:doc',
+		"@type": 'koral:doc',
 		"key": 'title',
 		"value": 't3',
 	      },
 	      {
-		"@type" : 'korap:doc',
+		"@type" : 'koral:doc',
 		'key' : 'title',
 		'value' : 't4'
 	      }
@@ -1844,7 +1844,7 @@
 
   it('should be initializable', function () {
     var rewrite = KorAP.Rewrite.create({
-      "@type" : "korap:rewrite",
+      "@type" : "koral:rewrite",
       "operation" : "operation:modification",
       "src" : "querySerializer",
       "scope" : "tree"
@@ -1855,7 +1855,7 @@
   it('should be deserialized by docs', function () {
     var doc = KorAP.Doc.create(undefined,
       {
-        "@type":"korap:doc",
+        "@type":"koral:doc",
         "key":"Titel",
         "value":"Baum",
         "match":"match:eq"
@@ -1866,13 +1866,13 @@
 
     doc = KorAP.Doc.create(undefined,
       {
-        "@type":"korap:doc",
+        "@type":"koral:doc",
         "key":"Titel",
         "value":"Baum",
         "match":"match:eq",
 	"rewrites" : [
 	  {
-	    "@type" : "korap:rewrite",
+	    "@type" : "koral:rewrite",
 	    "operation" : "operation:modification",
 	    "src" : "querySerializer",
 	    "scope" : "tree"
@@ -1888,3 +1888,11 @@
   });
 */
 });
+/*
+describe('KorAP.DocKey', function () {
+  it('should be initializable', function () {
+    var docKey = KorAP.DocKey.create();
+    expect(docKey.toString()).toEqual('...');
+  });
+});
+*/
diff --git a/public/js/src/menu.js b/public/js/src/menu.js
index b251000..f0dd15d 100644
--- a/public/js/src/menu.js
+++ b/public/js/src/menu.js
@@ -1,5 +1,11 @@
 var KorAP = KorAP || {};
 
+/**
+ * Create scrollable drop-down menus.
+ *
+ * @author Nils Diewald
+ */
+
 (function (KorAP) {
   "use strict";
 
@@ -25,39 +31,63 @@
       return Object.create(KorAP.Menu)._init(params);
     },
 
+    focus : function () {
+      this._element.focus();
+    },
+
+    // Initialize list
     _init : function (itemClass, params) {
       // this._element.addEventListener("click", chooseHint, false);
       this._itemClass = itemClass;
       this._element = document.createElement("ul");
       this._element.style.opacity = 0;
 
+/*
+      this._listener = document.createElement('input');
+      this._listener.setAttribute('type', 'text');
+//      this._listener.style.display = "none";
+*/
+      this._element.addEventListener(
+	"keydown",
+	function (e) {
+          console.log('+++');
+	},
+	false
+      );
+
       this.active = false;
       this._items = new Array();
       var i;
+
+      // Initialize item list based on parameters
       for (i in params) {
 	var obj = itemClass.create(params[i]);
-	this._items.push(
-	  obj
-	);
+	this._items.push(obj);
       };
       this._limit    = KorAP.menuLimit;
       this._position = 0;  // position in the active list
       this._active   = -1; // active item in the item list
-
       this._reset();
       return this;
     },
 
+    /**
+     * Get the instantiated HTML element
+     */
     element : function () {
       return this._element;
     },
 
+    /**
+     * Get the creator object for items
+     */
     itemClass : function () {
       return this._itemClass;
     },
 
     /**
-     * Get and set numerical value for limit
+     * Get and set numerical value for limit,
+     * i.e. the number of items visible.
      */
     limit : function (limit) {
       if (arguments.length === 1)
@@ -69,7 +99,7 @@
      * Upgrade this object to another object,
      * while private data stays intact.
      *
-     * @param {Object] An object with properties.
+     * @param {Object} An object with properties.
      */
     upgradeTo : function (props) {
       for (var prop in props) {
@@ -78,6 +108,7 @@
       return this;
     },
 
+    // Reset chosen item and prefix
     _reset : function () {
       this._offset = 0;
       this._pos    = 0;
@@ -96,30 +127,30 @@
       if (!this._initList())
 	return;
 
-      // show based on offset
+      // show based on initial offset
       this._showItems(0);
 
       // Set the first element to active
+      // Todo: Or the last element chosen
       this.liveItem(0).active(true);
 
       this._position = 0;
       this._active = this._list[0];
 
+      this._element.style.opacity = 1;
+
       // Add classes for rolling menus
       this._boundary(true);
     },
 
-    /**
-     * Get a specific item from the complete list
-     *
-     * @param {number} index of the list item
-     */
-    item : function (index) {
-      return this._items[index]
+    hide : function () {
+      this._element.style.opacity = 0;
     },
 
+    // Initialize the list
     _initList : function () {
 
+      // Create a new list
       if (this._list === undefined) {
 	this._list = [];
       }
@@ -131,20 +162,27 @@
       // Offset is initially zero
       this._offset = 0;
 
+      // There is no prefix set
       if (this.prefix().length <= 0) {
 	for (var i = 0; i < this._items.length; i++)
 	  this._list.push(i);
 	return true;
       };
 
+      // There is a prefix set, so filter the list
       var pos;
       var paddedPrefix = " " + this.prefix();
 
+      // 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(paddedPrefix)) >= 0)
 	  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
       if (this._list.length == 0) {
 	for (pos = 0; pos < this._items.length; pos++) {
 	  if ((this.item(pos).lcField().indexOf(this.prefix())) >= 0)
@@ -152,7 +190,7 @@
 	};
       };
 
-      // Filter was successful
+      // Filter was successful - yeah!
       return this._list.length > 0 ? true : false;
     },
 
@@ -164,12 +202,13 @@
 
     /**
      * Get the prefix for filtering,
-     * e.g. &quot;ve"&quot; for &quot;verb&quot;
+     * e.g. &quot;ve&quot; for &quot;verb&quot;
      */
     prefix : function () {
       return this._prefix || '';
     },
 
+    // Append Items that should be shown
     _showItems : function (offset) {
       this.delete();
 
@@ -194,12 +233,16 @@
      */
     delete : function () {
       var child;
+
+      // Iterate over all visible items
       for (var i = 0; i <= this.limit(); i++) {
 
+	// there is a visible element - unhighlight!
 	if (child = this.shownItem(i))
 	  child.lowlight();
       };
 
+      // Remove all children
       while (child = this._element.firstChild)
 	this._element.removeChild(child);
     },
@@ -218,10 +261,38 @@
     },
 
 
+    // Prepend item to the shown list based on index
+    _prepend : function (i) {
+      var item = this.item(i);
+
+      // Highlight based on prefix
+      if (this.prefix().length > 0)
+	item.highlight(this.prefix());
+
+      var e = this.element();
+      // Append element
+      e.insertBefore(
+	item.element(),
+	e.firstChild
+      );
+    },
+
+
+    /**
+     * Get a specific item from the complete list
+     *
+     * @param {number} index of the list item
+     */
+    item : function (index) {
+      return this._items[index]
+    },
+
+
     /**
      * Get a specific item from the filtered list
      *
      * @param {number} index of the list item
+     *        in the filtered list
      */
     liveItem : function (index) {
       if (this._list === undefined)
@@ -231,15 +302,12 @@
       return this._items[this._list[index]];
     },
 
-    length : function () {
-      return this._items.length;
-    },
-
 
     /**
      * Get a specific item from the visible list
      *
      * @param {number} index of the list item
+     *        in the visible list
      */
     shownItem : function (index) {
       if (index >= this.limit())
@@ -248,8 +316,16 @@
     },
 
 
-    /*
-     * Make the next item in the menu active
+    /**
+     * Get the length of the full list
+     */
+    length : function () {
+      return this._items.length;
+    },
+
+
+    /**
+     * Make the next item in the filtered menu active
      */
     next : function () {
       // No active element set
@@ -270,7 +346,7 @@
       }
 
       // The next element is outside the view - roll down
-      else if (this._position >= (this.limit + this._offset)) {
+      else if (this._position >= (this.limit() + this._offset)) {
 	this._removeFirst();
 	this._offset++;
 	this._append(this._list[this._position]);
@@ -282,8 +358,8 @@
     /*
      * Make the previous item in the menu active
      */
-/*
     prev : function () {
+      // No active element set
       if (this._position == -1)
 	return;
 
@@ -294,9 +370,9 @@
 
       // The previous element is undefined - roll to bottom
       if (newItem === undefined) {
-	this._position = this.liveLength - 1;
+	this._offset = this.liveLength() - this.limit();
+	this._position = this.liveLength() - 1;
 	newItem = this.liveItem(this._position);
-	this._offset = this.liveLength - this.limit;
 	this._showItems(this._offset);
       }
 
@@ -306,85 +382,33 @@
 	this._offset--;
 	this._prepend(this._list[this._position]);
       };
+
       newItem.active(true);
     },
-*/
 
 
-    /**
-     * Get the context of the menue,
-     * e.g. &quot;tt/&quot; for the tree tagger menu
-     */
-/*
-    get context () {
-      return this._context;
-    },
-*/
-/*
-    get liveLength () {
-      if (this._list === undefined)
-	this._initList();
-      return this._list.length;
-    },
-*/
-/*
-    chooseHint : function (e) {
-      var element = e.target;
-      while (element.nodeName == "STRONG" || element.nodeName == "SPAN")
-	element = element.parentNode;
-
-      if (element === undefined || element.nodeName != "LI")
-	return;
-
-      var action = element.getAttribute('data-action');
-      hint.insertText(action);
-      var menu = hint.menu();
-      menu.hide();
-
-      // Fill this with the correct value
-      var show;
-      if ((show = hint.analyzeContext()) != "-") {
-	menu.show(show);
-	menu.update(
-	  hint._search.getBoundingClientRect().right
-	);
-      };
-
-      hint._search.focus();
-    },
-
+    // Remove the HTML node from the first item
     _removeFirst : function () {
       this.item(this._list[this._offset]).lowlight();
       this._element.removeChild(this._element.firstChild);
     },
 
+
+    // Remove the HTML node from the last item
     _removeLast : function () {
-      this.item(this._list[this._offset + this.limit - 1]).lowlight();
+      this.item(this._list[this._offset + this.limit() - 1]).lowlight();
       this._element.removeChild(this._element.lastChild);
     },
 
-
-    // Prepend item to the shown list based on index
-    _prepend : function (i) {
-      var item = this.item(i);
-
-      // Highlight based on prefix
-      if (this.prefix.length > 0)
-	item.highlight(this.prefix);
-
-      // Append element
-      this.element.insertBefore(
-	item.element,
-	this.element.firstChild
-      );
-    },
-*/
-
+    // Length of the filtered list
+    liveLength : function () {
+      if (this._list === undefined)
+	this._initList();
+      return this._list.length;
+    }
   };
 
 
-
-
   /**
    * Item in the Dropdown menu
    */
@@ -585,4 +609,10 @@
     },
   };
 
+/*
+  KorAP._updateKey : function (e) {
+    var code = this._codeFromEvent(e)    
+  };
+*/
+
 }(this.KorAP));
diff --git a/public/js/src/vc.js b/public/js/src/vc.js
index d226fc4..00528aa 100644
--- a/public/js/src/vc.js
+++ b/public/js/src/vc.js
@@ -3,9 +3,13 @@
  *
  * @author Nils Diewald
  */
-
+/*
+ * Replaces a previous version written by Mengfei Zhou
+ */
 var KorAP = KorAP || {};
 
+// Requires menu.js
+
 /*
   TODO: Implement a working localization solution!
   TODO: Disable "and" or "or" in case it's followed
@@ -50,7 +54,6 @@
   loc.DEL   = loc.DEL   || '×';
   loc.EMPTY = loc.EMPTY || '⋯'
 
-
   // Utility for analysing boolean values
   function _bool (bool) {
     return (bool === undefined || bool === null || bool === false) ? false : true;
@@ -148,10 +151,10 @@
 
       if (json !== undefined) {
 	// Root object
-	if (json['@type'] == 'korap:doc') {
+	if (json['@type'] == 'koral:doc') {
 	  obj._root = KorAP.Doc.create(obj, json);
 	}
-	else if (json['@type'] == 'korap:docGroup') {
+	else if (json['@type'] == 'koral:docGroup') {
 	  obj._root = KorAP.DocGroup.create(obj, json);
 	}
 	else {
@@ -343,7 +346,7 @@
 
       // Set JSON-LD type
       var newDoc = KorAP.Doc.create(this._parent, {
-	"@type" : "korap:doc",
+	"@type" : "koral:doc",
 	"value" : "",
 	"key"   : v
       });
@@ -374,6 +377,9 @@
       ellipsis.appendChild(document.createTextNode(loc.EMPTY));
       this._element.appendChild(ellipsis);
 
+      // Set ref - TODO: Cleanup!
+      this._element.refTo = this;
+
       // Set operators
       if (this._parent !== undefined && this.parent().ldType() !== null) {
 	var op = this.operators(
@@ -430,6 +436,9 @@
       // Get element
       var e = this._element;
 
+      // Set ref - TODO: Cleanup!
+      e.refTo = this;
+
       // Check if there is a change
       if (this.__changed) {
 
@@ -441,6 +450,10 @@
 	// Added key
 	var key = document.createElement('span');
 	key.setAttribute('class', 'key');
+
+	// Change key
+	key.addEventListener('click', KorAP._changeKey, false);
+
 	if (this.key())
 	  key.appendChild(document.createTextNode(this.key()));
 
@@ -676,7 +689,7 @@
 	return {};
       
       return {
-	"@type" : "korap:" + this.ldType(),
+	"@type" : "koral:" + this.ldType(),
 	"key"   : this.key(),
 	"match" : "match:" + this.matchop(),
 	"value" : this.value() || '',
@@ -810,7 +823,7 @@
 	KorAP.log(701, "JSON-LD group has no @type attribute");
 	return;
 
-      case "korap:doc":
+      case "koral:doc":
 	// Be aware of cyclic structures!
 	var doc = KorAP.Doc.create(this, operand);
 	if (doc === undefined)
@@ -822,7 +835,7 @@
 	};
 	return dupl;
 
-      case "korap:docGroup":
+      case "koral:docGroup":
 	// Be aware of cyclic structures!
 	var docGroup = KorAP.DocGroup.create(this, operand);
 	if (docGroup === undefined)
@@ -1039,7 +1052,7 @@
 	  opArray.push(this._operands[i].toJson());
       };
       return {
-	"@type"     : "korap:" + this.ldType(),
+	"@type"     : "koral:" + this.ldType(),
 	"operation" : "operation:" + this.operation(),
 	"operands"  : opArray
       };
@@ -1301,7 +1314,7 @@
     toJson : function () {
       return {
 	// Unspecified object
-	"@type" : "korap:" + this.ldType()
+	"@type" : "koral:" + this.ldType()
       };
     },
 
@@ -1309,5 +1322,65 @@
       return '';
     }
   };
+
+
+  /**
+   * Criterion in a KorAP.Doc
+   */
+  KorAP._changeKey = function () {
+    var doc = this.parentNode.refTo;
+    console.log(doc.type());
+    // key, matchop, type, value
+  };
+  
+
+  // Field menu
+  KorAP.FieldMenu = {
+    create : function (params) {
+      return Object.create(KorAP.Menu)
+	.upgradeTo(KorAP.FieldMenu)
+	._init(KorAP.FieldMenuItem, params)
+    }
+  };
+
+
+  // Field menu item
+  KorAP.FieldMenuItem = {
+    create : function (params) {
+      return Object.create(KorAP.MenuItem)
+	.upgradeTo(KorAP.FieldMenuItem)
+	._init(params);
+    },
+    _init : function (params) {
+      if (params[0] === undefined)
+	throw new Error("Missing parameters");
+
+      this._name  = params[0];
+      this._value = params[1];
+      this._type  = params[2];
+
+      this._lcField = ' ' + this._name.toLowerCase();
+
+      return this;
+    },
+    name : function () {
+      return this._name;
+    },
+    type : function () {
+      return this._type;
+    },
+    element : function () {
+      // already defined
+      if (this._element !== undefined)
+	return this._element;
+
+      // Create list item
+      var li = document.createElement("li");
+      li.setAttribute("data-type", this._type);
+      li.setAttribute("data-value", this._value);
+      li.appendChild(document.createTextNode(this._name));
+      return this._element = li;
+    }
+  };
  
 }(this.KorAP));
