diff --git a/dev/demo/vcdemo.js b/dev/demo/vcdemo.js
index 9bb67e2..a3957f3 100644
--- a/dev/demo/vcdemo.js
+++ b/dev/demo/vcdemo.js
@@ -48,6 +48,10 @@
                   "operation" : "operation:injection",
                 }
               ]
+            },
+            {
+              "@type":"koral:docGroupRef",
+              "ref":"@kalamar/myCorpus"
             }
           ]
         }
@@ -122,7 +126,8 @@
       ['title', 'string'],
       ['subTitle', 'string'],
       ['pubDate', 'date'],
-      ['author', 'text']
+      ['author', 'text'],
+      ['@referTo', 'ref']
     ]).fromJson(json);
 
     document.getElementById('vc-view').appendChild(vc.element());
diff --git a/dev/js/runner/all.html b/dev/js/runner/all.html
index 78e2f19..3f0ed33 100644
--- a/dev/js/runner/all.html
+++ b/dev/js/runner/all.html
@@ -44,7 +44,7 @@
         'spec/pluginSpec',
         'spec/queryCreatorSpec',
         'spec/statSpec',
-        //'spec/vcSpec'
+        // 'spec/vcSpec'
       ],
       function () {
         window.onload();
diff --git a/dev/js/spec/vcSpec.js b/dev/js/spec/vcSpec.js
index 7cfdf3a..e9ec76b 100644
--- a/dev/js/spec/vcSpec.js
+++ b/dev/js/spec/vcSpec.js
@@ -8,6 +8,7 @@
   var menuClass =        require('vc/menu');
   var prefixClass =      require('vc/prefix');
   var docGroupClass =    require('vc/docgroup');
+  var docGroupRefClass = require('vc/docgroupref');
   var unspecifiedClass = require('vc/unspecified');
   var operatorsClass =   require('vc/operators');
   var rewriteClass =     require('vc/rewrite');
@@ -553,6 +554,62 @@
     });
   });
 
+  describe('KorAP.DocGroupRef', function () {
+    // Create example factories
+    var docRefFactory = buildFactory(
+      docGroupRefClass,
+      {
+        "@type" : "koral:docGroupRef",
+        "ref" : "@max/myCorpus"
+      }
+    );
+
+    it('should be initializable', function () {
+      var vcRef = docGroupRefClass.create();
+      expect(vcRef.ref()).toBeUndefined();
+    });
+
+    it('should be definable', function () {
+      var vcRef = docGroupRefClass.create();
+      vcRef.ref("@peter/mycorpus");
+      expect(vcRef.ref()).toEqual("@peter/mycorpus");
+      vcRef.ref("@peter/mycorpus2");
+      expect(vcRef.ref()).toEqual("@peter/mycorpus2");
+    });
+
+    it('should deserialize JSON-LD string', function () {
+      var vcRef = docRefFactory.create();
+      expect(vcRef.ref()).toEqual("@max/myCorpus");
+    });
+
+    it('should serialize to JSON-LD', function () {
+      var vcRef = docRefFactory.create();
+      expect(vcRef.toJson()).toEqual(jasmine.objectContaining({
+        "@type" : "koral:docGroupRef",
+        "ref":"@max/myCorpus"
+      }));
+
+      vcRef.ref("@peter/myCorpus2");
+      expect(vcRef.toJson()).toEqual(jasmine.objectContaining({
+        "@type" : "koral:docGroupRef",
+        "ref":"@peter/myCorpus2"
+      }));
+    });
+
+    it('should serialize to a query', function () {
+      var vcRef = docRefFactory.create();
+      expect(vcRef.toQuery()).toEqual(
+        "referTo \"@max/myCorpus\""
+      );
+
+      vcRef.ref("@peter/myCorpus2");
+      expect(vcRef.toQuery()).toEqual(
+        "referTo \"@peter/myCorpus2\""
+      );
+    });
+  });
+
+  
   describe('KorAP.UnspecifiedDoc', function () {
     it('should be initializable', function () {
       var doc = unspecifiedClass.create();
@@ -591,6 +648,9 @@
       var unspec = docGroup.element().children[1];
       expect(unspec.getAttribute('class')).toEqual('doc unspecified');
 
+      // Only unspec and delete
+      expect(unspec.children.length).toEqual(2);
+
       // Removable
       expect(unspec.lastChild.children.length).toEqual(1);
       expect(unspec.lastChild.children[0].getAttribute('class')).toEqual('delete');
@@ -632,11 +692,14 @@
       expect(docGroup.getOperand(1).key()).toEqual("name");
       expect(docGroup.getOperand(1).value()).toBeUndefined();
 
+      expect(docGroup.getOperand(1).element().children.length).toEqual(4);
+
       op = docGroup.getOperand(1).element().lastChild;
       expect(op.getAttribute('class')).toEqual('operators button-group');
       expect(op.children[0].getAttribute('class')).toEqual('and');
       expect(op.children[1].getAttribute('class')).toEqual('or');
       expect(op.children[2].getAttribute('class')).toEqual('delete');
+
       expect(op.children.length).toEqual(3);
 
       docGroup.getOperand(1).value("Pachelbel");
@@ -647,7 +710,7 @@
       // Specified!
       expect(docGroup.toQuery()).toEqual('pubDate in 2014-12-05 | name = "Pachelbel"');
     });
-
+    
     it('should be replaceable on root', function () {
       var vc = vcClass.create();
       expect(vc.toQuery()).toEqual("");
@@ -712,6 +775,70 @@
         "match":"match:eq"
       }));
     });
+
+    
+    it('should be replacable by unspecified', function () {
+      var vc = vcClass.create([
+        ["pubDate", "date"]
+      ]).fromJson({
+        "@type" : "koral:doc",
+        "key":"Titel",
+        "value":"Baum",
+        "match":"match:eq"
+      });
+      expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
+
+      var vcE = vc.element();
+      expect(vcE.firstChild.children.length).toEqual(4);
+
+      // Click to delete
+      vcE.firstChild.lastChild.lastChild.click();
+
+      expect(vcE.firstChild.children.length).toEqual(1);
+
+      expect(vcE.firstChild.textContent).toEqual("⋯");
+      vcE.firstChild.firstChild.click();
+      
+      // Click on pubDate
+      vcE.firstChild.getElementsByTagName("LI")[0].click();
+
+      expect(vcE.firstChild.firstChild.textContent).toEqual("pubDate");
+      expect(vcE.firstChild.children[1].getAttribute("data-type")).toEqual("date");
+
+      expect(vcE.firstChild.children.length).toEqual(4);
+    });
+
+    
+    it('should be replaceable by a docGroupRef', function () {
+      var vc = vcClass.create([
+        ["@referTo", "ref"]
+      ]).fromJson({
+        "@type" : "koral:doc",
+        "key":"Titel",
+        "value":"Baum",
+        "match":"match:eq"
+      });
+
+      expect(vc.toQuery()).toEqual("Titel = \"Baum\"");
+
+      var vcE = vc.element();
+      expect(vcE.firstChild.children.length).toEqual(4);
+
+      // Click to delete
+      vcE.firstChild.lastChild.lastChild.click();
+
+      expect(vcE.firstChild.children.length).toEqual(1);
+
+      expect(vcE.firstChild.textContent).toEqual("⋯");
+      vcE.firstChild.firstChild.click();
+      
+      // Click on @referTo
+      vcE.firstChild.getElementsByTagName("LI")[0].click();
+
+      expect(vcE.firstChild.firstChild.textContent).toEqual("@referTo");
+      expect(vcE.firstChild.children[1].getAttribute("data-type")).toEqual("string");
+      expect(vcE.firstChild.children.length).toEqual(3);
+    });
   });
 
   describe('KorAP.DocGroup element', function () {
@@ -828,6 +955,49 @@
     });
   });
 
+  describe('KorAP.DocGroupRef element', function () {
+    it('should be initializable', function () {
+      var docGroupRef = docGroupRefClass.create(undefined, {
+        "@type" : "koral:docGroupRef",
+        "ref" : "@franz/myVC1"
+      });
+      expect(docGroupRef.ref()).toEqual("@franz/myVC1");
+      var dgrE = docGroupRef.element();
+
+      expect(dgrE.children[0].firstChild.data).toEqual("@referTo");
+      expect(dgrE.children[0].tagName).toEqual("SPAN");
+      expect(dgrE.children[0].classList.contains("key")).toBeTruthy();
+      expect(dgrE.children[0].classList.contains("fixed")).toBeTruthy();
+      expect(dgrE.children[1].firstChild.data).toEqual("@franz/myVC1");
+      expect(dgrE.children[1].tagName).toEqual("SPAN");
+      expect(dgrE.children[1].classList.contains("value")).toBeTruthy();
+      expect(dgrE.children[1].getAttribute("data-type")).toEqual("string");
+    });
+
+    it('should be modifiable on reference', function () {
+      var docGroupRef = docGroupRefClass.create(undefined, {
+        "@type" : "koral:docGroupRef",
+        "ref" : "@franz/myVC1"
+      });
+      var dgrE = docGroupRef.element();
+      expect(docGroupRef.toQuery()).toEqual("referTo \"@franz/myVC1\"");
+      dgrE.children[1].click();
+
+      var input = dgrE.children[1].firstChild;
+      expect(input.tagName).toEqual("INPUT");
+      input.value = "Versuch";
+
+      var event = new KeyboardEvent("keypress", {
+	      "key" : "[Enter]",
+	      "keyCode"  : 13
+      });
+
+      input.dispatchEvent(event);
+      expect(docGroupRef.toQuery()).toEqual("referTo \"Versuch\"");     
+    });    
+  });
+
+  
   describe('KorAP.VirtualCorpus', function () {
     var simpleGroupFactory = buildFactory(docGroupClass, {
       "@type" : "koral:docGroup",
@@ -963,6 +1133,29 @@
       expect(second.matchop()).toEqual('eq');
     });
 
+    it('should be based on a docGroupRef', function () {
+      var vc = vcClass.create().fromJson({
+        "@type" : "koral:docGroupRef",
+        "ref":"myCorpus"
+      });
+
+      // iv class="doc groupref"><span class="key fixed">@referTo</span><span data-type="string" class="value">myCorpus</span>
+      var vcE = vc.element();
+      expect(vcE.getAttribute('class')).toEqual('vc');
+      expect(vcE.firstChild.tagName).toEqual('DIV');
+      expect(vcE.firstChild.classList.contains('groupref')).toBeTruthy();
+
+      expect(vcE.firstChild.firstChild.tagName).toEqual('SPAN');
+      expect(vcE.firstChild.firstChild.classList.contains('key')).toBeTruthy();
+      expect(vcE.firstChild.firstChild.classList.contains('fixed')).toBeTruthy();
+
+      expect(vcE.firstChild.firstChild.textContent).toEqual("@referTo");
+
+      expect(vcE.firstChild.children[1].tagName).toEqual('SPAN');
+      expect(vcE.firstChild.children[1].classList.contains('value')).toBeTruthy();
+      expect(vcE.firstChild.children[1].getAttribute('data-type')).toEqual('string');
+      expect(vcE.firstChild.children[1].textContent).toEqual("myCorpus");
+    });
 
     it('should be based on a nested docGroup', function () {
       var vc = nestedGroupFactory.create();
@@ -978,6 +1171,27 @@
       expect(vc.element().firstChild.children[2].getAttribute('class')).toEqual('operators button-group');
     });    
 
+    it('should be based on a nested docGroupRef', function () {
+      var vc = vcClass.create().fromJson({
+        "@type" : "koral:docGroup",
+        "operation" : "operation:and",
+        "operands" : [{
+          "@type" : "koral:docGroupRef",
+          "ref":"myCorpus"
+        },{
+          "@type" : "koral:doc",
+          "key":"Titel",
+          "value":"Baum",
+          "match":"match:eq"
+        }]
+      });
+
+      expect(vc._root.ldType()).toEqual("docGroup");
+
+      expect(vc.toQuery()).toEqual('referTo "myCorpus" & Titel = "Baum"');
+    });
+
+    
     it('should be modifiable by deletion in flat docGroups', function () {
       var vc = flatGroupFactory.create();
       var docGroup = vc.root();
@@ -1680,34 +1894,53 @@
               "@type" : 'koral:doc',
               'key' : 'foo',
               'value' : 'bar'
+            },
+            {
+              "@type" : "koral:docGroupRef",
+              "ref" : "myCorpus"
             }
           ]
         }
       );
 
-      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar"');
+      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
 
       var fc = vc.element().firstChild;
       expect(fc.getAttribute('data-operation')).toEqual('and');
-      expect(fc.children.length).toEqual(3);
+      expect(fc.children.length).toEqual(4);
       expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
       expect(fc.children[0].getAttribute('class')).toEqual('doc');
       expect(fc.children[1].getAttribute('class')).toEqual('doc');
+      expect(fc.children[2].getAttribute('class')).toEqual('doc groupref');
 
       // add with 'and' in the middle
       _andOn(vc.root().getOperand(0));
-      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar"');
+      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
 
       fc = vc.element().firstChild;
       expect(fc.getAttribute('data-operation')).toEqual('and');
-      expect(fc.children.length).toEqual(4);
+      expect(fc.children.length).toEqual(5);
       expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
 
       expect(fc.children[0].getAttribute('class')).toEqual('doc');
       expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
       expect(fc.children[2].getAttribute('class')).toEqual('doc');
+      expect(fc.children[3].getAttribute('class')).toEqual('doc groupref');
+      expect(fc.children[4].classList.contains('button-group')).toBeTruthy();
+      expect(fc.children.length).toEqual(5);
+
+      _andOn(vc.root().getOperand(3));
+      expect(fc.children[0].getAttribute('class')).toEqual('doc');
+      expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
+      expect(fc.children[2].getAttribute('class')).toEqual('doc');
+      expect(fc.children[3].getAttribute('class')).toEqual('doc groupref');
+      expect(fc.children[4].getAttribute('class')).toEqual('doc unspecified');
+      expect(fc.children[5].classList.contains('button-group')).toBeTruthy();
+      expect(fc.children.length).toEqual(6);
+
     });
 
+
     it('should add new unspecified doc with "or"', function () {
       var vc = vcClass.create().fromJson(
         {
@@ -1725,30 +1958,36 @@
               "@type" : 'koral:doc',
               'key' : 'foo',
               'value' : 'bar'
+            },
+            {
+              "@type" : "koral:docGroupRef",
+              "ref" : "myCorpus"
             }
           ]
         }
       );
 
-      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar"');
+      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
 
       var fc = vc.element().firstChild;
-      expect(fc.children.length).toEqual(3);
+      expect(fc.children.length).toEqual(4);
       expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
       expect(fc.children[0].getAttribute('class')).toEqual('doc');
       expect(fc.children[1].getAttribute('class')).toEqual('doc');
+      expect(fc.children[2].getAttribute('class')).toEqual('doc groupref');
 
       // add with 'or' in the middle
       _orOn(vc.root().getOperand(0));
-      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar"');
+      expect(vc.toQuery()).toEqual('pubDate in 2014-12-05 & foo = "bar" & referTo "myCorpus"');
       fc = vc.element().firstChild;
 
       expect(fc.getAttribute('data-operation')).toEqual('and');
-      expect(fc.children.length).toEqual(3);
+      expect(fc.children.length).toEqual(4);
       expect(fc.children[0].getAttribute('class')).toEqual('docGroup');
       expect(fc.children[0].getAttribute('data-operation')).toEqual('or');
       expect(fc.children[1].getAttribute('class')).toEqual('doc');
-      expect(fc.children[2].getAttribute('class')).toEqual('operators button-group');
+      expect(fc.children[2].getAttribute('class')).toEqual('doc groupref');
+      expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
       expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
 
       fc = vc.element().firstChild.firstChild;
@@ -1757,6 +1996,22 @@
       expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
       expect(fc.children[2].getAttribute('class')).toEqual('operators button-group');
       expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
+
+      _orOn(vc.root().getOperand(2));
+      fc = vc.element().firstChild;
+      expect(fc.children.length).toEqual(4);
+
+      expect(fc.children[0].getAttribute('class')).toEqual('docGroup');
+      expect(fc.children[1].getAttribute('class')).toEqual('doc');
+      expect(fc.children[2].getAttribute('class')).toEqual('docGroup');
+      expect(fc.children[3].getAttribute('class')).toEqual('operators button-group');
+
+      fc = vc.element().firstChild.children[2];
+      expect(fc.children[0].getAttribute('class')).toEqual('doc groupref');
+      expect(fc.children[1].getAttribute('class')).toEqual('doc unspecified');
+      expect(fc.children[2].getAttribute('class')).toEqual('operators button-group');
+      expect(fc.lastChild.getAttribute('class')).toEqual('operators button-group');
+
     });
 
     it('should add new unspecified doc with "and" before group', function () {
@@ -2278,6 +2533,16 @@
       sv.element().lastChild.click();
     });
 
+    it('should have a disableoption for regex', function () {
+      var sv = stringValClass.create(undefined, undefined, true);
+      var svE = sv.element();
+      expect(svE.children.length).toEqual(2);
+
+      sv = stringValClass.create(undefined, undefined, false);
+      svE = sv.element();
+      expect(svE.children.length).toEqual(1);
+    });
+
   });
 
   describe('KorAP.VC.Menu', function () {
diff --git a/dev/js/src/vc.js b/dev/js/src/vc.js
index 082ede0..b0ebc44 100644
--- a/dev/js/src/vc.js
+++ b/dev/js/src/vc.js
@@ -44,299 +44,326 @@
    and various field names with the prefix 'VC_'
  */
 
-define([ 'vc/unspecified', 'vc/doc', 'vc/docgroup', 'vc/menu', 'vc/statistic',
-    'datepicker', 'buttongroup', 'panel', 'view/corpstatv', 'util', ],
-    function(unspecDocClass, docClass, docGroupClass, menuClass, statClass,
-        dpClass, buttonGrClass, panelClass, corpStatVClass) {
-      "use strict";
+define([
+  'vc/unspecified',
+  'vc/doc',
+  'vc/docgroup',
+  'vc/docgroupref',
+  'vc/menu',
+  'vc/statistic',
+  'datepicker',
+  'buttongroup',
+  'panel',
+  'view/corpstatv',
+  'util'
+], function(
+  unspecDocClass,
+  docClass,
+  docGroupClass,
+  docGroupRefClass,
+  menuClass,
+  statClass,
+  dpClass,
+  buttonGrClass,
+  panelClass,
+  corpStatVClass) {
+  "use strict";
 
-      KorAP._validUnspecMatchRE = new RegExp(
-          "^(?:eq|ne|contains(?:not)?|excludes)$");
-      KorAP._validStringMatchRE = new RegExp("^(?:eq|ne)$");
-      KorAP._validTextMatchRE = KorAP._validUnspecMatchRE;
-      KorAP._validTextOnlyMatchRE = new RegExp(
-          "^(?:contains(?:not)?|excludes)$");
-      KorAP._overrideStyles = false;
-      // KorAP._validDateMatchRE is defined in datepicker.js!
+  KorAP._validUnspecMatchRE = new RegExp(
+    "^(?:eq|ne|contains(?:not)?|excludes)$");
+  KorAP._validStringMatchRE = new RegExp("^(?:eq|ne)$");
+  KorAP._validTextMatchRE = KorAP._validUnspecMatchRE;
+  KorAP._validTextOnlyMatchRE = new RegExp(
+    "^(?:contains(?:not)?|excludes)$");
+  KorAP._overrideStyles = false;
+  // KorAP._validDateMatchRE is defined in datepicker.js!
 
-      const loc = KorAP.Locale;
-      loc.SHOW_STAT = loc.SHOW_STAT || 'Statistics';
-      loc.VERB_SHOWSTAT = loc.VERB_SHOWSTAT || 'Corpus Statistics';
+  const loc = KorAP.Locale;
+  loc.SHOW_STAT = loc.SHOW_STAT || 'Statistics';
+  loc.VERB_SHOWSTAT = loc.VERB_SHOWSTAT || 'Corpus Statistics';
 
-      KorAP._vcKeyMenu = undefined;
-      KorAP._vcDatePicker = dpClass.create();
+  KorAP._vcKeyMenu = undefined;
+  KorAP._vcDatePicker = dpClass.create();
 
-      // Create match menus ....
-      KorAP._vcMatchopMenu = {
-        'string' : menuClass.create([ [ 'eq', null ], [ 'ne', null ] ]),
-        'text' : menuClass.create([ [ 'eq', null ], // Requires exact match
-        [ 'ne', null ], [ 'contains', null ], // Requires token sequence match
-        [ 'containsnot', null ] ]),
-        'date' : menuClass.create([ [ 'eq', null ], [ 'ne', null ],
-            [ 'geq', null ], [ 'leq', null ] ]),
-        'regex' : menuClass.create([ [ 'eq', null ], [ 'ne', null ] ])
+  // Create match menus ....
+  KorAP._vcMatchopMenu = {
+    'string' : menuClass.create([
+      [ 'eq', null ],
+      [ 'ne', null ]
+    ]),
+    'text' : menuClass.create([
+      [ 'eq', null ], // Requires exact match
+      [ 'ne', null ],
+      [ 'contains', null ], // Requires token sequence match
+      [ 'containsnot', null ]
+    ]),
+    'date' : menuClass.create([
+      [ 'eq', null ],
+      [ 'ne', null ],
+      [ 'geq', null ],
+      [ 'leq', null ]
+    ]),
+    'regex' : menuClass.create([
+      [ 'eq', null ],
+      [ 'ne', null ]
+    ])
+  };
+
+  /**
+   * Virtual Collection
+   */
+  return {
+
+    /**
+     * The JSON-LD type of the virtual collection
+     */
+    ldType : function() {
+      return null;
+    },
+
+    // Initialize virtual collection
+    _init : function(keyList) {
+
+      // Inject localized css styles
+      if (!KorAP._overrideStyles) {
+        var sheet = KorAP.newStyleSheet();
+
+        // Add css rule for OR operations
+        sheet.insertRule('.vc .docGroup[data-operation=or] > .doc::before,'
+                         + '.vc .docGroup[data-operation=or] > .docGroup::before '
+                         + '{ content: "' + loc.OR + '" }', 0);
+
+        // Add css rule for AND operations
+        sheet.insertRule(
+          '.vc .docGroup[data-operation=and] > .doc::before,'
+            + '.vc .docGroup[data-operation=and] > .docGroup::before '
+            + '{ content: "' + loc.AND + '" }', 1);
+
+        KorAP._overrideStyles = true;
       };
 
-      /**
-       * Virtual Collection
-       */
-      return {
+      // Create key menu
+      KorAP._vcKeyMenu = menuClass.create(keyList);
+      KorAP._vcKeyMenu.limit(6);
 
-        /**
-         * The JSON-LD type of the virtual collection
-         */
-        ldType : function() {
-          return null;
-        },
+      return this;
+    },
 
-        // Initialize virtual collection
-        _init : function(keyList) {
+    /**
+     * Create a new virtual collection.
+     */
+    create : function(keyList) {
+      var obj = Object.create(this)._init(keyList);
+      obj._root = unspecDocClass.create(obj);
+      return obj;
+    },
 
-          // Inject localized css styles
-          if (!KorAP._overrideStyles) {
-            var sheet = KorAP.newStyleSheet();
-
-            // Add css rule for OR operations
-            sheet.insertRule('.vc .docGroup[data-operation=or] > .doc::before,'
-                + '.vc .docGroup[data-operation=or] > .docGroup::before '
-                + '{ content: "' + loc.OR + '" }', 0);
-
-            // Add css rule for AND operations
-            sheet.insertRule(
-                '.vc .docGroup[data-operation=and] > .doc::before,'
-                    + '.vc .docGroup[data-operation=and] > .docGroup::before '
-                    + '{ content: "' + loc.AND + '" }', 1);
-
-            KorAP._overrideStyles = true;
-          }
-          ;
-
-          // Create key menu
-          KorAP._vcKeyMenu = menuClass.create(keyList);
-          KorAP._vcKeyMenu.limit(6);
-
-          return this;
-        },
-
-        /**
-         * Create a new virtual collection.
-         */
-        create : function(keyList) {
-          var obj = Object.create(this)._init(keyList);
-          obj._root = unspecDocClass.create(obj);
-          return obj;
-        },
-
-        /**
-         * Create and render a new virtual collection based on a KoralQuery
-         * collection document
-         */
-        fromJson : function(json) {
-          if (json !== undefined) {
-            // Parse root document
-            if (json['@type'] == 'koral:doc') {
-              this._root = docClass.create(this, json);
-            }
-            // parse root group
-            else if (json['@type'] == 'koral:docGroup') {
-              this._root = docGroupClass.create(this, json);
-            }
-            // Unknown collection type
-            else {
-              KorAP.log(813, "Collection type is not supported");
-              return;
-            }
-            ;
-          }
-
-          else {
-            // Add unspecified object
-            this._root = unspecDocClass.create(this);
-          }
-          ;
-
-          // Init element and update
-          this.update();
-
-          return this;
-        },
-
-        // Check if the virtual corpus contains a rewrite
-        // This is a class method
-        checkRewrite : function(json) {
-
-          // There is a rewrite attribute
-          if (json['rewrites'] !== undefined) {
-            return true;
-          }
-
-          // There is a group to check for rewrites
-          else if (json['@type'] === 'koral:docGroup') {
-            var ops = json['operands'];
-            if (ops === undefined)
-              return false;
-
-            for ( var i in ops) {
-
-              // "this" is the class
-              if (this.checkRewrite(ops[i])) {
-                return true;
-              }
-              ;
-            }
-            ;
-          }
-          ;
-          return false;
-        },
-
-        /**
-         * Clean the virtual document to uspecified doc.
-         */
-        clean : function() {
-          if (this._root.ldType() !== "non") {
-            this._root.destroy();
-            this.root(unspecDocClass.create(this));
-          }
-          ;
-          return this;
-        },
-
-        /**
-         * Get or set the root object of the virtual collection.
-         */
-        root : function(obj) {
-          if (arguments.length === 1) {
-            var e = this.element();
-
-            if (e.firstChild !== null) {
-              if (e.firstChild !== obj.element()) {
-                e.replaceChild(obj.element(), e.firstChild);
-              }
-              ;
-            }
-
-            // Append root element
-            else {
-              e.appendChild(obj.element());
-            }
-            ;
-
-            // Update parent child relations
-            this._root = obj;
-            obj.parent(this);
-
-            this.update();
-          }
-          ;
-          return this._root;
-        },
-
-        /**
-         * Get the element associated with the virtual collection
-         */
-        element : function() {
-
-          
-          if (this._element !== undefined) {
-            return this._element;
-          }
-          ;
-
-          this._element = document.createElement('div');
-          this._element.setAttribute('class', 'vc');
-
-          // Initialize root
-          this._element.appendChild(this._root.element());
-          
-          /*
-           * TODO by Helge Hack! additional div, because statistic button is
-           * removed after choosing and/or/x in vc builder. REMOVE this lines
-           * after solving the problem!!!!
-           */
-          this._element.addE('div');
-          this._element.addE('div');
-          this._element.addE('div');
-          
-          // Add panel to display corpus statistic, ...
-          this.addVcInfPanel();
-      
-          return this._element;
-        },
-
-        /**
-         * Update the whole object based on the underlying data structure
-         */
-        update : function() {
-          this._root.update();
-          return this;
-        },
-
-        /**
-         * Make the vc persistant by injecting the current timestamp as a
-         * creation date limit criterion.
-         */
-        makePersistant : function() {
-          // this.root().wrapOnRoot('and');
-          var todayStr = KorAP._vcDatePicker.today();
-          var doc = docClass.create();
-          var root = this.root();
-
-          if (root.ldType() === 'docGroup' && root.operation === 'and') {
-            root.append(cond);
-          } else {
-            root.wrapOnRoot('and');
-            root.append(doc);
-          }
-          ;
-
-          doc.key("creationDate");
-          doc.type("date");
-          doc.matchop("leq");
-          doc.value(todayStr);
-
-          /*
-           * { "@type" : "koral:doc", "key" : "creationDate", "type" :
-           * "type:date", "match" : "match:leq", "value" : todayStr }
-           * this.root().append(cond);
-           */
-          this.update();
-        },
-
-        /**
-         * Get the generated json string
-         */
-        toJson : function() {
-          return this._root.toJson();
-        },
-
-        /**
-         * Get the generated query string
-         */
-        toQuery : function() {
-          return this._root.toQuery();
-        },
-
-
-       /*
-        * Add panel to display virtual corpus information
-        */
-        addVcInfPanel : function() {
-
-          var dv = this._element.addE('div');
-          var panel = panelClass.create([ 'vcinfo' ]);
-          dv.appendChild(panel.element());
- 
-          var that = this;
-          var actions = panel.actions;
-          var statView;
-                    
-          actions.add(loc.SHOW_STAT, [ 'statistic' ], function() {
-            if (statView === undefined || !statView.shown()) {
-              statView = corpStatVClass.create(that);
-              panel.add(statView);
-            }
-          });
+    /**
+     * Create and render a new virtual collection based on a KoralQuery
+     * collection document
+     */
+    fromJson : function(json) {
+      if (json !== undefined) {
+        // Parse root document
+        if (json['@type'] == 'koral:doc') {
+          this._root = docClass.create(this, json);
         }
+        // parse root group
+        else if (json['@type'] == 'koral:docGroup') {
+          this._root = docGroupClass.create(this, json);
+        }
+
+        // parse root reference
+        else if (json['@type'] == 'koral:docGroupRef') {
+          this._root = docGroupRefClass.create(this, json);
+        }
+        
+        // Unknown collection type
+        else {
+          KorAP.log(813, "Collection type is not supported");
+          return;
+        };
+      }
+
+      else {
+        // Add unspecified object
+        this._root = unspecDocClass.create(this);
       };
-    });
+
+      // Init element and update
+      this.update();
+
+      return this;
+    },
+
+    // Check if the virtual corpus contains a rewrite
+    // This is a class method
+    checkRewrite : function(json) {
+
+      // There is a rewrite attribute
+      if (json['rewrites'] !== undefined) {
+        return true;
+      }
+
+      // There is a group to check for rewrites
+      else if (json['@type'] === 'koral:docGroup') {
+        var ops = json['operands'];
+        if (ops === undefined)
+          return false;
+
+        for ( var i in ops) {
+
+          // "this" is the class
+          if (this.checkRewrite(ops[i])) {
+            return true;
+          };
+        };
+      };
+      return false;
+    },
+
+    /**
+     * Clean the virtual document to uspecified doc.
+     */
+    clean : function() {
+      if (this._root.ldType() !== "non") {
+        this._root.destroy();
+        this.root(unspecDocClass.create(this));
+      };
+      return this;
+    },
+
+    /**
+     * Get or set the root object of the virtual collection.
+     */
+    root : function(obj) {
+      if (arguments.length === 1) {
+        var e = this.element();
+
+        if (e.firstChild !== null) {
+          if (e.firstChild !== obj.element()) {
+            e.replaceChild(obj.element(), e.firstChild);
+          };
+        }
+
+        // Append root element
+        else {
+          e.appendChild(obj.element());
+        };
+
+        // Update parent child relations
+        this._root = obj;
+        obj.parent(this);
+
+        this.update();
+      };
+      return this._root;
+    },
+
+    /**
+     * Get the element associated with the virtual collection
+     */
+    element : function() {
+
+      
+      if (this._element !== undefined) {
+        return this._element;
+      };
+
+      this._element = document.createElement('div');
+      this._element.setAttribute('class', 'vc');
+
+      // Initialize root
+      this._element.appendChild(this._root.element());
+      
+      /*
+       * TODO by Helge Hack! additional div, because statistic button is
+       * removed after choosing and/or/x in vc builder. REMOVE this lines
+       * after solving the problem!!!!
+       */
+      this._element.addE('div');
+      this._element.addE('div');
+      this._element.addE('div');
+      
+      // Add panel to display corpus statistic, ...
+      this.addVcInfPanel();
+      
+      return this._element;
+    },
+
+    /**
+     * Update the whole object based on the underlying data structure
+     */
+    update : function() {
+      this._root.update();
+      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();
+      var doc = docClass.create();
+      var root = this.root();
+
+      if (root.ldType() === 'docGroup' && root.operation === 'and') {
+        root.append(cond);
+      } else {
+        root.wrapOnRoot('and');
+        root.append(doc);
+      };
+
+      doc.key("creationDate");
+      doc.type("date");
+      doc.matchop("leq");
+      doc.value(todayStr);
+
+      /*
+       * { "@type" : "koral:doc", "key" : "creationDate", "type" :
+       * "type:date", "match" : "match:leq", "value" : todayStr }
+       * this.root().append(cond);
+       */
+      this.update();
+    },
+
+    /**
+     * Get the generated json string
+     */
+    toJson : function() {
+      return this._root.toJson();
+    },
+
+    /**
+     * Get the generated query string
+     */
+    toQuery : function() {
+      return this._root.toQuery();
+    },
+
+
+    /*
+     * Add panel to display virtual corpus information
+     */
+    addVcInfPanel : function() {
+
+      var dv = this._element.addE('div');
+      var panel = panelClass.create([ 'vcinfo' ]);
+      dv.appendChild(panel.element());
+      
+      var that = this;
+      var actions = panel.actions;
+      var statView;
+      
+      actions.add(loc.SHOW_STAT, [ 'statistic' ], function() {
+        if (statView === undefined || !statView.shown()) {
+          statView = corpStatVClass.create(that);
+          panel.add(statView);
+        }
+      });
+    }
+  };
+});
diff --git a/dev/js/src/vc/doc.js b/dev/js/src/vc/doc.js
index 15c7287..7c4f98a 100644
--- a/dev/js/src/vc/doc.js
+++ b/dev/js/src/vc/doc.js
@@ -62,77 +62,79 @@
       // Get element
       var e = this._element;
 
+      // Check if there is a change in the underlying data
+      if (!this.__changed)
+        return e;
+
       // Set ref - TODO: Cleanup!
       e.refTo = this;
 
-      // Check if there is a change in the underlying data
-      if (this.__changed) {
 
-        // Was rewritten
-        if (this.rewrites() !== undefined) {
-          e.classList.add("rewritten");
-        };
-
-        // Added key
-        this._keyE = document.createElement('span');
-        this._keyE.setAttribute('class', 'key');
-
-        // Change key
-        this._keyE.addEventListener('click', this._changeKey.bind(this));
-
-        if (this.key()) {
-          var k = this.key();
-          if (loc['VC_' + k] !== undefined)
-            k = loc['VC_' + k];
-          this._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());
-
-        // Change matchop
-        this._matchopE.addEventListener(
-          'click',
-          this._changeMatchop.bind(this)
-        );
-
-        // Added value operator
-        this._valueE = document.createElement('span');
-        this._valueE.setAttribute('data-type', this.type());
-        this._valueE.setAttribute('class', 'value');
-        if (this.value()) {
-          this._valueE.addT(this.value());
-        }
-        else {
-          this._valueE.addT(loc.EMPTY);
-        };
-
-        // Change value
-        this._valueE.addEventListener(
-          'click',
-          this._changeValue.bind(this)
-        );
-
-
-        // Remove all element children
-        _removeChildren(e);
-
-        // Add spans
-        e.appendChild(this._keyE);
-        e.appendChild(this._matchopE);
-        e.appendChild(this._valueE);
-
-        this.__changed = false;
+      // Was rewritten
+      if (this.rewrites() !== undefined) {
+        e.classList.add("rewritten");
       };
 
+      // Added key
+      this._keyE = document.createElement('span');
+      this._keyE.setAttribute('class', 'key');
+
+      // Change key
+      this._keyE.addEventListener('click', this._changeKey.bind(this));
+
+      if (this.key()) {
+        var k = this.key();
+        if (loc['VC_' + k] !== undefined)
+          k = loc['VC_' + k];
+        this._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());
+
+      // Change matchop
+      this._matchopE.addEventListener(
+        'click',
+        this._changeMatchop.bind(this)
+      );
+
+      // Added value operator
+      this._valueE = document.createElement('span');
+      this._valueE.setAttribute('data-type', this.type());
+      this._valueE.setAttribute('class', 'value');
+
+      if (this.value()) {
+        this._valueE.addT(this.value());
+      }
+      else {
+        this._valueE.addT(loc.EMPTY);
+      };
+
+      // Change value
+      this._valueE.addEventListener(
+        'click',
+        this._changeValue.bind(this)
+      );
+
+      // Remove all element children
+      _removeChildren(e);
+
+      // Add spans
+      e.appendChild(this._keyE);
+      e.appendChild(this._matchopE);
+      e.appendChild(this._valueE);
+
+      this.__changed = false;
+
       if (this._rewrites !== undefined) {
         e.appendChild(this._rewrites.element());
       };
 
       if (this._parent !== undefined) {
+        
         // Set operators
         var op = this.operators(
           true,
diff --git a/dev/js/src/vc/docgroup.js b/dev/js/src/vc/docgroup.js
index 58926f2..d3097e9 100644
--- a/dev/js/src/vc/docgroup.js
+++ b/dev/js/src/vc/docgroup.js
@@ -8,10 +8,12 @@
   'vc/jsonld',
   'vc/unspecified',
   'vc/doc',
+  'vc/docgroupref',
   'util'
 ], function (jsonldClass,
-	     unspecClass,
-	     docClass) {
+	           unspecClass,
+	           docClass,
+            docGroupRefClass) {
 
   const _validGroupOpRE = new RegExp("^(?:and|or)$");
 
@@ -41,6 +43,10 @@
 
     // The doc is already set in the group
     _duplicate : function (operand) {
+
+      // TODO:
+      //   Also check for duplicate docGroupRefs!
+      
       if (operand.ldType() !== 'doc')
 	      return null;
 
@@ -73,7 +79,8 @@
 	      // No @type defined
 	      if (operand["ldType"] !== undefined) {
 	        if (operand.ldType() !== 'doc' &&
-	            operand.ldType() !== 'docGroup') {
+	            operand.ldType() !== 'docGroup' &&
+              operand.ldType() !== 'docGroupRef') {
 	          KorAP.log(812, "Operand not supported in document group");
 	          return;
 	        };
@@ -127,6 +134,28 @@
 	      this._operands.push(docGroup);
 	      return docGroup;
 
+      case "koral:docGroupRef":
+      
+        var docGroupRef = docGroupRefClass.create(this, operand);
+      
+        if (docGroupRef === undefined) {
+          return
+        };
+
+        // TODO:
+        //   Currently this doesn't do anything meaningful,
+        //   as duplicate only checks on docs for the moment
+        /*
+	      var dupl = this._duplicate(doc);
+	      if (dupl === null) {
+	        this._operands.push(doc);
+	        return doc;
+	      };
+	      return dupl;
+        */
+	      this._operands.push(docGroupRef);
+        return docGroupRef;
+
       default:
 	      KorAP.log(812, "Operand not supported in document group");
 	      return;
@@ -229,6 +258,7 @@
 	        // Just insert a doc or ...
 	        if (newOp.ldType() === "doc" ||
 	            newOp.ldType() === "non" ||
+              newOp.ldType() === 'docGroupRef' ||
 	            // ... insert a group of a different operation
 	            // (i.e. "and" in "or"/"or" in "and")
 	            newOp.operation() != this.operation()) {
diff --git a/dev/js/src/vc/docgroupref.js b/dev/js/src/vc/docgroupref.js
new file mode 100644
index 0000000..43bb0ca
--- /dev/null
+++ b/dev/js/src/vc/docgroupref.js
@@ -0,0 +1,269 @@
+/**
+ * A reference to another VC.
+ * Inherits everything from jsonld
+ */
+define([
+  'vc/jsonld',
+  'vc/rewritelist',
+  'vc/stringval',
+  'util'
+], function (jsonldClass, rewriteListClass, stringValClass) {
+
+  const loc = KorAP.Locale;
+  loc.EMPTY = loc.EMPTY || '⋯';
+
+  return {
+
+    // The ld-type
+    _ldType : "docGroupRef",
+
+    /**
+     * Create new unspecified criterion
+     * with a link to the parent object
+     */
+    create : function (parent, json) {
+      var 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;
+    },
+
+
+    /**
+     * Update the element
+     */
+    update : function () {
+      if (this._element === undefined)
+        return this.element();
+
+      var e = this._element;
+
+      // Check if there is a change in the underlying data
+      if (!this.__changed)
+        return e;
+
+      // Set ref - TODO: Cleanup!
+      e.refTo = this;
+
+      // Was rewritten
+      if (this.rewrites() !== undefined) {
+        e.classList.add("rewritten");
+      };
+
+      var refTitle = document.createElement('span');
+      refTitle.classList.add('key','fixed');
+      refTitle.addT('@referTo');
+
+      // Added value operator
+      this._refE = document.createElement('span');
+      this._refE.setAttribute('data-type', "string");
+      this._refE.setAttribute('class', 'value');
+      if (this.ref()) {
+        this._refE.addT(this.ref());
+      }
+      else {
+        this._refE.addT(loc.EMPTY);
+      };
+
+      // Change value
+      this._refE.addEventListener(
+        'click',
+        this._changeRef.bind(this)
+      );
+
+      // Remove all element children
+      _removeChildren(e);
+
+      // Add spans
+      e.appendChild(refTitle);
+      e.appendChild(this._refE);
+
+      this.__changed = false;
+
+      if (this._rewrites !== undefined) {
+        e.appendChild(this._rewrites.element());
+      };
+
+      if (this._parent !== undefined) {
+        // Set operators
+        var op = this.operators(
+          true,
+          true,
+          true
+        );
+
+        // Append new operators
+        e.appendChild(op.element());
+      };  
+
+      return this.element();
+    },
+
+
+    /**
+     * Get the associated element
+     */
+    element : function () {
+      if (this._element !== undefined)
+	      return this._element;
+      this._element = document.createElement('div');
+      this._element.setAttribute('class', 'doc groupref');
+      this.update();
+      return this._element;
+    },
+
+
+    /**
+     * Get or set the value
+     */
+    ref : function (ref) {
+      if (arguments.length === 1) {
+        this._ref = ref;
+        this._changed();
+        return this;
+      };
+      return this._ref;
+    },
+
+
+    // 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();
+
+      str.store = function (ref, regex) {
+        that.ref(ref);
+          
+        that._element.removeChild(
+          this._element
+        );
+        that.update();
+      };
+
+      // Insert element
+      this._element.insertBefore(
+        strElem,
+        this._refE
+      );
+
+      str.focus();
+    },
+    
+
+    /**
+     * Wrap a new operation around the doc element.
+     * This is copypasta from doc.js
+     */
+    wrap : function (op) {
+      var parent = this.parent();
+      var group = require('vc/docgroup').create(parent);
+      group.operation(op);
+      group.append(this);
+      group.append();
+      return parent.replaceOperand(this, group).update();
+    },
+
+    /**
+     * Deserialize from json
+     */
+    fromJson : function (json) {
+      if (json === undefined)
+        return this;
+
+      if (json["@type"] === undefined) {
+        KorAP.log(701, "JSON-LD group has no @type attribute");
+        return;
+      };
+
+      if (json["ref"] === undefined ||
+          typeof json["ref"] != 'string') {
+        KorAP.log(821, "Reference is missing");
+        return;
+      };
+
+      this.ref(json["ref"]);
+
+      // Rewrite coming from the server
+      if (json["rewrites"] !== undefined) {
+        this.rewrite(json["rewrites"]);
+      };
+
+      return this;
+    },
+
+
+    /**
+     * Click on the unspecified object
+     */
+    onclick : function () {
+      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') {
+        value = [{
+          "@type" : "koral:rewrite",
+          "operation" : "operation:" + value,
+          "src" : "Kalamar"
+        }];
+      };
+      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
+    // change happened by the user
+    _changed : function () {
+      this.__changed = true;
+
+      if (this._rewrites === undefined)
+        return;
+
+        delete this["_rewrites"];
+
+      if (this._element === undefined)
+        return;
+
+      this._element.classList.remove("rewritten");
+    },
+
+    toJson : function () {
+      if (!this.ref)
+        return {};
+      
+      return {
+        "@type" : "koral:" + this.ldType(),
+        "ref"  : this.ref()
+      };
+    },
+
+    
+    toQuery : function () {
+      if (!this.ref())
+        return "";
+
+      // Build doc string based on key
+      return 'referTo "' + this.ref().quote() + '"';
+    }
+  };
+});
diff --git a/dev/js/src/vc/jsonld.js b/dev/js/src/vc/jsonld.js
index 846d55c..545652b 100644
--- a/dev/js/src/vc/jsonld.js
+++ b/dev/js/src/vc/jsonld.js
@@ -38,12 +38,15 @@
     // acyclic structures!
     // I'm paranoid!
     destroy : function () {
+      
       if (this._ops != undefined) {
 	      this._ops._parent = undefined;
-	      if (this._ops._element !== undefined)
+	      if (this._ops._element !== undefined) {
 	        this._ops._element.refTo = undefined;
+        };
 	      this._ops = undefined;
       };
+
       if (this._element !== undefined)
 	      this._element = undefined;
       
diff --git a/dev/js/src/vc/operators.js b/dev/js/src/vc/operators.js
index 1d4dc94..50605a3 100644
--- a/dev/js/src/vc/operators.js
+++ b/dev/js/src/vc/operators.js
@@ -31,7 +31,7 @@
 	      return obj.wrapOnRoot();
       };
     }
-    else if (obj.ldType() === 'doc') {
+    else if (obj.ldType() === 'doc' || obj.ldType() === 'docGroupRef') {
 
       if (parent.ldType() === null) {
 	      return obj.wrapOnRoot(type);
@@ -71,7 +71,7 @@
 
   return {
     create : function (and, or, del) {
-
+      
       // Inherit from buttonGroupClass
       var op = Object(buttonGroupClass).create(['operators']).upgradeTo(this);
       op.and(and);
diff --git a/dev/js/src/vc/stringval.js b/dev/js/src/vc/stringval.js
index 10daaee..77c6d90 100644
--- a/dev/js/src/vc/stringval.js
+++ b/dev/js/src/vc/stringval.js
@@ -7,24 +7,38 @@
    * Create new string value helper.
    */
   create : function () {
+    var regexOp = true;
     var regex = false;
     var value = '';
-    if (arguments.length == 2) {
-      regex = arguments[1];
-    };
+
+    // Set value
     if (arguments.length >= 1) {
       if (arguments[0] !== undefined)
         value = arguments[0];
     };
-    return Object.create(this)._init(value, regex);
+
+    // Set regex
+    if (arguments.length >= 2) {
+      if (arguments[1] !== undefined)
+        regex = arguments[1];
+    };
+
+    // Set regexOp
+    if (arguments.length >= 3) {
+      regexOp = arguments[2];
+      if (regexOp === false) {
+        regex = false;
+      }
+    };
+    return Object.create(this)._init(value, regex, regexOp);
   },
   
 
   // Initialize the string value
-  _init : function (value, regex) {
-    this.element();
+  _init : function (value, regex, regexOp) {
     this.value(value);
     this.regex(regex);
+    this._regexOp(regexOp);
     return this;
   },
 
@@ -47,6 +61,18 @@
     return this._regex;
   },
 
+  _regexOp : function (regexOp) {
+    if (arguments.length === 1) {
+      if (regexOp) {
+        this.__regexOp = true;
+      }
+      else {
+        this.__regexOp = false;
+      };
+      this._update();
+    };
+    return this.__regexOp;
+  },
 
   /**
    * Toggle the regex, make it either true,
@@ -65,18 +91,20 @@
   value : function (val) {
     if (arguments.length === 1) {
       this._value = val;
-      this._input.value = val;
+      // this._input.value = val;
       this._update();
     };
     return this._value;
   },
 
-
   // Update dom element
   _update : function () {
+    if (this._element === undefined)
+      return;
+ 
     this._value = this._input.value;
 
-    if (this._regex) {
+    if (this._regexOp() && this._regex) {
       this._element.classList.add('regex');
     }
     else {
@@ -92,7 +120,6 @@
    */
   store : function (v,r) {},
 
-
   /**
    * Put focus on element
    */
@@ -126,16 +153,18 @@
     };
 
     // Add regex button
-    var re = e.addE('div');
-    re.addEventListener(
-      'click',
-      function (ev) {
-	      this.toggleRegex();
-        // ev.halt();
-      }.bind(this),
-      true
-    );
-    re.addT('RE');
+    if (this._regexOp()) {
+      var re = e.addE('div');
+      re.addEventListener(
+        'click',
+        function (ev) {
+	        this.toggleRegex();
+          // ev.halt();
+        }.bind(this),
+        true
+      );
+      re.addT('RE');
+    };
 
     // If the focus is not on the text field anymore,
     // delegate focus to
diff --git a/dev/js/src/vc/unspecified.js b/dev/js/src/vc/unspecified.js
index 56d0869..6ffa0e3 100644
--- a/dev/js/src/vc/unspecified.js
+++ b/dev/js/src/vc/unspecified.js
@@ -5,8 +5,9 @@
 define([
   'vc/jsonld',
   'vc/doc',
+  'vc/docgroupref',
   'util'
-], function (jsonldClass, docClass) {
+], function (jsonldClass, docClass, docGroupRefClass) {
 
   // Localize empty string
   var loc = KorAP.Locale;
@@ -40,9 +41,18 @@
       if (this._parent === undefined)
 	      return null;
 
+      var newDoc;
+      var keyType = KorAP._vcKeyMenu.typeOf(v);
+
       // Set JSON-LD type
-      var newDoc = docClass.create(this._parent);
-      newDoc.key(v);
+      if (keyType && keyType === 'ref') {
+        newDoc = docGroupRefClass.create(this._parent);
+      }
+      else {
+        newDoc = docClass.create(this._parent);
+        newDoc.key(v);
+        newDoc.type(keyType);
+      };
   
       // Unspecified document on root
       if (this._parent.ldType() === null) {
@@ -82,7 +92,8 @@
       this._element.refTo = this;
 
       // Set operators
-      if (this._parent !== undefined && this.parent().ldType() !== null) {
+      if (this._parent !== undefined &&
+          this.parent().ldType() !== null) {
 	      var op = this.operators(
 	        false,
 	        false,
@@ -127,9 +138,9 @@
       var that = this;
 
       // Set released method
-      menu.released(function (key, type) {
+      menu.released(function (key) {
 	      // Set chosen key and type - will return a doc
-	      that.key(key).type(type).update();
+	      that.key(key).update();
 	      this.hide();
       });
 
diff --git a/dev/scss/header/vc.scss b/dev/scss/header/vc.scss
index b7b97cd..3b3fd50 100644
--- a/dev/scss/header/vc.scss
+++ b/dev/scss/header/vc.scss
@@ -148,6 +148,8 @@
     > span.key,
     > span.value {
       font-weight: bold;
+    }
+    > span.value {
       &[data-type=regex] {
         font-style: italic;
         &::after,
@@ -157,6 +159,10 @@
       }
     }
 
+    > span.key.fixed {
+      color: $light-green;
+    }
+
     /**
      * All operators on docs
      */
@@ -193,7 +199,7 @@
     }
   }
 
-  .doc > span {
+  .doc > span:not(.fixed) {
     cursor: pointer;
     &:hover {
       // color: $dark-green;
