diff --git a/dev/js/src/api.js b/dev/js/src/api.js
index 8da1934..c03013f 100644
--- a/dev/js/src/api.js
+++ b/dev/js/src/api.js
@@ -23,7 +23,18 @@
     url += '/' + match.docID;
     url += '/' + match.textID;
 */
-    url += '/' + match.textSigle;
+
+    var legacySigle = new RegExp('^([^_]+)_([^\.]+)\.(.+?)$');
+
+    // This is for legacy support
+    var legacy = legacySigle.exec(match.textSigle);
+    if (legacy[0]) {
+      url += '/' + legacy[1] + '/' + legacy[2] + '/' + legacy[3];
+    }
+    else {
+      url += '/' + match.textSigle;
+    }
+    
     url += '/' + match.matchID;
 
     // { spans: true, layer:x, foundry : y}
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 90592ec..4adbfc0 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -27,16 +27,16 @@
   'lib/highlight/highlight.pack',
   'util'
 ], function (matchClass,
-	     hintClass,
-	     vcClass,
-	     tutClass,
-	     domReady,
-	     hintArray,
-	     vcArray,
-	     alertifyClass,
-	     sessionClass,
-	     tagger,
-	     selectMenuClass) {
+             hintClass,
+             vcClass,
+             tutClass,
+             domReady,
+             hintArray,
+             vcArray,
+             alertifyClass,
+             sessionClass,
+             tagger,
+             selectMenuClass) {
 
   // Set hint array for hint helper
   KorAP.hintArray = hintArray;
@@ -55,7 +55,7 @@
     // Use alertify to log errors
     alertifyClass.log(
       (code === 0 ? '' : code + ': ') +
-	msg,
+        msg,
       'error',
       10000
     );
@@ -75,7 +75,7 @@
     if (KorAP.Notifications !== undefined) {
       var n = KorAP.Notifications;
       for (var i = 0; i < n.length; i++) {
-	alertifyClass.log(n[i][1], n[i][0], 10000);
+        alertifyClass.log(n[i][1], n[i][0], 10000);
       };
     };
 
@@ -92,13 +92,13 @@
 
       var currentVC = loc.VC_allCorpora;
       if (KorAP.koralQuery !== undefined && KorAP.koralQuery["collection"]) {
-	currentVC = loc.VC_oneCollection;
+        currentVC = loc.VC_oneCollection;
       };
 
       vcname.appendChild(
-	document.createTextNode(
-	  document.getElementById('collection-name').value || currentVC
-	)
+        document.createTextNode(
+          document.getElementById('collection-name').value || currentVC
+        )
       );
 
       input.parentNode.insertBefore(vcname, input);
@@ -114,28 +114,28 @@
 
     for (i = 0; i < inactiveLi.length; i++) {
       inactiveLi[i].addEventListener('click', function (e) {
-	if (this._match !== undefined)
-	  this._match.open();
-	else {
-	  // lazyLoad
-	  matchClass.create(this).open();
-	};
-	e.halt();
+        if (this._match !== undefined)
+          this._match.open();
+        else {
+          // lazyLoad
+          matchClass.create(this).open();
+        };
+        e.halt();
       });
       inactiveLi[i].addEventListener('keydown', function (e) {
-	var code = _codeFromEvent(e);
-	
-	switch (code) {
-	case 32:
-	  if (this._match !== undefined)
-	    this._match.toggle();
-	  else {
-	    // lazyLoad
-	    matchClass.create(this).open();
-	  };
-	  e.halt();
-	  break;
-	};
+        var code = _codeFromEvent(e);
+        
+        switch (code) {
+        case 32:
+          if (this._match !== undefined)
+            this._match.toggle();
+          else {
+            // lazyLoad
+            matchClass.create(this).open();
+          };
+          e.halt();
+          break;
+        };
       });
     };
 
@@ -158,66 +158,66 @@
     if (KorAP.koralQuery !== undefined) {
 
       if (resultButton !== null) {
-	var kq;
-      	var toggle = document.createElement('a');
-	toggle.setAttribute('title', loc.SHOW_KQ)
-	toggle.classList.add('show-kq', 'button');
-	toggle.appendChild(document.createElement('span'))
-	  .appendChild(document.createTextNode(loc.SHOW_KQ));
-	resultButton.appendChild(toggle);
+        var kq;
+        var toggle = document.createElement('a');
+        toggle.setAttribute('title', loc.SHOW_KQ)
+        toggle.classList.add('show-kq', 'button');
+        toggle.appendChild(document.createElement('span'))
+          .appendChild(document.createTextNode(loc.SHOW_KQ));
+        resultButton.appendChild(toggle);
 
-	var showKQ = function () {
-	  if (kq === undefined) {
-	    kq = document.createElement('div');
-	    kq.setAttribute('id', 'koralquery');
-	    kq.style.display = 'none';
-	    var kqInner = document.createElement('div');
-	    kq.appendChild(kqInner);
-	    kqInner.innerHTML = JSON.stringify(KorAP.koralQuery, null, '  ');
-	    hljs.highlightBlock(kqInner);
-	    var sb = document.getElementById('search');
-	    sb.insertBefore(kq, sb.firstChild);
-	  };
+        var showKQ = function () {
+          if (kq === undefined) {
+            kq = document.createElement('div');
+            kq.setAttribute('id', 'koralquery');
+            kq.style.display = 'none';
+            var kqInner = document.createElement('div');
+            kq.appendChild(kqInner);
+            kqInner.innerHTML = JSON.stringify(KorAP.koralQuery, null, '  ');
+            hljs.highlightBlock(kqInner);
+            var sb = document.getElementById('search');
+            sb.insertBefore(kq, sb.firstChild);
+          };
 
-	  if (kq.style.display === 'none') {
-	    kq.style.display = 'block';
-	    show['kq'] = true;
-	  }
-	  else {
-	    kq.style.display = 'none';
-	    delete show['kq'];
-	  };
-	};
+          if (kq.style.display === 'none') {
+            kq.style.display = 'block';
+            show['kq'] = true;
+          }
+          else {
+            kq.style.display = 'none';
+            delete show['kq'];
+          };
+        };
 
-	if (toggle !== undefined) {
-      
-	  // Show koralquery
-	  toggle.addEventListener('click', showKQ);
-	};
+        if (toggle !== undefined) {
+          
+          // Show koralquery
+          toggle.addEventListener('click', showKQ);
+        };
       };
 
       if (KorAP.koralQuery["errors"]) {
-	var errors = KorAP.koralQuery["errors"];
-	for (var i in errors) {
+        var errors = KorAP.koralQuery["errors"];
+        for (var i in errors) {
 
-	  // Malformed query
-	  if (errors[i][0] === 302 && errors[i][2]) {
-	    obj.hint = hintClass.create();
-	    obj.hint.alert(errors[i][2], errors[i][1]);
-	    break;
-	  }
+          // Malformed query
+          if (errors[i][0] === 302 && errors[i][2]) {
+            obj.hint = hintClass.create();
+            obj.hint.alert(errors[i][2], errors[i][1]);
+            break;
+          }
 
-	  // no query
-	  else if (errors[i][0] === 301) {
-	    obj.hint = hintClass.create();
-	    obj.hint.alert(0, errors[i][1]);	    
-	  }
-	}
+          // no query
+          else if (errors[i][0] === 301) {
+            obj.hint = hintClass.create();
+            obj.hint.alert(0, errors[i][1]);      
+          }
+        }
       };
 
       // Session has KQ visibility stored
       if (show["kq"])
-	showKQ.apply();
+        showKQ.apply();
     };
 
 
@@ -232,14 +232,14 @@
       var cl = toggle.classList;
       cl.add('align', 'right', 'button');
       toggle.addEventListener(
-	'click',
-	function (e) {
-	  var ol = document.querySelector('#search > ol');
-	  ol.toggleClass("align-left", "align-right");
-	  this.toggleClass("left", "right");
-	});
+        'click',
+        function (e) {
+          var ol = document.querySelector('#search > ol');
+          ol.toggleClass("align-left", "align-right");
+          this.toggleClass("left", "right");
+        });
       toggle.appendChild(document.createElement('span'))
-	.appendChild(document.createTextNode(loc.TOGGLE_ALIGN));
+        .appendChild(document.createTextNode(loc.TOGGLE_ALIGN));
       resultButton.appendChild(toggle);
     };
 
@@ -250,38 +250,38 @@
     if (vcname) {
       var vc;
       var vcclick = function () {
-	var view = document.getElementById('vc-view');
+        var view = document.getElementById('vc-view');
 
-	// The vc is visible
-	if (vcname.classList.contains('active')) {
-	  view.removeChild(vc.element());
-	  vcname.classList.remove('active');
-	  delete show['collection'];
-	}
+        // The vc is visible
+        if (vcname.classList.contains('active')) {
+          view.removeChild(vc.element());
+          vcname.classList.remove('active');
+          delete show['collection'];
+        }
 
-	// The vc is not visible
-	else {
-	  if (vc === undefined)
-	    vc = _getCurrentVC(vcClass, vcArray);
-	  view.appendChild(vc.element());
-	  vcname.classList.add('active');
-	  show['collection'] = true;
-	};
+        // The vc is not visible
+        else {
+          if (vc === undefined)
+            vc = _getCurrentVC(vcClass, vcArray);
+          view.appendChild(vc.element());
+          vcname.classList.add('active');
+          show['collection'] = true;
+        };
       };
       vcname.onclick = vcclick;
       if (show['collection']) {
-	vcclick.apply();
+        vcclick.apply();
       };
     };
 
-  
+    
     /**
      * Init Tutorial view
      */
     if (document.getElementById('view-tutorial')) {
       window.tutorial = tutClass.create(
-	document.getElementById('view-tutorial'),
-	session
+        document.getElementById('view-tutorial'),
+        session
       );
       obj.tutorial = window.tutorial;
     }
@@ -306,30 +306,30 @@
     var form = document.getElementById('searchform');
     if (form !== null) {
       form.addEventListener('submit', function (e) {
-	var qf = document.getElementById('q-field');
+        var qf = document.getElementById('q-field');
 
-	// No query was defined
-	if (qf.value === undefined || qf.value === '') {
-	  qf.focus();
-	  e.halt();
-	  KorAP.log(700, "No query given");
-	  return;
-	};
+        // No query was defined
+        if (qf.value === undefined || qf.value === '') {
+          qf.focus();
+          e.halt();
+          KorAP.log(700, "No query given");
+          return;
+        };
 
-	// Store session information
-	session.set("show", show);
+        // Store session information
+        session.set("show", show);
 
-	// Set Virtual collection 
-	if (vc === undefined) {
-	  vc = _getCurrentVC(vcClass, vcArray);
-	};
+        // Set Virtual collection 
+        if (vc === undefined) {
+          vc = _getCurrentVC(vcClass, vcArray);
+        };
 
-	if (vc !== undefined) {
-	  input.value = vc.toQuery();
-	}
-	else {
-	  delete input['value'];
-	};
+        if (vc !== undefined) {
+          input.value = vc.toQuery();
+        }
+        else {
+          delete input['value'];
+        };
       });
     };
 
diff --git a/dev/js/src/match.js b/dev/js/src/match.js
index 28d2154..6299220 100644
--- a/dev/js/src/match.js
+++ b/dev/js/src/match.js
@@ -47,68 +47,68 @@
 
       // No match defined
       if (arguments.length < 1 ||
-	  match === null ||
-	  match === undefined) {
-	throw new Error('Missing parameters');
+          match === null ||
+          match === undefined) {
+        throw new Error('Missing parameters');
       }
 
       // Match defined as a node
       else if (match instanceof Node) {
-	this._element  = match;
+        this._element  = match;
 
-	// Circular reference !!
-	match["_match"] = this;
+        // Circular reference !!
+        match["_match"] = this;
 
-/*
-	this.corpusID  = match.getAttribute('data-corpus-id'),
-	this.docID     = match.getAttribute('data-doc-id'),
-	this.textID    = match.getAttribute('data-text-id'),
-*/
-	if (match.hasAttribute('data-text-sigle')) {
-	  this.textSigle = match.getAttribute('data-text-sigle')
-	}
-	else {
-	  this.textSigle = match.getAttribute('data-corpus-id') +
-	    '/' +
-	    match.getAttribute('data-doc-id') +
-	    '/' +
-	    match.getAttribute('data-text-id');
-	};
+        /*
+          this.corpusID  = match.getAttribute('data-corpus-id'),
+          this.docID     = match.getAttribute('data-doc-id'),
+          this.textID    = match.getAttribute('data-text-id'),
+        */
+        if (match.hasAttribute('data-text-sigle')) {
+          this.textSigle = match.getAttribute('data-text-sigle')
+        }
+        else {
+          this.textSigle = match.getAttribute('data-corpus-id') +
+            '/' +
+            match.getAttribute('data-doc-id') +
+            '/' +
+            match.getAttribute('data-text-id');
+        };
 
-	this.matchID   = match.getAttribute('data-match-id');
+        this.matchID   = match.getAttribute('data-match-id');
 
-	// List of available annotations
-	this.available = match.getAttribute('data-available-info').split(' ');
+        // List of available annotations
+        this.available = match.getAttribute('data-available-info').split(' ');
       }
 
       // Match as an object
       else {
 
-	// Iterate over allowed match terms
-	for (var i in _matchTerms) {
-	  var term = _matchTerms[i];
-	  this[term] = match[term] !== undefined ? match[term] : undefined;
-	};
+        // Iterate over allowed match terms
+        for (var i in _matchTerms) {
+          var term = _matchTerms[i];
+          this[term] = match[term] !== undefined ? match[term] : undefined;
+        };
       };
       
       this._avail = {
-	tokens : [],
-	spans  : [],
-	rels   : []
+        tokens : [],
+        spans  : [],
+        rels   : []
       };
 
       // Iterate over info layers
       for (var i = 0; i < this.available.length; i++) {
-	var term = this.available[i];
+        var term = this.available[i];
 
-	// Create info layer objects
-	try {
-	  var layer = require('match/infolayer').create(term);
-	  this._avail[layer.type].push(layer);
-	}
-	catch (e) {
-	  continue;
-	};
+        // Create info layer objects
+        try {
+          var layer = require('match/infolayer').create(term);
+          this._avail[layer.type].push(layer);
+        }
+        catch (e) {
+          continue;
+        };
       };
 
       return this;
@@ -149,18 +149,18 @@
 
       // There is an element to open
       if (this._element === undefined || this._element === null)
-	return false;
+        return false;
 
       // The element is already opened
       if (element.classList.contains('active'))
-	return false;
+        return false;
       
       // Add active class to element
       element.classList.add('active');
 
       // Already there
       if (element.classList.contains('action'))
-	return true;
+        return true;
 
       // Create action buttons
       var ul = document.createElement('ul');
@@ -174,14 +174,14 @@
       // Add close button
       var close = document.createElement('li');
       close.appendChild(document.createElement('span'))
-	.appendChild(document.createTextNode(loc.CLOSE));
+        .appendChild(document.createTextNode(loc.CLOSE));
       close.classList.add('close');
       close.setAttribute('title', loc.CLOSE);
       
       // Add info button
       var info = document.createElement('li');
       info.appendChild(document.createElement('span'))
-	.appendChild(document.createTextNode(loc.SHOWINFO));
+        .appendChild(document.createTextNode(loc.SHOWINFO));
       info.classList.add('info');
       info.setAttribute('title', loc.SHOWINFO);
 
@@ -189,14 +189,14 @@
 
       // Close match
       close.addEventListener('click', function (e) {
-	e.halt();
-	that.close()
+        e.halt();
+        that.close()
       });
 
       // Add information, unless it already exists
       info.addEventListener('click', function (e) {
-	e.halt();
-	that.info().toggle();
+        e.halt();
+        that.info().toggle();
       });
 
       ul.appendChild(close);
@@ -208,9 +208,9 @@
     // Todo: Test toggle
     toggle : function () {
       if (this._element.classList.contains('active'))
-	this.close();
+        this.close();
       else
-	this.open();
+        this.open();
     },
 
 
@@ -233,16 +233,16 @@
 
       // Create match info
       if (this._info === undefined)
-	this._info = infoClass.create(this);
+        this._info = infoClass.create(this);
 
       // There is an element to append
       if (this._element === undefined ||
-	  this._element === null)
-	return this._info;
+          this._element === null)
+        return this._info;
       
       // Info is already activated
       if (this._info._element !== undefined)
-	return this._info;
+        return this._info;
 
       return this._info;
     },
