diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index ce8f48f..f30498e 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -105,7 +105,7 @@
     ]
   });
 
-  describe('KorAP.Doc', function () {
+  describe('KorAP.VC.Doc', function () {
     // Create example factories
     var stringFactory = buildFactory(docClass, {
       "key"   : "author",
@@ -385,7 +385,7 @@
   });
 
 
-  describe('KorAP.DocGroup', function () {
+  describe('KorAP.VC.DocGroup', function () {
     // Create example factories
     var docFactory = buildFactory(
       docClass,
@@ -595,7 +595,7 @@
     });
   });
 
-  describe('KorAP.DocGroupRef', function () {
+  describe('KorAP.VC.DocGroupRef', function () {
     // Create example factories
     var docRefFactory = buildFactory(
       docGroupRefClass,
@@ -657,7 +657,7 @@
   });
 
   
-  describe('KorAP.UnspecifiedDoc', function () {
+  describe('KorAP.VC.UnspecifiedDoc', function () {
     it('should be initializable', function () {
       var doc = unspecifiedClass.create();
       var docElement = doc.element();
@@ -803,7 +803,7 @@
     });    
   });
 
-  describe('KorAP.Doc element', function () {
+  describe('KorAP.VC.Doc element', function () {
     it('should be initializable', function () {
       var docElement = docClass.create(undefined, {
         "@type" : "koral:doc",
@@ -973,7 +973,7 @@
     });
   });
 
-  describe('KorAP.DocGroup element', function () {
+  describe('KorAP.VC.DocGroup element', function () {
     it('should be initializable', function () {
 
       var docGroup = docGroupClass.create(undefined, {
@@ -1087,7 +1087,7 @@
     });
   });
 
-  describe('KorAP.DocGroupRef element', function () {
+  describe('KorAP.VC.DocGroupRef element', function () {
     it('should be initializable', function () {
       var docGroupRef = docGroupRefClass.create(undefined, {
         "@type" : "koral:docGroupRef",
@@ -1130,7 +1130,7 @@
   });
 
   
-  describe('KorAP.VirtualCorpus', function () {
+  describe('KorAP.VC.VirtualCorpus', function () {
     var simpleGroupFactory = buildFactory(docGroupClass, {
       "@type" : "koral:docGroup",
       "operation" : "operation:and",
@@ -1908,7 +1908,7 @@
   });
 
 
-  describe('KorAP.Operators', function () {
+  describe('KorAP.VC.Operators', function () {
     it('should be initializable', function () {
       var op = operatorsClass.create(true, false, false);
       expect(op.and()).toBeTruthy();
@@ -1945,7 +1945,7 @@
     });
   });
 
-  describe('KorAP._delete (event)', function () {
+  describe('KorAP.VC._delete (event)', function () {
     var complexVCFactory = buildFactory(vcClass,{
       "@type": 'koral:docGroup',
       'operation' : 'operation:and',
@@ -2179,7 +2179,7 @@
     });
   });
 
-  describe('KorAP._add (event)', function () {
+  describe('KorAP.VC._add (event)', function () {
     var complexVCFactory = buildFactory(vcClass,{
       "@type": 'koral:docGroup',
       'operation' : 'operation:and',
@@ -2630,7 +2630,7 @@
   });
 
 
-  describe('KorAP.Rewrite', function () {
+  describe('KorAP.VC.Rewrite', function () {
     it('should be initializable', function () {
       var rewrite = rewriteClass.create({
         "@type" : "koral:rewrite",
@@ -2741,7 +2741,7 @@
     });
   });
 
-  describe('KorAP.stringValue', function () {
+  describe('KorAP.VC.stringValue', function () {
     it('should be initializable', function () {
       var sv = stringValClass.create();
       expect(sv.regex()).toBe(false);
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 764ed96..7bf0d34 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -43,6 +43,7 @@
    
    and various field names with the prefix 'VC_'
  */
+"use strict";
 
 define([
   'vc/unspecified',
@@ -69,7 +70,6 @@
   vcPanelClass,
   corpStatVClass,
   buttonGroupClass) {
-  "use strict";
 
   KorAP._validUnspecMatchRE = new RegExp(
     "^(?:eq|ne|contains(?:not)?|excludes)$");
@@ -114,6 +114,7 @@
     ])
   };
 
+
   /**
    * Virtual corpus
    */
@@ -126,12 +127,14 @@
       return null;
     },
 
+
     // Initialize virtual corpus
     _init : function(keyList) {
 
       // Inject localized css styles
       if (!KorAP._overrideStyles) {
-        var sheet = KorAP.newStyleSheet();
+
+        const sheet = KorAP.newStyleSheet();
 
         // Add css rule for OR operations
         sheet.insertRule('.vc .docGroup[data-operation=or] > .doc::before,'
@@ -147,7 +150,7 @@
         KorAP._overrideStyles = true;
       };
 
-      var l;
+      let l;
       if (keyList) {
         l = keyList.slice();
         l.unshift(['referTo', 'ref']);
@@ -163,11 +166,12 @@
       return this;
     },
 
+
     /**
      * Create a new virtual corpus
      */
-    create : function(keyList) {
-      var obj = Object.create(this)._init(keyList);
+    create : function (keyList) {
+      const obj = Object.create(this)._init(keyList);
       obj._root = unspecDocClass.create(obj);
       return obj;
     },
@@ -182,10 +186,12 @@
       let obj;
       
       if (json !== undefined) {
+
         // Parse root document
         if (json['@type'] == 'koral:doc') {
           obj = docClass.create(this, json);
         }
+
         // parse root group
         else if (json['@type'] == 'koral:docGroup') {
           obj = docGroupClass.create(this, json);
@@ -218,11 +224,7 @@
     // Check if the virtual corpus contains a rerite
     wasRewritten : function (obj) {
 
-      var obj;
-      if (arguments.length === 1) {
-        obj = arguments[0];
-      }
-      else {
+      if (arguments.length !== 1) {
         obj = this._root;
       };
 
@@ -239,7 +241,7 @@
           return true;
         };
       };
-
+      
       return false;
     },
 
@@ -248,22 +250,25 @@
      * Clean the virtual document to unspecified doc.
      */
     clean : function() {
-      if (this._root.ldType() !== "non") {
-        this._root.destroy();
-        this.root(unspecDocClass.create(this));
+      const t = this;
+      if (t._root.ldType() !== "non") {
+        t._root.destroy();
+        t.root(unspecDocClass.create(t));
       };
-      //update for graying corpus statistic by deleting the first line of the vc builder
-      this.update();
-      return this;
+
+      // update for graying corpus statistic by deleting the first line of the vc builder
+      t.update();
+      return t;
     },
 
+
     /**
      * Get or set the root object of the virtual corpus
      */
     root : function(obj) {
       if (arguments.length === 1) {
-        var e = this.builder();
-
+        const e = this.builder();
+        
         if (e.firstChild !== null) {
 
           // Object not yet set
@@ -283,6 +288,7 @@
 
         this.update();
       };
+
       return this._root;
     },
 
@@ -291,53 +297,57 @@
      * Get the wrapper element associated with the vc
      */
     builder : function () {
+      const t = this;
 
       // Initialize if necessary
-      if (this._builder !== undefined)
-        return this._builder;
+      if (t._builder !== undefined)
+        return t._builder;
 
-      this.element();
-      return this._builder;
+      t.element();
+      return t._builder;
     },
     
+
     /**
      * Get the element associated with the virtual corpus
      */
     element : function() {
-      if (this._element !== undefined) {
-        return this._element;
-      };
+      const t = this;
+      let e = t._element;
 
-      this._element = document.createElement('div');
-      this._element.classList.add('vc');
+      if (e !== undefined)
+        return e;
 
 
-      this._builder = this._element.addE('div');
-      this._builder.setAttribute('class', 'builder');
+      e = t._element = document.createElement('div');
+      e.classList.add('vc');
 
-      var btn = buttonGroupClass.create(
+
+      t._builder = e.addE('div');
+      t._builder.setAttribute('class', 'builder');
+
+      const btn = buttonGroupClass.create(
         ['action','button-view']
       );
-      var that = this;
-      btn.add(loc.MINIMIZE, {'cls':['button-icon','minimize']}, function () {
-        that.minimize();
-      });
-      this._element.appendChild(btn.element());
-      
-      
 
+      btn.add(loc.MINIMIZE, {'cls':['button-icon','minimize']}, function () {
+        this.minimize();
+      }.bind(t));
+
+      e.appendChild(btn.element());
+      
       // Initialize root
-      this._builder.appendChild(this._root.element());      
+      t._builder.appendChild(t._root.element());      
       
       // Add panel to display corpus statistic, ...
-      this.addVcInfPanel();
+      t.addVcInfPanel();
       
       //Adds EventListener for corpus changes
-      this._element.addEventListener('vcChange', function (e) {
-        that.checkStatActive(e.detail);
-      }, false);
+      t._element.addEventListener('vcChange', function (e) {
+        this.checkStatActive(e.detail);
+      }.bind(t), false);
       
-      return this._element;
+      return e;
     },
 
 
@@ -350,6 +360,7 @@
       return this._element.classList.contains('active');
     },
     
+
     /**
      * Open the VC view
      */
@@ -375,17 +386,21 @@
      */    
     update : function() {
       this._root.update();
-      if (KorAP.vc){
-        var vcchevent = new CustomEvent('vcChange', {'detail':this});
-        this.element().dispatchEvent(vcchevent);
+      if (KorAP.vc) {
+        this.element().dispatchEvent(
+          new CustomEvent('vcChange', {'detail':this})
+        );
       };
       return this;
     },
+
+
     /**
      * Make the vc persistant by injecting the current timestamp as a
      * creation date limit criterion.
      * THIS IS CURRENTLY NOT USED
      */
+    /*
     makePersistant : function() {
       // this.root().wrapOnRoot('and');
       var todayStr = KorAP._vcDatePicker.today();
@@ -404,13 +419,12 @@
       doc.matchop("leq");
       doc.value(todayStr);
 
-      /*
-       * { "@type" : "koral:doc", "key" : "creationDate", "type" :
-       * "type:date", "match" : "match:leq", "value" : todayStr }
-       * this.root().append(cond);
-       */
+      // { "@type" : "koral:doc", "key" : "creationDate", "type" :
+      // "type:date", "match" : "match:leq", "value" : todayStr }
+      // this.root().append(cond);
       this.update();
     },
+    */
 
 
     // Get the reference name
@@ -426,13 +440,13 @@
       }
     },
 
+
     // Add "and" constraint to VC
     addRequired : function (doc) {
+      const root = this.root();
+      const ldType = root.ldType();
+      const parent = root.parent();
 
-      let root = this.root();
-      let ldType = root.ldType();
-
-      let parent = root.parent();
       if (ldType === 'non') {
         parent.root(doc);
       }
@@ -444,7 +458,7 @@
           (ldType === 'docGroup' &&
            root.operation() === 'or'
           )) {
-        let group = require('vc/docgroup').create(
+        const group = require('vc/docgroup').create(
           parent
         );
         group.operation("and");
@@ -469,17 +483,19 @@
       this.update();
     },
     
+
     /**
      * Get the generated json string
      */
-    toJson : function() {
+    toJson : function () {
       return this._root.toJson();
     },
 
+
     /**
      * Get the generated query string
      */
-    toQuery : function() {
+    toQuery : function () {
       return this._root.toQuery();
     },
 
@@ -487,11 +503,10 @@
     /**
      * Add panel to display virtual corpus information
      */
-    addVcInfPanel : function() {
-      var dv = this._element.addE('div');
-      //Create panel  
+    addVcInfPanel : function () {
+      // Create panel  
       this.panel = vcPanelClass.create(this); 
-      dv.appendChild(this.panel.element());
+      this._element.addE('div').appendChild(this.panel.element());
       
     },
     
@@ -499,10 +514,10 @@
      * Checks if corpus statistic has to be disabled,
      * and to be updated after clicking at the "reload-button"
      */
-    checkStatActive : function(){
-      if(this.panel !== undefined && this.panel.statView !==undefined){
+    checkStatActive : function (){
+      if (this.panel !== undefined && this.panel.statView !== undefined){
         this.panel.statView.checkStatActive();
-      }
+      };
     }
   };
 });
diff --git a/dev/js/src/vc/chooseitem.js b/dev/js/src/vc/chooseitem.js
index 9f6fc06..039764c 100644
--- a/dev/js/src/vc/chooseitem.js
+++ b/dev/js/src/vc/chooseitem.js
@@ -1,6 +1,8 @@
+"use strict";
+
 define(['menu/item', 'util'], function (itemClass) {
 
-  var loc = KorAP.Locale;
+  const loc = KorAP.Locale;
 
   return {
 
@@ -17,21 +19,25 @@
 	      ._init(params);
     },
 
+
     // Initialize item object
     _init : function (params) {
+      const t = this;
+
       if (params[0] === undefined)
 	      throw new Error("Missing parameters");
       
-      this._id  = params[0];
-      this._name = params[1];
-      this._desc  = params[2];
+      t._id   = params[0];
+      t._name = params[1];
+      t._desc = params[2];
 
-      this._lcField =  ' ' + this._name.toLowerCase();
-      this._lcField += ' ' + this._desc.toLowerCase();
+      t._lcField =  ' ' + t._name.toLowerCase();
+      t._lcField += ' ' + t._desc.toLowerCase();
 
       return this;
     },
 
+
     /**
      * Override click event by passing all clicks
      * to the menu object.
@@ -44,6 +50,7 @@
       e.halt();
     },
 
+
     /**
      * Get the name of the item.
      */
@@ -51,6 +58,7 @@
       return this._name;
     },
 
+
     /**
      * Get the identifier of the item.
      */
@@ -58,6 +66,7 @@
       return this._id;
     },
 
+
     /**
      * Get the description of the item.
      */
@@ -65,25 +74,27 @@
       return this._desc;
     },
 
+
     /**
      * Get the HTML element associated with the item. 
      */
     element : function () {
+      const t = this;
 
       // already defined
-      if (this._element !== undefined)
-	      return this._element;
+      if (t._element !== undefined)
+	      return t._element;
 
       // Create list item
-      var li = document.createElement("li");
-      li.setAttribute("data-type", this._type);
-      li.setAttribute("data-key",  this._key);
+      const li = document.createElement("li");
+      li.setAttribute("data-type", t._type);
+      li.setAttribute("data-key",  t._key);
 
       // Connect action
-      li["onclick"] = this.onclick.bind(this);
+      li["onclick"] = t.onclick.bind(t);
 
-      li.addT(this._name);
-      return this._element = li;
+      li.addT(t._name);
+      return t._element = li;
     }
   }
 });
diff --git a/dev/js/src/vc/choosemenu.js b/dev/js/src/vc/choosemenu.js
index 90660b7..84adf00 100644
--- a/dev/js/src/vc/choosemenu.js
+++ b/dev/js/src/vc/choosemenu.js
@@ -2,6 +2,8 @@
  * Menu showing all predefined virtual corpora.
  * THIS IS EXPERIMENTAL AND MAY BE REMOVED!
  */
+"use strict";
+
 define(['vc/menu', 'api'], function (menuClass, itemClass) {
   return {
     create : function (params) {
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index 8ea8364..fd4c318 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -1,6 +1,7 @@
 /**
  * A new document criterion
  */
+"use strict";
 
 define([
   'vc/jsonld',
@@ -29,6 +30,7 @@
     // The object ... maybe not important
     _obj : function () { return '???'; /*KorAP.Doc*/ },
     
+
     /**
      * Create a new document criterion
      * by passing the parent object and a json construct.
@@ -36,10 +38,10 @@
     create : function (parent, json) {
 
       // Create the object, inheriting from Json-LD class
-      var obj = Object(jsonldClass).
-          create().
-          upgradeTo(this).
-          fromJson(json);
+      const obj = Object(jsonldClass).
+            create().
+            upgradeTo(this).
+            fromJson(json);
 
       if (obj === undefined) {
         console.log(json);
@@ -54,104 +56,106 @@
       return obj;
     },
 
+
     /**
      * Update the elements content.
      */
     update : function () {
-      if (this._element === undefined)
-        return this.element();
+      const t = this;
+
+      if (t._element === undefined)
+        return t.element();
       
       // Get element
-      var e = this._element;
+      const e = t._element;
 
       // Check if there is a change in the underlying data
-      if (!this.__changed)
+      if (!t.__changed)
         return e;
 
       // Set ref - TODO: Cleanup!
-      e.refTo = this;
+      e.refTo = t;
 
 
       // Was rewritten
-      if (this.rewrites() !== undefined) {
+      if (t.rewrites() !== undefined) {
         e.classList.add("rewritten");
       };
 
       // Added key
-      this._keyE = document.createElement('span');
-      this._keyE.setAttribute('class', 'key');
+      const keyE = t._keyE = document.createElement('span');
+      keyE.setAttribute('class', 'key');
 
       // Change key
-      this._keyE.addEventListener('click', this._changeKey.bind(this));
+      keyE.addEventListener('click', t._changeKey.bind(t));
 
-      if (this.key()) {
-        var k = this.key();
+      if (t.key()) {
+        const k = t.key();
         if (loc['VC_' + k] !== undefined)
           k = loc['VC_' + k];
-        this._keyE.addT(k);
+        keyE.addT(k);
       };
 
       // Added match operator
-      this._matchopE = document.createElement('span');
-      this._matchopE.setAttribute('data-type', this.type());
-      this._matchopE.setAttribute('class', 'match');
-      this._matchopE.addT(this.matchop());
+      const matchopE = t._matchopE = document.createElement('span');
+      matchopE.setAttribute('data-type', t.type());
+      matchopE.setAttribute('class', 'match');
+      matchopE.addT(t.matchop());
 
       // Change matchop
-      this._matchopE.addEventListener(
+      t._matchopE.addEventListener(
         'click',
-        this._changeMatchop.bind(this)
+        t._changeMatchop.bind(t)
       );
 
       // Added value operator
-      this._valueE = document.createElement('span');
-      this._valueE.setAttribute('data-type', this.type());
-      this._valueE.setAttribute('class', 'value');
+      const valueE = t._valueE = document.createElement('span');
+      valueE.setAttribute('data-type', t.type());
+      valueE.setAttribute('class', 'value');
 
-      if (this.value()) {
-        this._valueE.addT(this.value());
+      if (t.value()) {
+        valueE.addT(t.value());
       }
       else {
-        this._valueE.addT(loc.EMPTY);
-        this._valueE.classList.add('unspecified');
+        valueE.addT(loc.EMPTY);
+        valueE.classList.add('unspecified');
       };
 
       // Change value
-      this._valueE.addEventListener(
+      valueE.addEventListener(
         'click',
-        this._changeValue.bind(this)
+        t._changeValue.bind(t)
       );
 
       // Remove all element children
       _removeChildren(e);
 
       // Add spans
-      e.appendChild(this._keyE);
-      e.appendChild(this._matchopE);
-      e.appendChild(this._valueE);
+      e.appendChild(keyE);
+      e.appendChild(matchopE);
+      e.appendChild(valueE);
 
-      this.__changed = false;
+      t.__changed = false;
 
-      if (this._rewrites !== undefined) {
-        e.appendChild(this._rewrites.element());
+      if (t._rewrites !== undefined) {
+        e.appendChild(t._rewrites.element());
       };
 
-      if (this._parent !== undefined) {
+      if (t._parent !== undefined) {
         
         // Set operators
-        var op = this.operators(
+        // Append new operators
+        e.appendChild(t.operators(
           true,
           true,
           true
-        );
-
-        // Append new operators
-        e.appendChild(op.element());
+        ).element());
       };
       
-      if(KorAP.vc){
-      var vcchevent = new CustomEvent('vcChange', {'detail':this});
-      KorAP.vc.element().dispatchEvent(vcchevent);
+      if (KorAP.vc){
+        KorAP.vc.element().dispatchEvent(
+          new CustomEvent('vcChange', {'detail' : t})
+        );
       }
       
       return e;
@@ -162,48 +166,53 @@
      * Get the associated element
      */
     element : function () {
-      if (this._element !== undefined)
-        return this._element;
+      const t = this;
+      if (t._element !== undefined)
+        return t._element;
 
-      this._element = document.createElement('div');
-      this._element.setAttribute('class', 'doc');
-
-      this.update();
-      return this._element;
+      t._element = document.createElement('div');
+      t._element.setAttribute('class', 'doc');
+      t.update();
+      return t._element;
     },
 
+
     /**
      * Wrap a new operation around the doc element
      */
     wrap : function (op) {
-      var parent = this.parent();
-      var group = require('vc/docgroup').create(parent);
+      const parent = this.parent();
+      const group = require('vc/docgroup').create(parent);
       group.operation(op);
       group.append(this);
       group.append();
       return parent.replaceOperand(this, group).update();
     },
 
+
     replaceWith : function (op) {
-      var p = this.parent();
+      const p = this.parent();
 
       if (p.ldType() === 'docGroup') {
-        p.replaceOperand(this,op);
+        p.replaceOperand(this, op);
       }
       else if (p.ldType() == null) {
         p.root(op);
       };
+
       p.update();
 
       this.destroy();
     },
     
+
     /**
      * Deserialize from json
      */
     fromJson : function (json) {
+      const t = this;
       if (json === undefined)
-        return this;
+        return t;
 
       if (json["@type"] === undefined) {
         KorAP.log(701, "JSON-LD group has no @type attribute");
@@ -216,20 +225,19 @@
         return;
       };
 
-      var rewrite;
+      let rewrite;
 
       // There is a defined key
       if (json["key"] !== undefined &&
           typeof json["key"] === 'string') {
 
         // Set key
-        this.key(json["key"]);
+        t.key(json["key"]);
 
         // Set match operation
         if (json["match"] !== undefined) {
           if (typeof json["match"] === 'string') {
-
-            this.matchop(json["match"]);
+            t.matchop(json["match"]);
           }
           else {
             KorAP.log(802, errstr802);
@@ -241,7 +249,7 @@
         if (json["type"] === undefined && KorAP._vcKeyMenu) {
 
           // Check the VC list if the field is known
-          var type = KorAP._vcKeyMenu.typeOf(this.key());
+          const type = KorAP._vcKeyMenu.typeOf(t.key());
           if (type != undefined) {
             json["type"] = "type:" + type;
           };
@@ -251,69 +259,69 @@
         if (json["type"] === undefined) {
         
           // Check match type
-          if (!KorAP._validUnspecMatchRE.test(this.matchop())) {
+          if (!KorAP._validUnspecMatchRE.test(t.matchop())) {
             KorAP.log(802, errstr802);
 
             // Rewrite method
-            this.matchop('eq');
+            t.matchop('eq');
             rewrite = 'modification';
           };
 
           // Set string value
-          this.value(json["value"]);
+          t.value(json["value"]);
         }
 
         // Field is string type
         else if (json["type"] == "type:string") {
-          this.type("string");
+          t.type("string");
 
           // Check match type
-          if (!KorAP._validStringMatchRE.test(this.matchop())) {
+          if (!KorAP._validStringMatchRE.test(t.matchop())) {
             KorAP.log(802, errstr802);
 
             // Rewrite method
-            this.matchop('eq');
+            t.matchop('eq');
             rewrite = 'modification';
           };
-
+          
           // Set string value
-          this.value(json["value"]);
+          t.value(json["value"]);
         }
 
         // Field is specified
         else if (json["type"] == "type:text") {
-          this.type("text");
+          t.type("text");
 
           // Check match type
-          if (!KorAP._validTextMatchRE.test(this.matchop())) {
+          if (!KorAP._validTextMatchRE.test(t.matchop())) {
             KorAP.log(802, errstr802);
 
             // Rewrite method
-            this.matchop('eq');
+            t.matchop('eq');
             rewrite = 'modification';
           };
 
           // Set string value
-          this.value(json["value"]);
+          t.value(json["value"]);
         }
 
         // Key is a date
         else if (json["type"] === "type:date") {
-          this.type("date");
+          t.type("date");
 
           if (json["value"] !== undefined &&
               KorAP._validDateRE.test(json["value"])) {
 
-            if (!KorAP._validDateMatchRE.test(this.matchop())) {
+            if (!KorAP._validDateMatchRE.test(t.matchop())) {
               KorAP.log(802, errstr802);
 
               // Rewrite method
-              this.matchop('eq');
+              t.matchop('eq');
               rewrite = 'modification';
             };
 
             // Set value
-            this.value(json["value"]);
+            t.value(json["value"]);
           }
           else {
             KorAP.log(806, "Value is not a valid date string");
@@ -323,50 +331,51 @@
 
         // Key is a regular expression
         else if (json["type"] === "type:regex") {
-          this.type("regex");
+          t.type("regex");
 
           try {
 
             // Try to create a regular expression
-            var check = new RegExp(json["value"]);
+            let check = new RegExp(json["value"]);
 
-            if (!KorAP._validStringMatchRE.test(this.matchop())) {
+            if (!KorAP._validStringMatchRE.test(t.matchop())) {
               KorAP.log(802, errstr802);
 
               // Rewrite method
-              this.matchop('eq');
+              t.matchop('eq');
               rewrite = 'modification';
             };
 
-            this.value(json["value"]);
+            t.value(json["value"]);
           }
 
           catch (e) {
             KorAP.log(807, "Value is not a valid regular expression");
             return;
           };
-          this.type("regex");
+          t.type("regex");
         }
 
         else {
-          KorAP.log(804, errstr804 + ": " + this.type());
-          throw new Error(errstr804 + ": " + this.type());
+          KorAP.log(804, errstr804 + ": " + t.type());
+          throw new Error(errstr804 + ": " + t.type());
         };
       };
 
       // Rewrite coming from the server
       if (json["rewrites"] !== undefined) {
-        this.rewrite(json["rewrites"]);
+        t.rewrite(json["rewrites"]);
       }
 
       // Rewrite coming from Kalamar
       else if (rewrite !== undefined) {
-        this.rewrite(rewrite);
+        t.rewrite(rewrite);
       };
 
-      return this;
+      return t;
     },
 
+
     /**
      * Get or set the key
      */
@@ -379,9 +388,10 @@
       return this._key;
     },
 
+
     // Click on the key, show me the menu
     _changeKey : function (e) {
-      var menu = KorAP._vcKeyMenu;
+      const menu = KorAP._vcKeyMenu;
 
       // Insert menu
       this._element.insertBefore(
@@ -390,16 +400,18 @@
       );
 
       // Release event
-      var that = this;
+      const that = this;
       menu.released(function (key, type) {
 
         if (type === 'ref') {
           // KorAP._delete.bind(that);
-          var ref = docGroupRefClass.create(that.parent());
-          that.replaceWith(ref);
+          that.replaceWith(
+            docGroupRefClass.create(that.parent())
+          );
         }
+
         else {
-          var doc = that.key(key).type(type);
+          const doc = that.key(key).type(type);
 
           // This may not be compatible - then switch to default
           doc.matchop(doc.matchop());
@@ -418,42 +430,45 @@
       menu.focus();
     },
 
+
     /**
      * Get or set the match operator
      */
     matchop : function (match) {
+      const t = this;
 
       if (arguments.length === 1) {
-        var m = match.replace(/^match:/, '');
+        const m = match.replace(/^match:/, '');
 
         if (
-          (this._type == undefined) // && KorAP._validUnspecMatchRE.test(m))
+          (t._type == undefined) // && KorAP._validUnspecMatchRE.test(m))
             ||
             (
-              (this._type === 'string' || this._type === 'regex') &&
+              (t._type === 'string' || t._type === 'regex') &&
                 KorAP._validStringMatchRE.test(m)
             )
             ||
-            (this._type === 'text' && KorAP._validTextMatchRE.test(m))
+            (t._type === 'text' && KorAP._validTextMatchRE.test(m))
             ||
-            (this._type === 'date' && KorAP._validDateMatchRE.test(m))
+            (t._type === 'date' && KorAP._validDateMatchRE.test(m))
         ) {
-          this._matchop = m;
+          t._matchop = m;
         }
         else {
-          this._matchop = "eq";
+          t._matchop = "eq";
         };
 
-        this._changed();
-        return this
+        t._changed();
+        return t;
       };
-      return this._matchop || "eq";
+
+      return t._matchop || "eq";
     },
 
 
     // Click on the match operator, show me the menu
     _changeMatchop : function (e) {
-      var menu = KorAP._vcMatchopMenu[this.type()];
+      const menu = KorAP._vcMatchopMenu[this.type()];
 
       if (menu === undefined) {
         KorAP.log(0, "Unable to init menu for " + this.type());
@@ -467,7 +482,7 @@
       );
 
       // Release event
-      var that = this;
+      const that = this;
       menu.released(function (mo) {
         that.matchop(mo).update();
         this.hide();
@@ -495,29 +510,29 @@
      * Get or set the value
      */
     value : function (value) {
+      const t = this;
       if (arguments.length === 1) {
-        if (this._type === 'date' && !KorAP._validDateRE.test(value)) {
-          delete this._value;
+        if (t._type === 'date' && !KorAP._validDateRE.test(value)) {
+          delete t._value;
         }
         else {
-          this._value = value;
+          t._value = value;
         };
-        this._changed();
-        return this;
+        t._changed();
+        return t;
       };
-      return this._value;
+      return t._value;
     },
 
 
     // Click on the match operator, show me the menu
     _changeValue : function (e) {
-      var v = this.value();
-      var that = this;
+      const that = this;
      
       // Show datepicker
       if (this.type() === 'date') {
-        var dp = KorAP._vcDatePicker;
-        dp.fromString(v);
+        const dp = KorAP._vcDatePicker;
+        dp.fromString(this.value());
 
         // Todo: change this
         dp.onclick(function (selected) {
@@ -535,20 +550,18 @@
           );
         });
 
-        // Get element of the date picker
-        var dpElem = dp.show();
-
         this._element.insertBefore(
-          dpElem,
+          dp.show(), // Get element of the date picker
           this._valueE
         );
 
         dp.input().focus();
       }
+
       else {
-        var regex = this.type() === 'regex' ? true : false;
-        var str = stringValClass.create(this.value(), regex);
-        var strElem = str.element();
+        const regex = this.type() === 'regex' ? true : false;
+        const str = stringValClass.create(this.value(), regex);
+        const strElem = str.element();
 
         str.store = function (value, regex) {
           that.value(value);
@@ -578,6 +591,7 @@
       return this._rewrites;
     },
 
+
     rewrite : function (value) {
       if (typeof value === 'string') {
         value = [{
@@ -589,6 +603,7 @@
       this._rewrites = rewriteListClass.create(value);
     },
 
+
     // Mark the underlying data as being changed.
     // This is important for rerendering the dom.
     // This will also remove rewrite markers, when the data
@@ -599,8 +614,8 @@
       if (this._rewrites === undefined)
         return;
 
-        delete this["_rewrites"];
-
+      delete this["_rewrites"];
+      
       if (this._element === undefined)
         return;
 
@@ -609,28 +624,32 @@
 
 
     toJson : function () {
-      if (!this.matchop() || !this.key())
+      const t = this;
+
+      if (!t.matchop() || !t.key())
         return {};
       
       return {
-        "@type" : "koral:" + this.ldType(),
-        "key"   : this.key(),
-        "match" : "match:" + this.matchop(),
-        "value" : this.value() || '',
-        "type"  : "type:" + this.type()
+        "@type" : "koral:" + t.ldType(),
+        "key"   : t.key(),
+        "match" : "match:" + t.matchop(),
+        "value" : t.value() || '',
+        "type"  : "type:" + t.type()
       };
     },
 
+
     incomplete : function () {
       return !(this.matchop() && this.key() && this.value());
     },
 
+
     toQuery : function () {
       if (this.incomplete())
         return "";
 
       // Build doc string based on key
-      var string = this.key() + ' ';
+      let string = this.key() + ' ';
 
       // Add match operator
       switch (this.matchop()) {
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 47f3a96..1dbd5d7 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -4,6 +4,8 @@
 /*
  * TODO: Let the UPDATE event bubble up through parents!
  */
+"use strict";
+
 define([
   'vc/jsonld',
   'vc/unspecified',
@@ -18,10 +20,11 @@
   const _validGroupOpRE = new RegExp("^(?:and|or)$");
 
   const docGroupClass = {
+
     _ldType : "docGroup",
 
     create : function (parent, json) {
-      var obj = Object.create(jsonldClass).upgradeTo(this);
+      const obj = Object.create(jsonldClass).upgradeTo(this);
       obj._operands = [];
       obj.fromJson(json);
       if (parent !== undefined)
@@ -29,22 +32,23 @@
       return obj;
     },
     
+
     newAfter : function (obj) {
       this._operands.forEach(function (op, i) {
 	      if (op === obj) {
-	        var operand = unspecClass.create(this);
+	        const operand = unspecClass.create(this);
 	        this._operands.splice(i + 1, 0, operand);
 	        return this.update();
 	      };
       }, this);
     },
 
+
     // The doc is already set in the group
     _duplicate : function (operand) {
 
       // TODO:
       //   Also check for duplicate docGroupRefs!
-      
       if (operand.ldType() !== 'doc')
 	      return null;
 
@@ -62,6 +66,7 @@
       return null;
     },
     
+
     append : function (operand) {
       
       // Append unspecified object
@@ -88,7 +93,7 @@
 	        // Be aware of cyclic structures!
 	        operand.parent(this);
 
-	        var dupl = this._duplicate(operand);
+	        const dupl = this._duplicate(operand);
 	        if (dupl === null) {
 	          this._operands.push(operand);
 	          return operand;
@@ -101,10 +106,11 @@
 
       case "koral:doc":
 	      // Be aware of cyclic structures!
-	      var doc = docClass.create(this, operand);
+	      const doc = docClass.create(this, operand);
 	      if (doc === undefined)
 	        return;
-	      var dupl = this._duplicate(doc);
+        
+	      const dupl = this._duplicate(doc);
 	      if (dupl === null) {
 	        this._operands.push(doc);
 	        return doc;
@@ -112,15 +118,16 @@
 	      return dupl;
 
       case "koral:docGroup":
-	      // Be aware of cyclic structures!
-	      var docGroup = docGroupClass.create(this, operand);
+
+        // Be aware of cyclic structures!
+	      const docGroup = docGroupClass.create(this, operand);
 	      if (docGroup === undefined)
 	        return;
 
 	      // Flatten group
 	      if (docGroup.operation() === this.operation()) {
           docGroup.operands().forEach(function(op) {
-	          var dupl = this._duplicate(op);
+	          const dupl = this._duplicate(op);
 	          if (dupl === null) {
 	            this._operands.push(op);
 	            op.parent(this);
@@ -135,11 +142,10 @@
 
       case "koral:docGroupRef":
       
-        var docGroupRef = docGroupRefClass.create(this, operand);
+        const docGroupRef = docGroupRefClass.create(this, operand);
       
-        if (docGroupRef === undefined) {
+        if (docGroupRef === undefined)
           return
-        };
 
         // TODO:
         //   Currently this doesn't do anything meaningful,
@@ -161,25 +167,28 @@
       };
     },
 
+
     update : function () {
+      const t = this;
+
       // There is only one operand in group
       
-      if (this._operands.length === 1) {
+      if (t._operands.length === 1) {
 	      
-	      var parent = this.parent();
-	      var op = this.getOperand(0);
+	      const parent = t.parent();
+	      const op = t.getOperand(0);
 	      
 	      // This will prevent destruction of
 	      // the operand
-	      this._operands = [];
+	      t._operands = [];
 
 	      // Parent is a group
 	      if (parent.ldType() !== null)
-	        return parent.replaceOperand(this, op).update();
+	        return parent.replaceOperand(t, op).update();
 
 	      // Parent is vc
 	      else {
-	        this.destroy();
+	        t.destroy();
 	        // Cyclic madness
 	        parent.root(op);
 	        op.parent(parent);
@@ -187,49 +196,54 @@
 	      };
       };
 
-      if (this._element === undefined)
-	      return this;
+      if (t._element === undefined)
+	      return t;
 
-      var group = this._element;
-      group.setAttribute('data-operation', this.operation());
+      const group = t._element;
+      group.setAttribute('data-operation', t.operation());
 
       _removeChildren(group);
 
       // Append operands
-      this._operands.forEach(
+      t._operands.forEach(
         op => group.appendChild(op.element())
       );
 
       // Set operators
-      var op = this.operators(
-	      this.operation() == 'and' ? false : true,
-	      this.operation() == 'or'  ? false : true,
+      var op = t.operators(
+	      t.operation() == 'and' ? false : true,
+	      t.operation() == 'or'  ? false : true,
 	      true
       );
 
       group.appendChild(op.element());
 
       if (KorAP.vc) {
-        var vcchevent = new CustomEvent('vcChange', {'detail':this});
-        KorAP.vc.element().dispatchEvent(vcchevent);
+        KorAP.vc.element().dispatchEvent(
+          new CustomEvent('vcChange', {'detail' : t})
+        );
       };
       
-      return this;
+      return t;
     },
 
+
     element : function () {
-      if (this._element !== undefined)
-	      return this._element;
+      const t = this;
 
-      this._element = document.createElement('div');
-      this._element.setAttribute('class', 'docGroup');
+      if (t._element !== undefined)
+	      return t._element;
+
+      const e = t._element = document.createElement('div');
+      e.setAttribute('class', 'docGroup');
 
       // Update the object - including optimization
-      this.update();
+      t.update();
 
-      return this._element;
+      return e;
     },
 
+
     operation : function (op) {
       if (arguments.length === 1) {
 	      if (_validGroupOpRE.test(op)) {
@@ -243,18 +257,22 @@
       return this._op || 'and';
     },
 
+
     operands : function () {
       return this._operands;
     },
 
+
     getOperand : function (index) {
       return this._operands[index];
     },
 
+
     // Replace operand
     replaceOperand : function (oldOp, newOp) {
       
-      for (var i = 0; i < this._operands.length; i++) {
+      for (let i = 0; i < this._operands.length; i++) {
+
 	      if (this._operands[i] === oldOp) {
 	        
 	        // Just insert a doc or ...
@@ -270,18 +288,24 @@
 
 	        // Flatten group
 	        else {
-	          // Remove old group
+
+            // Remove old group
 	          this._operands.splice(i, 1);
 
 	          // Inject new operands
-            newOp.operands().reverse().forEach(function(op) {
-	            this._operands.splice(i, 0, op);
-	            op.parent(this);
-	          }, this);
+            newOp.operands().reverse().forEach(
+              function(op) {
+	              this._operands.splice(i, 0, op);
+	              op.parent(this);
+	            },
+              this
+            );
+
 	          // Prevent destruction of operands
 	          newOp._operands = [];
 	          newOp.destroy();
 	        };
+
 	        oldOp.destroy();
 	        return this;
 	      }
@@ -289,9 +313,11 @@
       return false;
     },
 
+
     // Delete operand from group
     delOperand : function (obj) {
-      for (var i = 0; i < this._operands.length; i++) {
+
+      for (let i = 0; i < this._operands.length; i++) {
 	      if (this._operands[i] === obj) {
 	        
 	        // Delete identified operand
@@ -308,8 +334,10 @@
       return undefined;
     },
     
+
     // Deserialize from json
     fromJson : function (json) {
+
       if (json === undefined)
 	      return this;
 
@@ -324,7 +352,7 @@
 	      return;
       };
 
-      var operation = json["operation"];
+      const operation = json["operation"];
 
       this.operation(operation.replace(/^operation:/,''));
 
@@ -340,12 +368,14 @@
       return this;
     },
 
+
     toJson : function () {
-      var opArray = new Array();
+      const opArray = new Array();
       this._operands.forEach(function(op) {
 	      if (op.ldType() !== 'non')
 	        opArray.push(op.toJson());
       });
+
       return {
 	      "@type"     : "koral:" + this.ldType(),
 	      "operation" : "operation:" + this.operation(),
@@ -353,6 +383,7 @@
       };
     },
 
+
     toQuery : function (brackets) {
       var list = this._operands
 	        .filter(function (op) {
@@ -367,10 +398,11 @@
       if (list.length === 1)
 	      return list.join('');
       else {
-	      var str = list.join(this.operation() === 'or' ? ' | ' : ' & ');
+	      const str = list.join(this.operation() === 'or' ? ' | ' : ' & ');
 	      return brackets ? '(' + str + ')' : str;
       };
     }
   };
+  
   return docGroupClass;
 });
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
index e72385a..83ac244 100644
--- a/dev/js/src/vc/docgroupref.js
+++ b/dev/js/src/vc/docgroupref.js
@@ -25,18 +25,17 @@
      * with a link to the parent object
      */
     create : function (parent, json) {
-      var obj = Object(jsonldClass)
-          .create().
-	        upgradeTo(this)
-          .fromJson(json);
-
-      if (obj === undefined) {
+      const obj = Object(jsonldClass).
+            create().
+	          upgradeTo(this).
+            fromJson(json);
+      
+      if (obj === undefined)
         console.log(json);
-      };
 
       if (parent !== undefined)
 	      obj._parent = parent;
-
+      
       obj.__changed = true;
       return obj;
     },
@@ -46,43 +45,46 @@
      * Update the element
      */
     update : function () {
-      if (this._element === undefined)
-        return this.element();
+      const t = this;
 
-      var e = this._element;
+      if (t._element === undefined)
+        return t.element();
+
+      const e = t._element;
 
       // Check if there is a change in the underlying data
-      if (!this.__changed)
+      if (!t.__changed)
         return e;
 
       // Set ref - TODO: Cleanup!
-      e.refTo = this;
+      e.refTo = t;
 
       // Was rewritten
-      if (this.rewrites() !== undefined) {
+      if (t.rewrites() !== undefined) {
         e.classList.add("rewritten");
       };
 
-      var refTitle = document.createElement('span');
+      const refTitle = document.createElement('span');
       refTitle.classList.add('key','fixed', 'ref');
       refTitle.addT('referTo');
 
       // Added value operator
-      this._refE = document.createElement('span');
-      this._refE.setAttribute('data-type', "string");
-      this._refE.setAttribute('class', 'value');
+      const refE = t._refE = document.createElement('span');
+      refE.setAttribute('data-type', "string");
+      refE.setAttribute('class', 'value');
+
       if (this.ref()) {
-        this._refE.addT(this.ref());
+        refE.addT(t.ref());
       }
       else {
-        this._refE.addT(loc.EMPTY);
-        this._refE.classList.add('unspecified');
+        refE.addT(loc.EMPTY);
+        refE.classList.add('unspecified');
       };
 
       // Change value
-      this._refE.addEventListener(
+      refE.addEventListener(
         'click',
-        this._changeRef.bind(this)
+        t._changeRef.bind(t)
       );
 
       // Remove all element children
@@ -90,30 +92,30 @@
 
       // Add spans
       e.appendChild(refTitle);
-      e.appendChild(this._refE);
+      e.appendChild(refE);
 
-      this.__changed = false;
+      t.__changed = false;
 
-      if (this._rewrites !== undefined) {
-        e.appendChild(this._rewrites.element());
+      if (t._rewrites !== undefined) {
+        e.appendChild(t._rewrites.element());
       };
 
-      if (this._parent !== undefined) {
+      if (t._parent !== undefined) {
+
         // Set operators
-        var op = this.operators(
+        // Append new operators
+        e.appendChild(t.operators(
           true,
           true,
           true
-        );
-
-        // Append new operators
-        e.appendChild(op.element());
+        ).element());
       };  
      
-      var vcchevent = new CustomEvent('vcChange', {'detail':this});
-      KorAP.vc.element().dispatchEvent(vcchevent);
+      KorAP.vc.element().dispatchEvent(
+        new CustomEvent('vcChange', { 'detail' : t })
+      );
       
-      return this.element();
+      return t.element();
     },
 
 
@@ -121,12 +123,14 @@
      * Get the associated element
      */
     element : function () {
+
       if (this._element !== undefined)
 	      return this._element;
-      this._element = document.createElement('div');
-      this._element.setAttribute('class', 'doc groupref');
+
+      const e = this._element = document.createElement('div');
+      e.setAttribute('class', 'doc groupref');
       this.update();
-      return this._element;
+      return e;
     },
 
 
@@ -145,10 +149,9 @@
 
     // Click on the reference operator, show me the option
     _changeRef : function (e) {
-      var that = this;
-
-      var str = stringValClass.create(this.ref(), false, false);
-      var strElem = str.element();
+      const that = this;
+      const str = stringValClass.create(this.ref(), false, false);
+      const strElem = str.element();
 
       str.store = function (ref, regex) {
         that.ref(ref);
@@ -174,14 +177,15 @@
      * This is copypasta from doc.js
      */
     wrap : function (op) {
-      var parent = this.parent();
-      var group = require('vc/docgroup').create(parent);
+      const parent = this.parent();
+      const group = require('vc/docgroup').create(parent);
       group.operation(op);
       group.append(this);
       group.append();
       return parent.replaceOperand(this, group).update();
     },
 
+
     /**
      * Deserialize from json
      */
@@ -210,6 +214,7 @@
       return this;
     },
 
+
     /**
      * Click on the unspecified object
      */
@@ -217,11 +222,13 @@
       console.log("Do not support click on this");
     },
 
+
     // TODO: This is identical to doc.js
     rewrites : function () {
       return this._rewrites;
     },
 
+
     // TODO: This is identical to doc.js
     rewrite : function (value) {
       if (typeof value === 'string') {
@@ -245,7 +252,7 @@
       if (this._rewrites === undefined)
         return;
 
-        delete this["_rewrites"];
+      delete this["_rewrites"];
 
       if (this._element === undefined)
         return;
@@ -253,13 +260,14 @@
       this._element.classList.remove("rewritten");
     },
 
+
     toJson : function () {
       if (!this.ref)
         return {};
       
       return {
         "@type" : "koral:" + this.ldType(),
-        "ref"  : this.ref()
+        "ref"   : this.ref()
       };
     },
 
@@ -268,6 +276,7 @@
       return this.ref() ? false : true
     },
     
+
     toQuery : function () {
       if (this.incomplete())
         return "";
diff --git a/dev/js/src/vc/fragment.js b/dev/js/src/vc/fragment.js
index bf1905e..0f155ff 100644
--- a/dev/js/src/vc/fragment.js
+++ b/dev/js/src/vc/fragment.js
@@ -6,9 +6,9 @@
  * @author Nils Diewald
  */
 
-define(['vc/doc', 'util'], function (docClass) {
+"use strict";
 
-  "use strict";
+define(['vc/doc', 'util'], function (docClass) {
 
   const loc = KorAP.Locale;
   loc.NEW_CONSTRAINT = loc.NEW_CONSTRAINT || 'New Constraint';
@@ -29,7 +29,7 @@
     const value = doc.addE('span');
     value.setAttribute('class', 'value');
     value.addT(op[1]);
-      
+
     return doc;
   };
 
@@ -51,7 +51,7 @@
      * Add document constraint to fragment
      */
     add : function (key, value, type) {
-      this._operands.forEach(function (op,i,arr) {
+      this._operands.forEach(function (op, i, arr) {
         if (op[0] === key && op[1] === value) {
           arr.splice(i,1);
         }
@@ -94,14 +94,14 @@
       };
 
       // Initialize element
-      this._element = document.createElement('div');
-      this._element.classList.add('vc', 'fragment');
+      const e = this._element = document.createElement('div');
+      e.classList.add('vc', 'fragment');
 
       // Prepend info text
-      this._element.addE('span').addT(loc.NEW_CONSTRAINT + ':');
-      this._frag = this._element.addE('div');
+      e.addE('span').addT(loc.NEW_CONSTRAINT + ':');
+      this._frag = e.addE('div');
       
-      return this._element;
+      return e;
     },
 
 
@@ -115,17 +115,13 @@
           doc.key(item[0]);
           doc.matchop("eq");
           doc.value(item[1]);
-          if (item[2] === "date") {
-            doc.type("date");
-          }
-          else {
-            doc.type("string");
-          };
+          doc.type(item[2] === "date" ? "date" : "string");
           return doc;
         }
       );
     },
 
+
     /**
      * Update the whole object based on the underlying data structure
      */
diff --git a/dev/js/src/vc/item.js b/dev/js/src/vc/item.js
index f9267e8..59589d8 100644
--- a/dev/js/src/vc/item.js
+++ b/dev/js/src/vc/item.js
@@ -1,4 +1,6 @@
 // Field menu item
+"use strict";
+
 define(['menu/item', 'util'], function (itemClass) {
 
   const loc = KorAP.Locale;
@@ -18,22 +20,26 @@
 	      ._init(params);
     },
 
+
     // Initialize item object
     _init : function (params) {
+      const t = this;
+
       if (params[0] === undefined)
 	      throw new Error("Missing parameters");
 
-      this._key = params[0];
-      this._type  = params[1];
+      t._key = params[0];
+      t._type  = params[1];
 
-      var k = this._key;
-      this._name  = loc["VC_" + k] ? loc["VC_" + k] : k;
+      const k = t._key;
+      t._name  = loc["VC_" + k] ? loc["VC_" + k] : k;
 
-      this._lcField = ' ' + this._name.toLowerCase();
+      t._lcField = ' ' + t._name.toLowerCase();
 
-      return this;
+      return t;
     },
 
+
     /**
      * Override click event by passing all clicks
      * to the menu object.
@@ -46,6 +52,7 @@
       e.halt();
     },
 
+
     /**
      * Get the name of the item.
      * This is a potential localized version
@@ -55,6 +62,7 @@
       return this._name;
     },
 
+
     /**
      * Get the type of the item.
      */
@@ -62,6 +70,7 @@
       return this._type;
     },
 
+
     /**
      * Get the key of the item.
      */
@@ -69,26 +78,29 @@
       return this._key;
     },
 
+
     /**
      * Get the HTML element associated with the item. 
      */
     element : function () {
+      const t = this;
 
       // already defined
-      if (this._element !== undefined)
-	      return this._element;
+      if (t._element !== undefined)
+	      return t._element;
 
       // Create list item
       var li = document.createElement("li");
-      if (this._type)
-        li.setAttribute("data-type", this._type);
-      li.setAttribute("data-key",  this._key);
+      if (t._type)
+        li.setAttribute("data-type", t._type);
+
+      li.setAttribute("data-key",  t._key);
 
       // Connect action
-      li["onclick"] = this.onclick.bind(this);
+      li["onclick"] = t.onclick.bind(t);
 
-      li.addT(this._name);
-      return this._element = li;
+      li.addT(t._name);
+      return t._element = li;
     }
   };
 });
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index cfa0acc..fdee980 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -1,31 +1,38 @@
 /**
  * Abstract JsonLD criterion object
  */
+"use strict";
+
 define(['vc/operators'], function (operatorsClass) {
+
   return {
+
     __changed : false,
     
     create : function () {
       return Object.create(this);
     },
 
+
     /**
      * Upgrade this object to another object
      * while private data stays intact
      */
     upgradeTo : function (props) {
-      for (var prop in props) {
+      for (let prop in props) {
 	      this[prop] = props[prop];
       };
       return this;
     },
     
+
     ldType : function (type) {
       if (arguments.length === 1)
 	      this._ldType = type;
       return this._ldType;
     },
     
+
     parent : function (obj) {
       if (arguments.length === 1) {
 	      this._parent = obj;
@@ -34,34 +41,35 @@
       return this._parent;
     },
 
+
     // Destroy object - especially for
     // acyclic structures!
     // I'm paranoid!
     destroy : function () {
-      
-      if (this._ops != undefined) {
-	      this._ops._parent = undefined;
-	      if (this._ops._element !== undefined) {
-	        this._ops._element.refTo = undefined;
+      const t = this;
+      if (t._ops != undefined) {
+	      t._ops._parent = undefined;
+	      if (t._ops._element !== undefined) {
+	        t._ops._element.refTo = undefined;
         };
-	      this._ops = undefined;
+	      t._ops = undefined;
       };
 
-      if (this._element !== undefined)
-	      this._element = undefined;
+      if (t._element !== undefined)
+	      t._element = undefined;
       
       // In case of a group, destroy all operands
-      if (this._operands !== undefined) {
-        this._operands.forEach(i => i.destroy());
-	      this._operands = [];
+      if (t._operands !== undefined) {
+        t._operands.forEach(i => i.destroy());
+	      t._operands = [];
       };
     },
     
     // Wrap a new operation around the root group element 
     wrapOnRoot : function (op) {
-      var parent = this.parent();
-      
-      var group = require('vc/docgroup').create(parent);
+      const parent = this.parent();
+      const group = require('vc/docgroup').create(parent);
+
       if (arguments.length === 1)
 	      group.operation(op);
       else
@@ -76,17 +84,21 @@
       return this.parent();
     },
 
+
     // Be aware! This may be cyclic
     operators : function (and, or, del) {
       if (arguments === 0)
 	      return this._ops;
+
       this._ops = operatorsClass.create(
 	      and, or, del
       );
+
       this._ops.parent(this);
       return this._ops;
     },
 
+
     toJson : function () {
       return {
 	      // Unspecified object
@@ -94,14 +106,17 @@
       };
     },
 
+
     rewrites : function () {
       return null;
     },
 
+
     incomplete : function () {
       return false;
     },
 
+
     toQuery : function () {
       return '';
     }
diff --git a/dev/js/src/vc/menu.js b/dev/js/src/vc/menu.js
index f2f4b2f..40dbab0 100644
--- a/dev/js/src/vc/menu.js
+++ b/dev/js/src/vc/menu.js
@@ -1,22 +1,34 @@
 /**
  * Menu showing all key fields.
  */
-define(['menu', 'vc/item', 'vc/prefix'], function (menuClass, itemClass, prefixClass) {
+"use strict";
+
+define([
+  'menu',
+  'vc/item',
+  'vc/prefix'
+], function (
+  menuClass,
+  itemClass,
+  prefixClass) {
 
   return {
+
     create : function (params) {
-      var obj = Object.create(menuClass)
-          .upgradeTo(this)
-          ._init(params, {
-            itemClass : itemClass,
-            prefixClass : prefixClass
-          });
+      const obj = Object.create(menuClass)
+            .upgradeTo(this)
+            ._init(params, {
+              itemClass : itemClass,
+              prefixClass : prefixClass
+            });
       obj.limit(6);
 
       // This is only domspecific
-      obj.element().addEventListener('blur', function (e) {
-        this.menu.hide();
-      });
+      obj.element().addEventListener(
+        'blur', function (e) {
+          this.menu.hide();
+        }
+      );
  
       return obj;
     },
@@ -38,6 +50,7 @@
         this._cb(key, type);
     },
 
+
     /**
      * Return a key type based on a key.
      * This is a linear search, but should work okay for small
@@ -45,6 +58,7 @@
      */
     typeOf : function (key) {
       const found = this._items.find(i => i.key() === key);
+
       if (found)
         return found.type();
     }
diff --git a/dev/js/src/vc/operators.js b/dev/js/src/vc/operators.js
index 306c371..928e943 100644
--- a/dev/js/src/vc/operators.js
+++ b/dev/js/src/vc/operators.js
@@ -1,21 +1,25 @@
 /**
  * Operators for criteria
  */
+"use strict";
+
 define(['buttongroup'], function (buttonGroupClass) {
 
   const loc = KorAP.Locale;
   loc.DEL   = loc.DEL   || '×';
 
-
   // Utility for analysing boolean values
   function _bool (bool) {
-    return (bool === undefined || bool === null || bool === false) ? false : true;
+    return (
+      bool === undefined ||
+        bool === null ||
+        bool === false) ? false : true;
   };
 
 
   // Add new unspecified document
   function _add (obj, type) {
-    var parent = obj.parent();
+    const parent = obj.parent();
 
     if (obj.ldType() === 'docGroup') {
 
@@ -26,19 +30,24 @@
       if (parent.ldType() !== null) {
 	      return parent.newAfter(obj);
       }
+
       else {
 	      // The group is on root - wrap
 	      return obj.wrapOnRoot();
       };
     }
-    else if (obj.ldType() === 'doc' || obj.ldType() === 'docGroupRef') {
+
+    else if (obj.ldType() === 'doc' ||
+             obj.ldType() === 'docGroupRef') {
 
       if (parent.ldType() === null) {
 	      return obj.wrapOnRoot(type);
       }
+
       else if (parent.operation() === type) {
 	      return parent.newAfter(obj);
       }
+
       else {
 	      return obj.wrap(type);
       };
@@ -82,31 +91,34 @@
       return op;
     },
 
+
     /*
-      * Update the element
+     * Update the element
      */
     update : function () {
+      const t = this;
 
       // Clear button group
-      this.clear();
+      t.clear();
 
-      if (this._and === true) {
-        this.add(loc.AND, {'cls':['and']}, KorAP._and);
+      if (t._and === true) {
+        t.add(loc.AND, {'cls':['and']}, KorAP._and);
       };
 
       // Add or button
-      if (this._or === true) {
-        this.add(loc.OR, {'cls':['or']}, KorAP._or);
+      if (t._or === true) {
+        t.add(loc.OR, {'cls':['or']}, KorAP._or);
       };
 
       // Add delete button
-      if (this._del === true) {
-        this.add(loc.DEL, {'cls':['delete']}, KorAP._delete);
+      if (t._del === true) {
+        t.add(loc.DEL, {'cls':['delete']}, KorAP._delete);
       };
 
-      return this.element();
+      return t.element();
     },
 
+
     // Be aware! This may be cyclic
     // This is somehow redundant with bind, but relevant for ldTypes
     parent : function (obj) {
@@ -116,21 +128,25 @@
         // This is somehow duplicate - but it's not that relevant
         this.bind(obj);
       };
+
       return this._parent;
     },
 
+
     and : function (bool) {
       if (arguments.length === 1)
 	      this._and = _bool(bool);
       return this._and;
     },
 
+
     or : function (bool) {
       if (arguments.length === 1)
 	      this._or = _bool(bool);
       return this._or;
     },
 
+
     del : function (bool) {
       if (arguments.length === 1)
 	      this._del = _bool(bool);
diff --git a/dev/js/src/vc/prefix.js b/dev/js/src/vc/prefix.js
index 5deefe4..32989bc 100644
--- a/dev/js/src/vc/prefix.js
+++ b/dev/js/src/vc/prefix.js
@@ -1,3 +1,5 @@
+"use strict";
+
 define(['menu/prefix'], function (prefixClass) {
   return {
 
@@ -9,6 +11,7 @@
 	      upgradeTo(this)._init(params);
     },
 
+
     /**
      * Override the prefix action.
      */
diff --git a/dev/js/src/vc/rewrite.js b/dev/js/src/vc/rewrite.js
index 150ee87..5af4b35 100644
--- a/dev/js/src/vc/rewrite.js
+++ b/dev/js/src/vc/rewrite.js
@@ -1,6 +1,8 @@
 /**
  * Implementation of rewrite objects.
  */
+"use strict";
+
 define(['vc/jsonld', 'util'], function (jsonldClass) {
 
   // injection, modification, and deletion should probably be enough
@@ -8,15 +10,16 @@
         new RegExp("^(operation:)?(?:injec|inser|modifica|dele)tion|override$");
 
   return {
+
     // Construction method
     create : function (json) {
-      var obj = Object(jsonldClass).
-	        create().
-	        upgradeTo(this).
-	        fromJson(json);
-      return obj;
+      return Object(jsonldClass).
+	      create().
+	      upgradeTo(this).
+	      fromJson(json);
     },
 
+
     // Get or set source
     src : function (string) {
       if (arguments.length === 1)
@@ -24,6 +27,7 @@
       return this._src;
     },
     
+
     // Get or set operation
     operation : function (op) {
       if (arguments.length === 1) {
@@ -38,6 +42,7 @@
       return this._op || 'injection';
     },
 
+
     // Get or set scope
     scope : function (attr) {
       if (arguments.length === 1)
@@ -45,6 +50,7 @@
       return this._scope;
     },
 
+
     // Serialize from Json
     fromJson : function (json) {
       if (json === undefined)
@@ -68,8 +74,7 @@
 
       // Set operation
       if (json["operation"] !== undefined) {
-	      var operation = json["operation"];
-	      this.operation(operation.replace(/^operation:/,''));
+	      this.operation(json["operation"].replace(/^operation:/,''));
       };
 
       // Set scope
@@ -80,9 +85,10 @@
       return this;
     },
     
+
     toString : function () {
-      var str = '';
-      var op = this.operation();
+      let str = '';
+      const op = this.operation();
       str += op.charAt(0).toUpperCase() + op.slice(1);
       str += ' of ' + (
 	      this._scope === null ?
diff --git a/dev/js/src/vc/rewritelist.js b/dev/js/src/vc/rewritelist.js
index d6885c9..410c975 100644
--- a/dev/js/src/vc/rewritelist.js
+++ b/dev/js/src/vc/rewritelist.js
@@ -1,12 +1,14 @@
+"use strict";
+
 define(['vc/jsonld', 'vc/rewrite','util'], function (jsonldClass, rewriteClass) {
   return {
+
     // Construction method
     create : function (json) {
-      var obj = Object(jsonldClass).
-	        create().
-	        upgradeTo(this).
-	        fromJson(json);
-      return obj;
+      return Object(jsonldClass).
+	      create().
+	      upgradeTo(this).
+	      fromJson(json);
     },
 
 
@@ -24,10 +26,12 @@
       return this;
     },
 
+
     length : function () {
       return this._list.length;
     },
 
+
     /**
      * Get element.
      */
@@ -35,19 +39,21 @@
       if (this._element !== undefined)
 	      return this._element;
 
-      this._element = document.createElement('div');
-      this._element.setAttribute('class', 'rewrite');
-      var comments = [];
-      this._list.forEach(function(rewrite) {
+      const e = this._element = document.createElement('div');
+      e.setAttribute('class', 'rewrite');
+
+      const comments = [];
+      let span, rewriteText;
+      this._list.forEach(function (rewrite) {
 	    
         // This is a blind element
-	      var span = document.createElement('span');
+	      span = document.createElement('span');
 
 	      // Set class attribute
 	      span.setAttribute('class', rewrite.operation());
 
 	      // Append source information
-	      var rewriteText = rewrite.src();
+	      rewriteText = rewrite.src();
 
 	      // Append scope information
 	      if (rewrite.scope() !== undefined) {
@@ -61,8 +67,10 @@
         
 	      this._element.appendChild(span);
       }, this);
-      this._element.setAttribute("title", comments.join("\n"))
-      return this._element;
+
+      e.setAttribute("title", comments.join("\n"))
+
+      return e;
     }
   };
 });
diff --git a/dev/js/src/vc/statistic.js b/dev/js/src/vc/statistic.js
index 0c3c6ca..4dd5ab3 100644
--- a/dev/js/src/vc/statistic.js
+++ b/dev/js/src/vc/statistic.js
@@ -6,6 +6,8 @@
  * 
  */
 
+"use strict";
+
 define([ 'util' ], function() {
 
   return {
@@ -13,14 +15,15 @@
     /**
      * Create new statistic object
      */
-    create : function(statistic) {
+    create : function (statistic) {
       return Object.create(this)._init(statistic);
     },
 
+
     /**
      * Initialize statistic object
      */
-    _init : function(statistic) {
+    _init : function (statistic) {
       if (statistic === undefined) {
         throw new Error("Missing parameter");
       } else {
@@ -29,10 +32,11 @@
       }
     },
 
+
     /**
      * Display statistic object as HTML Description List Element
      */
-    element : function() {
+    element : function () {
 
       // if this._element already exists return without doing something
       if (this._element !== undefined) {
@@ -40,11 +44,13 @@
       }
 
       // create HTML Description List Element
-      var statDL = document.createElement('dl');
+      const statDL = document.createElement('dl');
       statDL.classList.add("flex");
-      var statistic = this._statistic;
 
-      Object.keys(statistic).forEach(function(k) {
+      const statistic = this._statistic;
+      let statSp, statDT, statDD;
+
+      Object.keys(statistic).forEach(function (k) {
         statSp = statDL.addE('div')
         statDT = statSp.addE('dt');
         statDT.addT(k);
@@ -55,8 +61,7 @@
 
       this._element = statDL;
       return this._element;
-    },
-
+    }
   }
 
 });
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index 8b05787..0705033 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -1,31 +1,34 @@
 /**
  * Add string values to the virtual corpus
  */
+"use strict";
+
 define(['util'], {
 
   /**
    * Create new string value helper.
    */
   create : function () {
-    var regexOp = true;
-    var regex = false;
-    var value = '';
+    const a = arguments;
+    let regexOp = true,
+        regex = false,
+        value = '';
 
     // Set value
-    if (arguments.length >= 1) {
-      if (arguments[0] !== undefined)
-        value = arguments[0];
+    if (a.length >= 1) {
+      if (a[0] !== undefined)
+        value = a[0];
     };
 
     // Set regex
-    if (arguments.length >= 2) {
-      if (arguments[1] !== undefined)
-        regex = arguments[1];
+    if (a.length >= 2) {
+      if (a[1] !== undefined)
+        regex = a[1];
     };
 
     // Set regexOp
-    if (arguments.length >= 3) {
-      regexOp = arguments[2];
+    if (a.length >= 3) {
+      regexOp = a[2];
       if (regexOp === false) {
         regex = false;
       }
@@ -50,41 +53,31 @@
    */
   regex : function (bool) {
     if (arguments.length === 1) {
-      if (bool) {
-	      this._regex = true;
-      }
-      else {
-	      this._regex = false;
-      };
+	    this._regex = bool ? true : false;
       this._update();
     };
     return this._regex;
   },
 
+
   _regexOp : function (regexOp) {
     if (arguments.length === 1) {
-      if (regexOp) {
-        this.__regexOp = true;
-      }
-      else {
-        this.__regexOp = false;
-      };
+      this.__regexOp = regexOp ? true : false;
       this._update();
     };
     return this.__regexOp;
   },
 
+
   /**
    * Toggle the regex, make it either true,
    * if it is false, or make it false, if it is true.
    */
   toggleRegex : function () {
-    if (this._regex === false)
-      this.regex(true);
-    else
-      this.regex(false);
+    this.regex(this._regex === false ? true : false);
   },
   
+
   /**
    * Get or set the string value.
    */
@@ -97,6 +90,7 @@
     return this._value;
   },
 
+
   // Update dom element
   _update : function () {
     if (this._element === undefined)
@@ -104,11 +98,13 @@
  
     this._value = this._input.value;
 
+    const cl = this._element.classList;
+
     if (this._regexOp() && this._regex) {
-      this._element.classList.add('regex');
+      cl.add('regex');
     }
     else {
-      this._element.classList.remove('regex');
+      cl.remove('regex');
     };
   },
   
@@ -120,6 +116,7 @@
    */
   store : function (v,r) {},
 
+
   /**
    * Put focus on element
    */
@@ -127,6 +124,7 @@
     this._element.children[0].focus();
   },
 
+
   /**
    * Get the associated dom element.
    */
@@ -135,12 +133,11 @@
       return this._element;
 
     // Create element
-    this._element = document.createElement('div');
-    var e = this._element;
+    const e = this._element = document.createElement('div');
     e.setAttribute('tabindex', 0);
     e.style.outline = 0;
 
-    var cl = e.classList;
+    const cl = e.classList;
     cl.add('value');
     if (this.regex() === true)
       cl.add('regex');
@@ -154,10 +151,10 @@
 
     // Add regex button
     if (this._regexOp()) {
-      var re = e.addE('div');
+      const re = e.addE('div');
       re.addEventListener(
         'click',
-        function (ev) {
+        function () {
 	        this.toggleRegex();
           // ev.halt();
         }.bind(this),
@@ -170,10 +167,11 @@
     // delegate focus to
     this._input.addEventListener(
       'blur',
-      function (ev) {        
-        if (!this._inField) {
-	        this.value(this._input.value);
-          this.store(this.value(), this.regex());
+      function () {
+        const t = this;
+        if (!t._inField) {
+	        t.value(t._input.value);
+          t.store(t.value(), t.regex());
         };
         ev.halt();
       }.bind(this)
@@ -182,14 +180,14 @@
     // Workaround to check the click is in the field
     e.addEventListener(
       'mousedown',
-      function (ev) {
+      function () {
         this._inField = true;
       }.bind(this)
     );
 
     e.addEventListener(
       'mouseup',
-      function (ev) {
+      function () {
         this._inField = false;
         this._input.focus();
       }.bind(this)
@@ -198,9 +196,10 @@
     this._input.addEventListener(
       'keypress',
       function (ev) {
+        const t = this;
 	      if (ev.keyCode == 13) {
-	        this.value(this._input.value);
-	        this.store(this.value(), this.regex());
+	        t.value(t._input.value);
+	        t.store(t.value(), t.regex());
           return false;
 	      };
       }.bind(this)
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 4ffe507..fe089a3 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -2,6 +2,8 @@
  * An unspecified criterion in a virtual corpus.
  * Inherits everything from jsonld
  */
+"use strict";
+
 define([
   'vc/jsonld',
   'vc/doc',
@@ -10,7 +12,7 @@
 ], function (jsonldClass, docClass, docGroupRefClass) {
 
   // Localize empty string
-  var loc = KorAP.Locale;
+  const loc = KorAP.Locale;
   loc.EMPTY = loc.EMPTY || '⋯';
 
   return {
@@ -23,7 +25,7 @@
      * with a link to the parent object
      */
     create : function (parent) {
-      var obj = Object.create(jsonldClass).
+      const obj = Object.create(jsonldClass).
 	        upgradeTo(this);
 
       if (parent !== undefined)
@@ -32,6 +34,7 @@
       return obj;
     },
 
+
     /**
      * Set the key; this will spawn a new doc
      */
@@ -41,8 +44,8 @@
       if (this._parent === undefined)
 	      return null;
 
-      var newDoc;
-      var keyType = KorAP._vcKeyMenu.typeOf(v);
+      let newDoc;
+      const keyType = KorAP._vcKeyMenu.typeOf(v);
 
       // Set JSON-LD type
       if (keyType && keyType === 'ref') {
@@ -73,39 +76,39 @@
      * Update the element
      */
     update : function () {
+      const t = this;
 
-      if (this._element === undefined)
-	      return this.element();
+      if (t._element === undefined)
+	      return t.element();
 
       // Remove element content
-       _removeChildren(this._element);
+      _removeChildren(t._element);
 
-      var ellipsis = document.createElement('span');
+      const ellipsis = document.createElement('span');
       ellipsis.addT(loc.EMPTY);
 
       // Click on empty criterion
-      ellipsis.addEventListener('click', this.onclick.bind(this));
+      ellipsis.addEventListener('click', t.onclick.bind(t));
 
-      this._element.appendChild(ellipsis);
+      t._element.appendChild(ellipsis);
 
       // Set ref - TODO: Cleanup!
-      this._element.refTo = this;
+      t._element.refTo = t;
 
       // Set operators
-      if (this._parent !== undefined &&
-          this.parent().ldType() !== null) {
-	      var op = this.operators(
-	        false,
-	        false,
-	        true
-	      );
-	      
-	      this._element.appendChild(
-	        op.element()
+      if (t._parent !== undefined &&
+          t.parent().ldType() !== null) {
+
+	      t._element.appendChild(
+	        t.operators(
+	          false,
+	          false,
+	          true
+	        ).element()
 	      );
       };
 
-      return this.element();
+      return t.element();
     },
 
 
@@ -113,12 +116,13 @@
      * Get the associated element
      */
     element : function () {
-      if (this._element !== undefined)
-	      return this._element;
-      this._element = document.createElement('div');
-      this._element.setAttribute('class', 'doc unspecified');
-      this.update();
-      return this._element;
+      const t = this;
+      if (t._element !== undefined)
+	      return t._element;
+      t._element = document.createElement('div');
+      t._element.setAttribute('class', 'doc unspecified');
+      t.update();
+      return t._element;
     },
 
 
@@ -126,13 +130,14 @@
       return true;
     },
     
+
     /**
      * Click on the unspecified object
      */
     onclick : function () {
 
       // Get the key menu
-      var menu = KorAP._vcKeyMenu;
+      const menu = KorAP._vcKeyMenu;
 
       // Add key menu element at the correct position
       this._element.insertBefore(
@@ -140,7 +145,7 @@
 	      this._element.firstChild
       );
 
-      var that = this;
+      const that = this;
 
       // Set released method
       menu.released(function (key) {
