Updated tests with payload type identifiers.

Change-Id: I8278b1f780d327bfe0f0cbb24cbd3857061591d7
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
index 597f322..1a93456 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementSpans.java
@@ -40,10 +40,10 @@
     
 	public static enum PayloadTypeIdentifier {
 		ELEMENT(64), 
-		ELEMENT_WITH_TUI(65), 
-		ELEMENT_WITH_CERTAINTY_VALUE (66), 
-		ELEMENT_WITH_TUI_AND_CERTAINTY_VALUE (67), 
-		MILESTONE (68);
+        // ELEMENT_WITH_TUI(65),
+        // ELEMENT_WITH_CERTAINTY_VALUE (66),
+        // ELEMENT_WITH_TUI_AND_CERTAINTY_VALUE (67),
+        MILESTONE(65);
 		
 		private int value;
 
@@ -136,13 +136,12 @@
 			this.payloadTypeIdentifier = bb.get(0);
 			this.matchEndPosition = bb.getInt(9);
 
-			if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_WITH_TUI.value
-					|| payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT_WITH_TUI_AND_CERTAINTY_VALUE.value) {
+            if (payloadTypeIdentifier == PayloadTypeIdentifier.ELEMENT.value
+                    && length > 15) {
 				this.setSpanId(bb.getShort(14));
 				this.hasSpanId = true;
 			}
             else {
-				// System.out.println(payloadTypeIdentifier);
                 this.setSpanId((short) -1);
             }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
index 9ec7b4d..069d9a5 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
@@ -37,31 +37,31 @@
                 "base",
                 "bcbabd",
 				"[(0-1)s:a|_1$<i>0<i>1|"
-				+ "<>:div$<b>65<i>0<i>2<i>2<b>0<s>2|"
-				+ "<>:div$<b>65<i>0<i>3<i>3<b>0<s>1|"
-				+ "<>:s$<b>65<i>0<i>5<i>5<b>0<s>3|"
-						+ "@:class=header$<b>17<i>3<s>1|@:class=header$<b>17<i>2<s>2]"
+                        + "<>:div$<b>64<i>0<i>2<i>2<b>0<s>2|"
+                        + "<>:div$<b>64<i>0<i>3<i>3<b>0<s>1|"
+                        + "<>:s$<b>64<i>0<i>5<i>5<b>0<s>3|"
+                        + "@:class=header$<b>17<i>3<s>1|@:class=header$<b>17<i>2<s>2]"
 
-						+ "[(1-2)s:e|_2$<i>1<i>2|"
-						+ "<>:a$<b>65<i>1<i>2<i>2<b>0<s>1|@:class=header$<b>17<i>2<s>1]"
+                        + "[(1-2)s:e|_2$<i>1<i>2|"
+                        + "<>:a$<b>64<i>1<i>2<i>2<b>0<s>1|@:class=header$<b>17<i>2<s>1]"
   
 						+ "[(2-3)s:e|_3$<i>2<i>3|"
-						+ "<>:div$<b>65<i>2<i>5<i>5<b>0<s>1|@:class=time$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>2<i>5<i>5<b>0<s>1|@:class=time$<b>17<i>5<s>1]"
   
 						+ "[(3-4)s:a|_4$<i>3<i>4|"
-						+ "<>:div$<b>65<i>3<i>5<i>5<b>0<s>1|@:class=header$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>3<i>5<i>5<b>0<s>1|@:class=header$<b>17<i>5<s>1]"
   
 						+ "[(4-5)s:b|_5$<i>4<i>5|"
-				+ "<>:div$<b>65<i>4<i>5<i>5<b>0<s>1|"
-						+ "<>:a$<b>65<i>4<i>5<i>5<b>0<s>2|@:class=header$<b>17<i>5<s>2]"
+                        + "<>:div$<b>64<i>4<i>5<i>5<b>0<s>1|"
+                        + "<>:a$<b>64<i>4<i>5<i>5<b>0<s>2|@:class=header$<b>17<i>5<s>2]"
 		  
 						+ "[(5-6)s:d|_6$<i>5<i>6|"
-				+ "<>:s$<b>65<i>5<i>6<i>6<b>0<s>1|"
-						+ "<>:div$<b>65<i>5<i>6<i>6<b>0<s>2|@:class=header$<b>17<i>6<s>1]"
+                        + "<>:s$<b>64<i>5<i>6<i>6<b>0<s>1|"
+                        + "<>:div$<b>64<i>5<i>6<i>6<b>0<s>2|@:class=header$<b>17<i>6<s>1]"
   
 						+ "[(6-7)s:d|_7$<i>6<i>7|"
-				+ "<>:div$<b>65<i>6<i>7<i>7<b>0<s>1"
-				+ "<>:s$<b>65<i>6<i>7<i>7<b>0<s>2|"
+                        + "<>:div$<b>64<i>6<i>7<i>7<b>0<s>1"
+                        + "<>:s$<b>64<i>6<i>7<i>7<b>0<s>2|"
 						+ "|@:class=header$<b>17<i>7<s>1|@:class=header$<b>17<i>7<s>2]");
 
         return fd;
@@ -75,25 +75,25 @@
                 "base",
                 "bcbabd",
 				"[(0-1)s:b|_1$<i>0<i>1|"
-						+ "<>:div$<b>65<i>0<i>3<i>3<b>0<s>1|"
-						+ "<>:s<b>65<i>0<i>5<i>5<b>0<s>2|"
+                        + "<>:div$<b>64<i>0<i>3<i>3<b>0<s>1|"
+                        + "<>:s<b>64<i>0<i>5<i>5<b>0<s>2|"
 						+ "@:class=header$<b>17<i>3<s>1|@:class=title$<b>17<i>3<s>1|@:class=book$<b>17<i>3<s>1]"
 						+ "[(1-2)s:c|_2$<i>1<i>2|"
-						+ "<>:div$<b>65<i>1<i>2<i>2<b>0<s>1|"
+                        + "<>:div$<b>64<i>1<i>2<i>2<b>0<s>1|"
 						+ "@:class=header$<b>17<i>2<s>1|@:class=title$<b>17<i>2<s>1]"
 						+ "[(2-3)s:b|_3$<i>2<i>3|"
-						+ "<>:div$<b>65<i>2<i>5<i>5<b>0<s>1|@:class=book$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>2<i>5<i>5<b>0<s>1|@:class=book$<b>17<i>5<s>1]"
 						+ "[(3-4)s:a|_4$<i>3<i>4|"
-						+ "<>:div$<b>65<i>3<i>5<i>5<b>0<s>1|@:class=title$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>3<i>5<i>5<b>0<s>1|@:class=title$<b>17<i>5<s>1]"
 						+ "[(4-5)s:b|_5$<i>4<i>5|"
-						+ "<>:div$<b>65<i>4<i>5<i>5<b>0<s>1|"
+                        + "<>:div$<b>64<i>4<i>5<i>5<b>0<s>1|"
 						+ "@:class=header$<b>17<i>5<s>1|@:class=book$<b>17<i>5<s>1|@:class=title$<b>17<i>5<s>1]"
 						+ "[(5-6)s:d|_6$<i>5<i>6|"
-						+ "<>:div$<b>65<i>5<i>6<i>6<b>0<s>1|@:class=header$<b>17<i>6<s>1]"
-						+ "<>:s$<b>65<i>5<i>6<i>6<b>0<s>2|"
+                        + "<>:div$<b>64<i>5<i>6<i>6<b>0<s>1|@:class=header$<b>17<i>6<s>1]"
+                        + "<>:s$<b>64<i>5<i>6<i>6<b>0<s>2|"
 						+ "[(6-7)s:d|_7$<i>6<i>7|"
-						+ "<>:div$<b>65<i>6<i>7<i>7<b>0<s>1|"
-						+ "<>:s$<b>65<i>6<i>7<i>7<b>0<s>2|"
+                        + "<>:div$<b>64<i>6<i>7<i>7<b>0<s>1|"
+                        + "<>:s$<b>64<i>6<i>7<i>7<b>0<s>2|"
 						+ "@:class=header$<b>17<i>7<s>1|@:class=title$<b>17<i>7<s>1]");
 
         return fd;
@@ -107,25 +107,25 @@
                 "base",
                 "bcbabd",
 				"[(0-1)s:b|_1$<i>0<i>1|"
-						+ "<>:s$<b>65<i>0<i>5<i>5<b>0<s>1|"
-						+ "<>:div$<b>65<i>0<i>3<i>3<b>0<s>2|"
+                        + "<>:s$<b>64<i>0<i>5<i>5<b>0<s>1|"
+                        + "<>:div$<b>64<i>0<i>3<i>3<b>0<s>2|"
 						+ "@:class=header$<b>17<i>3<s>2|@:class=book$<b>17<i>5<s>1|@:class=book$<b>17<i>3<s>2]"
 						+ "[(1-2)s:e|_2$<i>1<i>2|"
-						+ "<>:div$<b>65<i>1<i>2<i>2<b>0<s>1|"
-						+ "<>:a$<b>65<i>1<i>2<i>2<b>0<s>2|@:class=book$<b>17<i>2<s>2|@:class=header$<b>17<i>2<s>1]"
+                        + "<>:div$<b>64<i>1<i>2<i>2<b>0<s>1|"
+                        + "<>:a$<b>64<i>1<i>2<i>2<b>0<s>2|@:class=book$<b>17<i>2<s>2|@:class=header$<b>17<i>2<s>1]"
 						+ "[(2-3)s:b|_3$<i>2<i>3|"
-						+ "<>:div$<b>65<i>2<i>3<i>5<b>0<s>1|"
-						+ "<>:a$<b>65<i>1<i>2<i>2<b>0<s>2|@:class=header$<b>17<i>2<s>2|@:class=book$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>2<i>3<i>5<b>0<s>1|"
+                        + "<>:a$<b>64<i>1<i>2<i>2<b>0<s>2|@:class=header$<b>17<i>2<s>2|@:class=book$<b>17<i>5<s>1]"
 						+ "[(3-4)s:a|_4$<i>3<i>4|"
-						+ "<>:div$<b>65<i>3<i>5<i>5<b>0<s>1|@:class=title$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>3<i>5<i>5<b>0<s>1|@:class=title$<b>17<i>5<s>1]"
 						+ "[(4-5)s:b|_5$<i>4<i>5|"
-						+ "<>:div$<b>65<i>4<i>5<i>5<b>0<s>1|@:class=header$<b>17<i>5<s>1|@:class=book$<b>17<i>5<s>1]"
+                        + "<>:div$<b>64<i>4<i>5<i>5<b>0<s>1|@:class=header$<b>17<i>5<s>1|@:class=book$<b>17<i>5<s>1]"
 						+ "[(5-6)s:d|_6$<i>5<i>6|"
-						+ "<>:s$<b>65<i>5<i>6<i>6<b>0<s>1|"
-						+ "<>:div$<b>65<i>5<i>6<i>6<b>0<s>1|@:class=header$<b>17<i>6<s>1]"
+                        + "<>:s$<b>64<i>5<i>6<i>6<b>0<s>1|"
+                        + "<>:div$<b>64<i>5<i>6<i>6<b>0<s>1|@:class=header$<b>17<i>6<s>1]"
 						+ "[(6-7)s:d|_7$<i>6<i>7|"
-						+ "<>:div$<b>65<i>6<i>7<i>7<b>0<s>1|"
-						+ "<>:s$<b>65<i>6<i>7<i>7<b>0<s>2|"
+                        + "<>:div$<b>64<i>6<i>7<i>7<b>0<s>1|"
+                        + "<>:s$<b>64<i>6<i>7<i>7<b>0<s>2|"
 						+ "@:class=header$<b>17<i>7<s>1|@:class=book$<b>17<i>7<s>2]");
 
         return fd;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
index 70900f2..72af862 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
@@ -12,11 +12,11 @@
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.DistanceConstraint;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanSegmentQuery;
+import de.ids_mannheim.korap.response.Result;
 
 @RunWith(JUnit4.class)
 public class TestDistanceIndex {
@@ -27,9 +27,10 @@
     private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "text", "[(0-1)s:b|s:c|_1#0-1]" + "[(1-2)s:b|_2#1-2]"
-                + "[(2-3)s:c|_3#2-3]" + "[(3-4)s:c|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5]" + "[(5-6)s:d|_6#5-6]");
+        fd.addTV("base", "text", "[(0-1)s:b|s:c|_1$<i>0<i>1]"
+                + "[(1-2)s:b|_2$<i>1<i>2]" + "[(2-3)s:c|_3$<i>2<i>3]"
+                + "[(3-4)s:c|_4$<i>3<i>4]" + "[(4-5)s:d|_5$<i>4<i>5]"
+                + "[(5-6)s:d|_6$<i>5<i>6]");
         return fd;
     }
 
@@ -37,13 +38,16 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "text", "[(0-1)s:c|_1#0-1]" + "[(1-2)s:e|_2#1-2]"
-                + "[(2-3)s:c|_3#2-3|<>:y#2-4$<i>4]"
-                + "[(3-4)s:c|_4#3-4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:d|_5#4-5|<>:y#4-6$<i>6]"
-                + "[(5-6)s:c|_6#5-6|<>:y#5-8$<i>8]" + "[(6-7)s:d|_7#6-7]"
-                + "[(7-8)s:e|_8#7-8|<>:x#7-9$<i>9]"
-                + "[(8-9)s:e|_9#8-9|<>:x#8-10$<i>10]" + "[(9-10)s:d|_10#9-10]");
+        fd.addTV("base", "text", "[(0-1)s:c|_1$<i>0<i>1]"
+                + "[(1-2)s:e|_2$<i>1<i>2]"
+                + "[(2-3)s:c|_3$<i>2<i>3|<>:y$<b>64<i>2<i>4<i>4]"
+                + "[(3-4)s:c|_4$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:d|_5$<i>4<i>5|<>:y$<b>64<i>4<i>6<i>6]"
+                + "[(5-6)s:c|_6$<i>5<i>6|<>:y$<b>64<i>5<i>8<i>8]"
+                + "[(6-7)s:d|_7$<i>6<i>7]"
+                + "[(7-8)s:e|_8$<i>7<i>8|<>:x$<b>64<i>7<i>9<i>9]"
+                + "[(8-9)s:e|_9$<i>8<i>9|<>:x$<b>64<i>8<i>10<i>10]"
+                + "[(9-10)s:d|_10$<i>9<i>10]");
         return fd;
     }
 
@@ -51,9 +55,10 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "text", "[(0-1)s:b|_1#0-1]" + "[(1-2)s:b|_2#1-2]"
-                + "[(2-3)s:d|_3#2-3]" + "[(3-4)s:e|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5]" + "[(5-6)s:e|_6#5-6]");
+        fd.addTV("base", "text", "[(0-1)s:b|_1$<i>0<i>1]"
+                + "[(1-2)s:b|_2$<i>1<i>2]" + "[(2-3)s:d|_3$<i>2<i>3]"
+                + "[(3-4)s:e|_4$<i>3<i>4]" + "[(4-5)s:d|_5$<i>4<i>5]"
+                + "[(5-6)s:e|_6$<i>5<i>6]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
index 13309d6..fafb308 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
@@ -10,11 +10,11 @@
 import org.junit.Test;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.DistanceConstraint;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
+import de.ids_mannheim.korap.response.Result;
 
 public class TestElementDistanceExclusionIndex {
 
@@ -36,13 +36,17 @@
     private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "ceccdcdecd", "[(0-1)s:c|_1#0-1|<>:s#0-1$<i>1]"
-                + "[(1-2)s:e|_2#1-2|<>:s#1-2$<i>2]"
-                + "[(2-3)s:c|_3#2-3|<>:s#2-4$<i>4]" + "[(3-4)s:c|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5|<>:s#4-6$<i>6]" + "[(5-6)s:c|_6#5-6]"
-                + "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7]"
-                + "[(7-8)s:e|_8#7-8|<>:s#7-9$<i>9]" + "[(8-9)s:c|_9#8-9]"
-                + "[(9-10)s:d|_10#9-10]");
+        fd.addTV("base", "ceccdcdecd",
+                "[(0-1)s:c|_1$<i>0<i>1|<>:s$<b>64<i>0<i>1<i>1]"
+                        + "[(1-2)s:e|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>2]"
+                        + "[(2-3)s:c|_3$<i>2<i>3|<>:s$<b>64<i>2<i>4<i>4]"
+                        + "[(3-4)s:c|_4$<i>3<i>4]"
+                        + "[(4-5)s:d|_5$<i>4<i>5|<>:s$<b>64<i>4<i>6<i>6]"
+                        + "[(5-6)s:c|_6$<i>5<i>6]"
+                        + "[(6-7)s:d|_7$<i>6<i>7|<>:s$<b>64<i>6<i>7<i>7]"
+                        + "[(7-8)s:e|_8$<i>7<i>8|<>:s$<b>64<i>7<i>9<i>9]"
+                        + "[(8-9)s:c|_9$<i>8<i>9]"
+                        + "[(9-10)s:d|_10$<i>9<i>10]");
         return fd;
     }
 
@@ -50,12 +54,15 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "eedadaeed", "[(0-1)s:e|_1#0-1|<>:s#0-1$<i>1]"
-                + "[(1-2)s:e|_2#1-2|<>:s#1-2$<i>2]"
-                + "[(2-3)s:d|_3#2-3|<>:s#2-4$<i>4]" + "[(3-4)s:a|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5|<>:s#4-7$<i>6]" + "[(5-6)s:a|_6#5-6]"
-                + "[(6-7)s:e|_7#6-7|<>:s#6-7$<i>9]" + "[(7-8)s:e|_8#7-8]"
-                + "[(8-9)s:d|_9#8-9]");
+        fd.addTV("base", "eedadaeed",
+                "[(0-1)s:e|_1$<i>0<i>1|<>:s$<b>64<i>0<i>1<i>1]"
+                        + "[(1-2)s:e|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>2]"
+                        + "[(2-3)s:d|_3$<i>2<i>3|<>:s$<b>64<i>2<i>4<i>4]"
+                        + "[(3-4)s:a|_4$<i>3<i>4]"
+                        + "[(4-5)s:d|_5$<i>4<i>5|<>:s$<b>64<i>4<i>7<i>6]"
+                        + "[(5-6)s:a|_6$<i>5<i>6]"
+                        + "[(6-7)s:e|_7$<i>6<i>7|<>:s$<b>64<i>6<i>7<i>9]"
+                        + "[(7-8)s:e|_8$<i>7<i>8]" + "[(8-9)s:d|_9$<i>8<i>9]");
         return fd;
     }
 
@@ -63,12 +70,16 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-");
-        fd.addTV("base", "dcacacdac", "[(0-1)s:d|_1#0-1|<>:s#0-1$<i>1]"
-                + "[(1-2)s:c|_2#1-2|<>:s#1-2$<i>2]"
-                + "[(2-3)s:a|_3#2-3|<>:s#2-4$<i>4]" + "[(3-4)s:c|_4#3-4]"
-                + "[(4-5)s:a|_5#4-5|<>:s#4-6$<i>6]" + "[(5-6)s:c|_6#5-6]"
-                + "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7]"
-                + "[(7-8)s:a|_8#7-8|<>:s#7-9$<i>9]" + "[(8-9)s:c|_9#8-9]");
+        fd.addTV("base", "dcacacdac",
+                "[(0-1)s:d|_1$<i>0<i>1|<>:s$<b>64<i>0<i>1<i>1]"
+                        + "[(1-2)s:c|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>2]"
+                        + "[(2-3)s:a|_3$<i>2<i>3|<>:s$<b>64<i>2<i>4<i>4]"
+                        + "[(3-4)s:c|_4$<i>3<i>4]"
+                        + "[(4-5)s:a|_5$<i>4<i>5|<>:s$<b>64<i>4<i>6<i>6]"
+                        + "[(5-6)s:c|_6$<i>5<i>6]"
+                        + "[(6-7)s:d|_7$<i>6<i>7|<>:s$<b>64<i>6<i>7<i>7]"
+                        + "[(7-8)s:a|_8$<i>7<i>8|<>:s$<b>64<i>7<i>9<i>9]"
+                        + "[(8-9)s:c|_9$<i>8<i>9]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
index 4ee6b09..447c1b0 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -16,15 +16,14 @@
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.response.Result;
-import de.ids_mannheim.korap.query.QueryBuilder;
 import de.ids_mannheim.korap.query.DistanceConstraint;
+import de.ids_mannheim.korap.query.QueryBuilder;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
+import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.util.QueryException;
 
 @RunWith(JUnit4.class)
@@ -37,11 +36,13 @@
     private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "text", "[(0-1)s:b|s:c|_1#0-1|<>:s#0-1$<i>1]"
-                + "[(1-2)s:b|_2#1-2]" + "[(2-3)s:c|_3#2-3|<>:s#2-3$<i>3]"
-                + "[(3-4)s:b|_4#3-4|<>:s#3-4$<i>4]"
-                + "[(4-5)s:b|_5#4-5|<>:s#4-5$<i>5]" + "[(5-6)s:b|_6#5-6]"
-                + "[(6-7)s:c|_7#6-7]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|s:c|_1$<i>0<i>1|<>:s$<b>64<i>0<i>1<i>1]"
+                        + "[(1-2)s:b|_2$<i>1<i>2]"
+                        + "[(2-3)s:c|_3$<i>2<i>3|<>:s$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:b|_4$<i>3<i>4|<>:s$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:b|_5$<i>4<i>5|<>:s$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:b|_6$<i>5<i>6]" + "[(6-7)s:c|_7$<i>6<i>7]");
         return fd;
     }
 
@@ -49,12 +50,13 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "text", "[(0-1)s:e|_1#0-1|<>:s#0-2$<i>1]"
-                + "[(1-2)s:c|s:b|_2#1-2|<>:s#1-2$<i>2]"
-                + "[(2-3)s:e|_3#2-3|<>:s#2-3$<i>3]"
-                + "[(3-4)s:b|_4#3-4|<>:s#3-4$<i>4]"
-                + "[(4-5)s:d|_5#4-5|<>:s#4-5$<i>5]"
-                + "[(5-6)s:c|_6#5-6|<>:s#5-6$<i>6]");
+        fd.addTV("base", "text",
+                "[(0-1)s:e|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:c|s:b|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>2]"
+                        + "[(2-3)s:e|_3$<i>2<i>3|<>:s$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:b|_4$<i>3<i>4|<>:s$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:d|_5$<i>4<i>5|<>:s$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:c|_6$<i>5<i>6|<>:s$<b>64<i>5<i>6<i>6]");
         return fd;
     }
 
@@ -62,10 +64,13 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "text", "[(0-1)s:b|_1#0-1|<>:p#0-2$<i>1]"
-                + "[(1-2)s:b|_2#1-2]" + "[(2-3)s:b|_3#2-3|<>:p#2-3$<i>3]"
-                + "[(3-4)s:d|_4#3-4|<>:p#3-4$<i>4]"
-                + "[(4-5)s:d|_5#4-5|<>:p#4-5$<i>5]" + "[(5-6)s:d|_6#5-6]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1$<i>0<i>1|<>:p$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:b|_2$<i>1<i>2]"
+                        + "[(2-3)s:b|_3$<i>2<i>3|<>:p$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:d|_4$<i>3<i>4|<>:p$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:d|_5$<i>4<i>5|<>:p$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:d|_6$<i>5<i>6]");
         return fd;
     }
 
@@ -73,10 +78,13 @@
     private FieldDocument createFieldDoc3 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-3");
-        fd.addTV("base", "text", "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>1]"
-                + "[(1-2)s:d|_2#1-2]" + "[(2-3)s:b|_3#2-3|<>:s#2-3$<i>3]"
-                + "[(3-4)s:c|_4#3-4|<>:s#3-4$<i>4]"
-                + "[(4-5)s:d|_5#4-5|<>:s#4-5$<i>5]" + "[(5-6)s:d|_6#5-6]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:d|_2$<i>1<i>2]"
+                        + "[(2-3)s:b|_3$<i>2<i>3|<>:s$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:c|_4$<i>3<i>4|<>:s$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:d|_5$<i>4<i>5|<>:s$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:d|_6$<i>5<i>6]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
index b2ec752..71feb94 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
@@ -1,27 +1,17 @@
 package de.ids_mannheim.korap.index;
 
-import java.util.*;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
 
-import org.apache.lucene.util.Version;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.Bits;
+import java.io.IOException;
 
-import static org.junit.Assert.*;
+import org.apache.lucene.search.spans.SpanQuery;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.SpanElementQuery;
-import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.index.MultiTermTokenStream;
-import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.index.Term;
+import de.ids_mannheim.korap.response.Result;
 
 
 @RunWith(JUnit4.class)
@@ -36,8 +26,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x  y  z  h  i  j  h  i  j  h  i  j  ",
-                "[(0-3)s:x|<>:a#0-3$<i>12]" + "[(3-6)s:y|<>:a#3-6$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-9$<i>6]" + "[(9-12)s:h]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>3<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>6<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>9<i>6]" + "[(9-12)s:h]"
                         + "[(12-15)s:i]" + "[(15-18)s:j]" + "[(18-21)s:h]"
                         + "[(21-24)s:i]" + "[(24-27)s:j]" + "[(27-30)s:h]"
                         + "[(30-33)s:i]" + "[(33-36)s:j]");
@@ -46,8 +37,9 @@
         // <a>x<a>y<a>zcde</a>cde</a>cde</a>cde</a>
         fd = new FieldDocument();
         fd.addTV("base", "x  y  z  c  d  e  c  d  e  c  d  e  ",
-                "[(0-3)s:x|<>:a#0-3$<i>12]" + "[(3-6)s:y|<>:a#3-6$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-9$<i>6]" + "[(9-12)s:c]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>3<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>6<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>9<i>6]" + "[(9-12)s:c]"
                         + "[(12-15)s:d]" + "[(15-18)s:e]" + "[(18-21)s:c]"
                         + "[(21-24)s:d]" + "[(24-27)s:e]" + "[(27-30)s:c]"
                         + "[(30-33)s:d]" + "[(33-36)s:e]");
@@ -89,10 +81,13 @@
         // <a><a><a>h</a>hhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "h  h        i  j   h  i  j  h  i  j  ",
-                "[(0-3)s:h|<>:a#0-27$<i>6|<>:a#0-18$<i>3|<>:a#0-36$<i>9]"
-                        + "[(3-6)s:h]" + "[(12-15)s:i]" + "[(15-18)s:j]"
-                        + "[(18-21)s:h]" + "[(21-24)s:i]" + "[(24-27)s:j]"
-                        + "[(27-30)s:h]" + "[(30-33)s:i]" + "[(33-36)s:j]");
+                "[(0-3)s:h|"
+                + "<>:a$<b>64<i>0<i>18<i>3|" 
+                + "<>:a$<b>64<i>0<i>27<i>6|"
+                + "<>:a$<b>64<i>0<i>36<i>9]" + "[(3-6)s:h]" + "[(12-15)s:i]"
+                + "[(15-18)s:j]" + "[(18-21)s:h]" + "[(21-24)s:i]"
+                + "[(24-27)s:j]" + "[(27-30)s:h]" + "[(30-33)s:i]"
+                + "[(33-36)s:j]");
         ki.addDoc(fd);
 
         // Save documents
@@ -121,15 +116,15 @@
         // <a><a><a>u</a></a></a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "xyz",
-                "[(0-3)s:xyz|<>:a#0-3$<i>0|<>:a#0-3$<i>0|<>:a#0-3$<i>0|<>:b#0-3$<i>0]");
+                "[(0-3)s:xyz|<>:a$<b>64<i>0<i>3<i>0|<>:a$<b>64<i>0<i>3<i>0|<>:a$<b>64<i>0<i>3<i>0|<>:b$<b>64<i>0<i>3<i>0]");
         ki.addDoc(fd);
 
         // <a><b>x<a>y<a>zcde</a>cde</a>cde</b></a>
         fd = new FieldDocument();
         fd.addTV("base", "x  y  z  c  d  e  c  d  e  c  d  e  ",
-                "[(0-3)s:x|<>:a#0-36$<i>12|<>:b#0-36$<i>12]"
-                        + "[(3-6)s:y|<>:a#3-27$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-18$<i>6]" + "[(9-12)s:c]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12|<>:b$<b>64<i>0<i>36<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + "[(9-12)s:c]"
                         + "[(12-15)s:d]" + "[(15-18)s:e]" + "[(18-21)s:c]"
                         + "[(21-24)s:d]" + "[(24-27)s:e]" + "[(27-30)s:c]"
                         + "[(30-33)s:d]" + "[(33-36)s:e]");
@@ -144,9 +139,9 @@
         // <a>x<a><b>y<a>zcde</a>cde</b></a>cde</a>
         fd = new FieldDocument();
         fd.addTV("base", "x  y  z  k  l  m  k  l  m  k  l  m  ",
-                "[(0-3)s:x|<>:a#0-3$<i>12]"
-                        + "[(3-6)s:y|<>:a#3-6$<i>9|<>:b#3-6$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-9$<i>6]" + "[(9-12)s:k]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>3<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>6<i>9|<>:b$<b>64<i>3<i>6<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>9<i>6]" + "[(9-12)s:k]"
                         + "[(12-15)s:l]" + "[(15-18)s:m]" + "[(18-21)s:k]"
                         + "[(21-24)s:l]" + "[(24-27)s:m]" + "[(27-30)s:k]"
                         + "[(30-33)s:l]" + "[(33-36)s:m]");
@@ -155,7 +150,10 @@
         // <a><a><a>h</a>hhij</a>hij</a>hij</a>
         fd = new FieldDocument();
         fd.addTV("base", "h  h        i  j  h  i  j  h  i  j  ",
-                "[(0-3)s:h|<>:a#0-27$<i>6|<>:a#0-18$<i>3|<>:a#0-36$<i>9]"
+                "[(0-3)s:h|" 
+                        + "<>:a$<b>64<i>0<i>18<i>3|" 
+                        + "<>:a$<b>64<i>0<i>27<i>6|" 
+                        + "<>:a$<b>64<i>0<i>36<i>9]"
                         + "[(3-6)s:h]" + "[(12-15)s:i]" + "[(15-18)s:j]"
                         + "[(18-21)s:h]" + "[(21-24)s:i]" + "[(24-27)s:j]"
                         + "[(27-30)s:h]" + "[(30-33)s:i]" + "[(33-36)s:j]");
@@ -216,13 +214,16 @@
         KrillIndex ki = new KrillIndex();
 
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "111111ccc222222fff333333iiijjj", "[(0-3)s:a|_0#0-3]"
-                + "[(3-6)s:b|_1#3-6]" + "[(6-9)s:c|_2#6-9]"
-                + "[(9-12)s:d|_3#9-12|<>:a#9-15$<i>4]"
-                + "[(12-15)s:e|_4#12-15]" + "[(15-18)s:f|_5#15-18]"
-                + "[(18-21)s:g|_6#18-21|<>:a#18-24$<i>8]"
-                + "[(21-24)s:h|_7#21-24]" + "[(24-27)s:i|_8#24-27]"
-                + "[(27-30)s:j|_9#27-30]");
+        fd.addTV("base", "111111ccc222222fff333333iiijjj",
+                "[(0-3)s:a|_0$<i>0<i>3]" + "[(3-6)s:b|_1$<i>3<i>6]"
+                        + "[(6-9)s:c|_2$<i>6<i>9]"
+                        + "[(9-12)s:d|_3$<i>9<i>12|<>:a$<b>64<i>9<i>15<i>4]"
+                        + "[(12-15)s:e|_4$<i>12<i>15]"
+                        + "[(15-18)s:f|_5$<i>15<i>18]"
+                        + "[(18-21)s:g|_6$<i>18<i>21|<>:a$<b>64<i>18<i>24<i>8]"
+                        + "[(21-24)s:h|_7$<i>21<i>24]"
+                        + "[(24-27)s:i|_8$<i>24<i>27]"
+                        + "[(27-30)s:j|_9$<i>27<i>30]");
         ki.addDoc(fd);
 
         // Save documents
@@ -248,13 +249,15 @@
 
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "111111ccc222222fff333333iiijjj",
-                "[(0-3)s:a|_0#0-3|<>:a#0-6$<i>1]" + "[(3-6)s:b|_1#3-6]"
-                        + "[(6-9)s:c|_2#6-9]"
-                        + "[(9-12)s:d|_3#9-12|<>:a#9-15$<i>4]"
-                        + "[(12-15)s:e|_4#12-15]" + "[(15-18)s:f|_5#15-18]"
-                        + "[(18-21)s:g|_6#18-21|<>:a#18-24$<i>8]"
-                        + "[(21-24)s:h|_7#21-24]" + "[(24-27)s:i|_8#24-27]"
-                        + "[(27-30)s:j|_9#27-30]");
+                "[(0-3)s:a|_0$<i>0<i>3|<>:a$<b>64<i>0<i>6<i>1]"
+                        + "[(3-6)s:b|_1$<i>3<i>6]" + "[(6-9)s:c|_2$<i>6<i>9]"
+                        + "[(9-12)s:d|_3$<i>9<i>12|<>:a$<b>64<i>9<i>15<i>4]"
+                        + "[(12-15)s:e|_4$<i>12<i>15]"
+                        + "[(15-18)s:f|_5$<i>15<i>18]"
+                        + "[(18-21)s:g|_6$<i>18<i>21|<>:a$<b>64<i>18<i>24<i>8]"
+                        + "[(21-24)s:h|_7$<i>21<i>24]"
+                        + "[(24-27)s:i|_8$<i>24<i>27]"
+                        + "[(27-30)s:j|_9$<i>27<i>30]");
         ki.addDoc(fd);
 
         // Save documents
@@ -283,57 +286,58 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x  y  z  h  i  j  h  i  j  h  i  j  ",
-                "[(0-3)s:x|_0#0-3|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|_1#3-6|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|_2#6-9|<>:a#6-18$<i>6]" +  // 3
-                        "[(9-12)s:h|_3#9-12]" +   // 4
-                        "[(12-15)s:i|_4#12-15]" +  // 5
-                        "[(15-18)s:j|_5#15-18]" +  // 6
-                        "[(18-21)s:h|_6#18-21]" +  // 7
-                        "[(21-24)s:i|_7#21-24]" +  // 8
-                        "[(24-27)s:j|_8#24-27]" +  // 9
-                        "[(27-30)s:h|_9#27-30]" +  // 10
-                        "[(30-33)s:i|_10#30-33]" +  // 11
-                        "[(33-36)s:j|_11#33-36]");  // 12
+                "[(0-3)s:x|_0$<i>0<i>3|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|_1$<i>3<i>6|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|_2$<i>6<i>9|<>:a$<b>64<i>6<i>18<i>6]" + // 3
+                        "[(9-12)s:h|_3$<i>9<i>12]" + // 4
+                        "[(12-15)s:i|_4$<i>12<i>15]" + // 5
+                        "[(15-18)s:j|_5$<i>15<i>18]" + // 6
+                        "[(18-21)s:h|_6$<i>18<i>21]" + // 7
+                        "[(21-24)s:i|_7$<i>21<i>24]" + // 8
+                        "[(24-27)s:j|_8$<i>24<i>27]" + // 9
+                        "[(27-30)s:h|_9$<i>27<i>30]" + // 10
+                        "[(30-33)s:i|_10$<i>30<i>33]" + // 11
+                        "[(33-36)s:j|_11$<i>33<i>36]"); // 12
         ki.addDoc(fd);
 
         fd = new FieldDocument();
-        fd.addTV("base", "x  y  z  h  ", "[(0-3)s:x|_0#0-3]" +  // 1
-                "[(3-6)s:y|_1#3-6]" +  // 2
-                "[(6-9)s:z|_2#6-9]" +  // 3
-                "[(9-12)s:h|_3#9-12]"); // 4
+        fd.addTV("base", "x  y  z  h  ", "[(0-3)s:x|_0$<i>0<i>3]" + // 1
+                "[(3-6)s:y|_1$<i>3<i>6]" + // 2
+                "[(6-9)s:z|_2$<i>6<i>9]" + // 3
+                "[(9-12)s:h|_3$<i>9<i>12]"); // 4
         ki.addDoc(fd);
 
         // Here is a larger offset than expected
         fd = new FieldDocument();
-        fd.addTV("base", "x  y  z  h  ", "[(0-3)s:x|_0#0-3|<>:a#0-36$<i>12]" +  // 1
-                "[(3-6)s:y|_1#3-6]" +  // 2
-                "[(6-9)s:z|_2#6-9]" +  // 3
-                "[(9-12)s:h|_3#9-12]"); // 4
+        fd.addTV("base", "x  y  z  h  ",
+                "[(0-3)s:x|_0$<i>0<i>3|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|_1$<i>3<i>6]" + // 2
+                        "[(6-9)s:z|_2$<i>6<i>9]" + // 3
+                        "[(9-12)s:h|_3$<i>9<i>12]"); // 4
         ki.addDoc(fd);
 
         // <a>x<a>y<a>zabc</a>abc</a>abc</a>
         fd = new FieldDocument();
         fd.addTV("base", "x  y  z  a  b  c  a  b  c  a  b  c  ",
-                "[(0-3)s:x|_0#0-3|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|_1#3-6|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|_2#6-9|<>:a#6-18$<i>6]" +  // 3
-                        "[(9-12)s:a|_3#9-12]" +   // 4
-                        "[(12-15)s:b|_4#12-15]" +  // 5
-                        "[(15-18)s:c|_5#15-18]" +  // 6
-                        "[(18-21)s:a|_6#18-21]" +  // 7
-                        "[(21-24)s:b|_7#21-24]" +  // 8
-                        "[(24-27)s:c|_8#24-27]" +  // 9
-                        "[(27-30)s:a|_9#27-30]" +  // 10
-                        "[(30-33)s:b|_10#30-33]" +  // 11
-                        "[(33-36)s:c|_11#33-36]");  // 12
+                "[(0-3)s:x|_0$<i>0<i>3|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|_1$<i>3<i>6|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|_2$<i>6<i>9|<>:a$<b>64<i>6<i>18<i>6]" + // 3
+                        "[(9-12)s:a|_3$<i>9<i>12]" + // 4
+                        "[(12-15)s:b|_4$<i>12<i>15]" + // 5
+                        "[(15-18)s:c|_5$<i>15<i>18]" + // 6
+                        "[(18-21)s:a|_6$<i>18<i>21]" + // 7
+                        "[(21-24)s:b|_7$<i>21<i>24]" + // 8
+                        "[(24-27)s:c|_8$<i>24<i>27]" + // 9
+                        "[(27-30)s:a|_9$<i>27<i>30]" + // 10
+                        "[(30-33)s:b|_10$<i>30<i>33]" + // 11
+                        "[(33-36)s:c|_11$<i>33<i>36]"); // 12
         ki.addDoc(fd);
 
         fd = new FieldDocument();
-        fd.addTV("base", "x  y  z  h  ", "[(0-3)s:x|_0#0-3]" +  // 1
-                "[(3-6)s:y|_1#3-6]" +  // 2
-                "[(6-9)s:z|_2#6-9]" +  // 3
-                "[(9-12)s:h|_3#9-12]"); // 4
+        fd.addTV("base", "x  y  z  h  ", "[(0-3)s:x|_0$<i>0<i>3]" + // 1
+                "[(3-6)s:y|_1$<i>3<i>6]" + // 2
+                "[(6-9)s:z|_2$<i>6<i>9]" + // 3
+                "[(9-12)s:h|_3$<i>9<i>12]"); // 4
         ki.addDoc(fd);
 
         // Save documents
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
index 464f4e1..737fabb 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -37,12 +37,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         ki.commit();
@@ -80,12 +80,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         ki.commit();
@@ -229,12 +229,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -300,12 +300,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -332,12 +332,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -383,13 +383,13 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2|<>:s#1-5$<i>5]"
-                + "[(2-3)s:c|i:c|_2#2-3|<>:s#2-7$<i>7]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2|<>:s$<b>64<i>1<i>5<i>5]"
+                + "[(2-3)s:c|i:c|_2$<i>2<i>3|<>:s$<b>64<i>2<i>7<i>7]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -426,42 +426,51 @@
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "abcabcabac",
         // The payload should be ignored
-                "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
+                "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
                         + // |<>:p#0-10<i>9]" +
-                        "[(1-2)s:b|i:b|_1#1-2|<>:s#1-5$<i>5]"
-                        + "[(2-3)s:c|i:c|_2#2-3|<>:s#2-7$<i>7]"
-                        + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                        + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                        + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                        + "[(9-10)s:c|i:c|_9#9-10]");
+                        "[(1-2)s:b|i:b|_1$<i>1<i>2|<>:s$<b>64<i>1<i>5<i>5]"
+                        + "[(2-3)s:c|i:c|_2$<i>2<i>3|<>:s$<b>64<i>2<i>7<i>7]"
+                        + "[(3-4)s:a|i:a|_3$<i>3<i>4]"
+                        + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                        + "[(5-6)s:c|i:c|_5$<i>5<i>6]"
+                        + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                        + "[(7-8)s:b|i:b|_7$<i>7<i>8]"
+                        + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                        + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         fd.addTV("base", "gbcgbcgbgc",
-                "[(0-1)s:g|i:g|_0#0-1|-:t$<i>10|<>:p#0-10$<i>9]"
-                        + "[(1-2)s:b|i:b|_1#1-2|<>:s#1-5$<i>5]"
-                        + "[(2-3)s:c|i:c|_2#2-3|<>:s#2-7$<i>7]"
-                        + "[(3-4)s:g|i:g|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                        + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:g|i:g|_6#6-7]"
-                        + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:g|i:g|_8#8-9]"
-                        + "[(9-10)s:c|i:c|_9#9-10]");
+                "[(0-1)s:g|i:g|_0$<i>0<i>1|-:t$<i>10|<>:p$<b>64<i>0<i>10<i>9]"
+                        + "[(1-2)s:b|i:b|_1$<i>1<i>2|<>:s$<b>64<i>1<i>5<i>5]"
+                        + "[(2-3)s:c|i:c|_2$<i>2<i>3|<>:s$<b>64<i>2<i>7<i>7]"
+                        + "[(3-4)s:g|i:g|_3$<i>3<i>4]"
+                        + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                        + "[(5-6)s:c|i:c|_5$<i>5<i>6]"
+                        + "[(6-7)s:g|i:g|_6$<i>6<i>7]"
+                        + "[(7-8)s:b|i:b|_7$<i>7<i>8]"
+                        + "[(8-9)s:g|i:g|_8$<i>8<i>9]"
+                        + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         fd = new FieldDocument();
-        fd.addTV("base", "gbcgbcgbgc", "[(0-1)s:g|i:g|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:g|i:g|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:g|i:g|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:g|i:g|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "gbcgbcgbgc", "[(0-1)s:g|i:g|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:g|i:g|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:g|i:g|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:g|i:g|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         // contains(<p>, focus(3: contains({2:<s>}, {3:a})))
         fd.addTV("base", "acabcabac",
-                "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10|<>:p#0-9$<i>8]"
-                        + "[(1-2)s:b|i:b|_1#1-2|<>:s#1-5$<i>5]"
-                        + "[(2-3)s:a|i:a|_2#2-3|<>:s#2-7$<i>7]"
-                        + "[(3-4)s:b|i:b|_3#3-4]" + "[(4-5)s:c|i:c|_4#4-5]"
-                        + "[(5-6)s:a|i:a|_5#5-6]" + "[(6-7)s:b|i:b|_6#6-7]"
-                        + "[(7-8)s:a|i:a|_7#7-8]" + "[(8-9)s:c|i:c|_8#8-9]");
+                "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10|<>:p$<b>64<i>0<i>9<i>8]"
+                        + "[(1-2)s:b|i:b|_1$<i>1<i>2|<>:s$<b>64<i>1<i>5<i>5]"
+                        + "[(2-3)s:a|i:a|_2$<i>2<i>3|<>:s$<b>64<i>2<i>7<i>7]"
+                        + "[(3-4)s:b|i:b|_3$<i>3<i>4]"
+                        + "[(4-5)s:c|i:c|_4$<i>4<i>5]"
+                        + "[(5-6)s:a|i:a|_5$<i>5<i>6]"
+                        + "[(6-7)s:b|i:b|_6$<i>6<i>7]"
+                        + "[(7-8)s:a|i:a|_7$<i>7<i>8]"
+                        + "[(8-9)s:c|i:c|_8$<i>8<i>9]");
         ki.addDoc(fd);
         ki.commit();
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
index ee97464..6748c44 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
@@ -1,6 +1,6 @@
 package de.ids_mannheim.korap.index;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -14,12 +14,12 @@
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.DistanceConstraint;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanMultipleDistanceQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
+import de.ids_mannheim.korap.response.Result;
 
 @RunWith(JUnit4.class)
 public class TestMultipleDistanceIndex {
@@ -54,11 +54,11 @@
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
         fd.addTV("base", "text",
-                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                "[(0-1)s:b|_1#0-1|<>:s$<b>64<i>0<i>2<i>2|<>:p$<b>64<i>0<i>4<i>4]"
                         + "[(1-2)s:b|s:c|_2#1-2]"
-                        + "[(2-3)s:c|_3#2-3|<>:s#2-3$<i>4]"
+                        + "[(2-3)s:c|_3#2-3|<>:s$<b>64<i>2<i>3<i>4]"
                         + "[(3-4)s:b|_4#3-4]"
-                        + "[(4-5)s:c|_5#4-5|<>:s#4-6$<i>6|<>:p#4-6$<i>6]"
+                        + "[(4-5)s:c|_5#4-5|<>:s$<b>64<i>4<i>6<i>6|<>:p$<b>64<i>4<i>6<i>6]"
                         + "[(5-6)s:e|_6#5-6]");
         return fd;
     }
@@ -68,11 +68,11 @@
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addTV("base", "text",
-                "[(0-1)s:c|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                "[(0-1)s:c|_1#0-1|<>:s$<b>64<i>0<i>2<i>2|<>:p$<b>64<i>0<i>4<i>4]"
                         + "[(1-2)s:c|s:e|_2#1-2]"
-                        + "[(2-3)s:e|_3#2-3|<>:s#2-3$<i>4]"
+                        + "[(2-3)s:e|_3#2-3|<>:s$<b>64<i>2<i>3<i>4]"
                         + "[(3-4)s:c|_4#3-4]"
-                        + "[(4-5)s:e|_5#4-5|<>:s#4-6$<i>6|<>:p#4-6$<i>6]"
+                        + "[(4-5)s:e|_5#4-5|<>:s$<b>64<i>4<i>6<i>6|<>:p$<b>64<i>4<i>6<i>6]"
                         + "[(5-6)s:c|_6#5-6]");
         return fd;
     }
@@ -82,13 +82,13 @@
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addTV("base", "text",
-                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                "[(0-1)s:b|_1#0-1|<>:s$<b>64<i>0<i>2<i>2|<>:p$<b>64<i>0<i>4<i>4]"
                         + "[(1-2)s:b|s:e|_2#1-2]"
-                        + "[(2-3)s:e|_3#2-3|<>:s#2-3$<i>4]"
+                        + "[(2-3)s:e|_3#2-3|<>:s$<b>64<i>2<i>3<i>4]"
                         + "[(3-4)s:b|s:c|_4#3-4]"
-                        + "[(4-5)s:e|_5#4-5|<>:s#4-6$<i>6|<>:p#4-6$<i>6]"
+                        + "[(4-5)s:e|_5#4-5|<>:s$<b>64<i>4<i>6<i>6|<>:p$<b>64<i>4<i>6<i>6]"
                         + "[(5-6)s:d|_6#5-6]"
-                        + "[(6-7)s:b|_7#6-7|<>:s#6-7$<i>7|<>:p#6-7$<i>7]");
+                        + "[(6-7)s:b|_7#6-7|<>:s$<b>64<i>6<i>7<i>7|<>:p$<b>64<i>6<i>7<i>7]");
         return fd;
     }
 
@@ -97,12 +97,12 @@
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
         fd.addTV("base", "text",
-                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                "[(0-1)s:b|_1#0-1|<>:s$<b>64<i>0<i>2<i>2|<>:p$<b>64<i>0<i>4<i>4]"
                         + "[(1-2)s:b|s:c|_2#1-2]"
-                        + "[(2-3)s:c|_3#2-3|<>:s#2-3$<i>5]"
+                        + "[(2-3)s:c|_3#2-3|<>:s$<b>64<i>2<i>3<i>5]"
                         + "[(3-4)s:b|_4#3-4]" + "[(4-5)s:b|_5#4-5]"
                         + "[(5-6)s:b|_6#5-6]" + // gap
-                        "[(6-7)s:c|_7#6-7|<>:s#6-7$<i>7|<>:p#6-7$<i>7]");
+                        "[(6-7)s:c|_7#6-7|<>:s$<b>64<i>6<i>7<i>7|<>:p$<b>64<i>6<i>7<i>7]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
index ffcaed4..ff985e0 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
@@ -1,38 +1,22 @@
 package de.ids_mannheim.korap.index;
 
-import java.util.*;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
 
-import org.apache.lucene.util.Version;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.Bits;
+import java.io.IOException;
 
-import static org.junit.Assert.*;
-
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.spans.SpanOrQuery;
+import org.apache.lucene.search.spans.SpanQuery;
+import org.apache.lucene.search.spans.SpanTermQuery;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Match;
-import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.response.Result;
-import de.ids_mannheim.korap.query.SpanNextQuery;
-import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.index.MultiTermTokenStream;
-
-import org.apache.lucene.search.spans.SpanOrQuery;
-import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.search.spans.SpanTermQuery;
-
 import de.ids_mannheim.korap.query.SpanElementQuery;
-import de.ids_mannheim.korap.query.SpanSegmentQuery;
-import de.ids_mannheim.korap.query.SpanWithinQuery;
-
+import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper;
-
-import org.apache.lucene.index.Term;
+import de.ids_mannheim.korap.response.Result;
 
 @RunWith(JUnit4.class)
 public class TestNextIndex {
@@ -45,12 +29,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4]" + "[(4-5)s:b|i:b|_4#4-5]"
-                + "[(5-6)s:c|i:c|_5#5-6]" + "[(6-7)s:a|i:a|_6#6-7]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4]" + "[(4-5)s:b|i:b|_4$<i>4<i>5]"
+                + "[(5-6)s:c|i:c|_5$<i>5<i>6]" + "[(6-7)s:a|i:a|_6$<i>6<i>7]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -109,12 +93,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4|<>:x#3-4$<i>4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:b|i:b|_4#4-5]" + "[(5-6)s:c|i:c|_5#5-6]"
-                + "[(6-7)s:a|i:a|_6#6-7]" + "[(7-8)s:b|i:b|_7#7-8]"
-                + "[(8-9)s:a|i:a|_8#8-9]" + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                        + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:x$<b>64<i>3<i>4<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]"
+                + "[(6-7)s:a|i:a|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]"
+                + "[(8-9)s:a|i:a|_8$<i>8<i>9]" + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         ki.commit();
@@ -137,12 +121,12 @@
 
         // abcabcabac
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:b|i:b|_4#4-5]" + "[(5-6)s:c|i:c|_5#5-6]"
-                + "[(6-7)s:a|i:a|_6#6-7]" + "[(7-8)s:b|i:b|_7#7-8]"
-                + "[(8-9)s:a|i:a|_8#8-9]" + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]"
+                + "[(6-7)s:a|i:a|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]"
+                + "[(8-9)s:a|i:a|_8$<i>8<i>9]" + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         ki.commit();
@@ -166,24 +150,24 @@
         // abc<x>abc<x>a</x>b</x>ac
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:c|i:c|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:b|i:b|_4#4-5]" + "[(5-6)s:c|i:c|_5#5-6]"
-                + "[(6-7)s:a|i:a|_6#6-7]<>:x#6-8$<i>8]"
-                + "[(7-8)s:b|i:b|_7#7-8]" + "[(8-9)s:a|i:a|_8#8-9]"
-                + "[(9-10)s:c|i:c|_9#9-10]");
+        fd.addTV("base", "abcabcabac", "[(0-1)s:a|i:a|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:c|i:c|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:c|i:c|_5$<i>5<i>6]"
+                + "[(6-7)s:a|i:a|_6$<i>6<i>7]<>:x$<b>64<i>6<i>8<i>8]"
+                + "[(7-8)s:b|i:b|_7$<i>7<i>8]" + "[(8-9)s:a|i:a|_8$<i>8<i>9]"
+                + "[(9-10)s:c|i:c|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         // xbz<x>xbzx</x>bxz
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "xbzxbzxbxz", "[(0-1)s:x|i:x|_0#0-1|-:t$<i>10]"
-                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:z|i:z|_2#2-3]"
-                + "[(3-4)s:x|i:x|_3#3-4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:b|i:b|_4#4-5]" + "[(5-6)s:z|i:z|_5#5-6]"
-                + "[(6-7)s:x|i:x|_6#6-7]" + "[(7-8)s:b|i:b|_7#7-8]"
-                + "[(8-9)s:x|i:x|_8#8-9]" + "[(9-10)s:z|i:z|_9#9-10]");
+        fd.addTV("base", "xbzxbzxbxz", "[(0-1)s:x|i:x|_0$<i>0<i>1|-:t$<i>10]"
+                + "[(1-2)s:b|i:b|_1$<i>1<i>2]" + "[(2-3)s:z|i:z|_2$<i>2<i>3]"
+                + "[(3-4)s:x|i:x|_3$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:b|i:b|_4$<i>4<i>5]" + "[(5-6)s:z|i:z|_5$<i>5<i>6]"
+                + "[(6-7)s:x|i:x|_6$<i>6<i>7]" + "[(7-8)s:b|i:b|_7$<i>7<i>8]"
+                + "[(8-9)s:x|i:x|_8$<i>8<i>9]" + "[(9-10)s:z|i:z|_9$<i>9<i>10]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -338,10 +322,10 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "bcbadb", "[(0-1)s:b|i:b|_0#0-1]"
-                + "[(1-2)s:c|i:c|s:b|_1#1-2]" + "[(2-3)s:b|i:b|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4|<>:e#3-6$<i>6]"
-                + "[(4-5)s:d|i:d|s:c|_4#4-5]" + "[(5-6)s:b|i:b|_5#5-6]");
+        fd.addTV("base", "bcbadb", "[(0-1)s:b|i:b|_0$<i>0<i>1]"
+                + "[(1-2)s:c|i:c|s:b|_1$<i>1<i>2]" + "[(2-3)s:b|i:b|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:e$<b>64<i>3<i>6<i>6]"
+                + "[(4-5)s:d|i:d|s:c|_4$<i>4<i>5]" + "[(5-6)s:b|i:b|_5$<i>5<i>6]");
         return fd;
     }
 
@@ -349,9 +333,9 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "caba", "[(0-1)s:c|i:c|_0#0-1]"
-                + "[(1-2)s:a|i:a|s:c|_1#1-2|<>:e#1-3$<i>3]"
-                + "[(2-3)s:b|i:b|s:a|_2#2-3]" + "[(3-4)s:a|i:a|_3#3-4]");
+        fd.addTV("base", "caba", "[(0-1)s:c|i:c|_0$<i>0<i>1]"
+                + "[(1-2)s:a|i:a|s:c|_1$<i>1<i>2|<>:e$<b>64<i>1<i>3<i>3]"
+                + "[(2-3)s:b|i:b|s:a|_2$<i>2<i>3]" + "[(3-4)s:a|i:a|_3$<i>3<i>4]");
         return fd;
     }
 
@@ -359,9 +343,9 @@
     private FieldDocument createFieldDoc3 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "cdbd", "[(0-1)s:c|i:c|_0#0-1]"
-                + "[(1-2)s:d|i:d|_1#1-2]" + "[(2-3)s:b|i:b|s:a|_2#2-3]"
-                + "[(3-4)s:d|i:d|_3#3-4]");
+        fd.addTV("base", "cdbd", "[(0-1)s:c|i:c|_0$<i>0<i>1]"
+                + "[(1-2)s:d|i:d|_1$<i>1<i>2]" + "[(2-3)s:b|i:b|s:a|_2$<i>2<i>3]"
+                + "[(3-4)s:d|i:d|_3$<i>3<i>4]");
 
         return fd;
     }
@@ -370,11 +354,11 @@
     private FieldDocument createFieldDoc4 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-3");
-        fd.addTV("base", "bcbadb", "[(0-1)s:b|i:b|_0#0-1]"
-                + "[(1-2)s:c|i:c|s:b|<>:s#1-3$<i>3|_1#1-2]"
-                + "[(2-3)s:b|i:b|_2#2-3]"
-                + "[(3-4)s:a|i:a|_3#3-4|<>:e#3-6$<i>6]"
-                + "[(4-5)s:d|i:d|s:c|_4#4-5]" + "[(5-6)s:b|i:b|_5#5-6]");
+        fd.addTV("base", "bcbadb", "[(0-1)s:b|i:b|_0$<i>0<i>1]"
+                + "[(1-2)s:c|i:c|s:b|<>:s$<b>64<i>1<i>3<i>3|_1$<i>1<i>2]"
+                + "[(2-3)s:b|i:b|_2$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_3$<i>3<i>4|<>:e$<b>64<i>3<i>6<i>6]"
+                + "[(4-5)s:d|i:d|s:c|_4$<i>4<i>5]" + "[(5-6)s:b|i:b|_5$<i>5<i>6]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
index f718ce3..ba397b3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestReferenceIndex.java
@@ -242,21 +242,21 @@
                 "tokens",
                 "Frankenstein, treat my daughter well. She is the one that saved your master who you hold so dear.",
 
-                "[(0-12)s:Frankenstein|_0#0-12|<>:nn#0-12$<i>1<s>18|<>:s#0-37$<i>4<s>1|"
-                        + "<>:np#0-13$<i>1<s>2|"
+                "[(0-12)s:Frankenstein|_0$<i>0<i>12|<>:nn$<b>64<i>0<i>12<i>1<s>18|<>:s$<b>64<i>0<i>37<i>4<s>1|"
+                        + "<>:np$<b>64<i>0<i>13<i>1<s>2|"
                         + "<:stanford/d:tag$<i>1<s>1<s>18<s>19]"
 
-                        + "[(14-19)s:treat|_1#14-19|<>:vb#14-19$<i>2<s>19|<>:vp#14-36$<i>4<s>3|"
+                        + "[(14-19)s:treat|_1$<i>14<i>19|<>:vb$<b>64<i>14<i>19<i>2<s>19|<>:vp$<b>64<i>14<i>36<i>4<s>3|"
                         + ">:stanford/d:tag$<i>0<s>2<s>19<s>18|"
                         + ">:stanford/d:tag$<i>3<s>3<s>19<s>21|"
                         + ">:stanford/d:tag$<i>4<s>4<s>19<s>22]"
 
-                        + "[(20-22)s:my|_2#20-22|<>:prp#20-22$<i>3<s>20|<>:np#20-31$<i>3<s>4]"
+                        + "[(20-22)s:my|_2$<i>20<i>22|<>:prp$<b>64<i>20<i>22<i>3<s>20|<>:np$<b>64<i>20<i>31<i>3<s>4]"
 
-                        + "[(23-31)s:daughter|_3#23-31|<>:nn#23-31$<i>4<s>21|"
+                        + "[(23-31)s:daughter|_3$<i>23<i>31|<>:nn$<b>64<i>23<i>31<i>4<s>21|"
                         + ">:stanford/d:tag$<i>2<s>5<s>21<s>20]"
 
-                        + "[(32-36)s:well|_4#32-36|<>:rb#32-36$<i>5<s>22|<>:advp#32-36$<i>4<s>5]");
+                        + "[(32-36)s:well|_4$<i>32<i>36|<>:rb$<b>64<i>32<i>36<i>5<s>22|<>:advp$<b>64<i>32<i>36<i>4<s>5]");
         return fd;
     }
 
@@ -268,59 +268,59 @@
                 "tokens",
                 "Frankenstein, treat my daughter well. She is the one that saved your master who you hold so dear.",
 
-                "[(0-12)s:Frankenstein|_0#0-12|<>:nn#0-12$<i>1<s>18|<>:s#0-37$<i>5<s>1|"
-                        + "<>:np#0-13$<i>1<s>2|"
+                "[(0-12)s:Frankenstein|_0$<i>0<i>12|<>:nn$<b>64<i>0<i>12<i>1<s>18|<>:s$<b>64<i>0<i>37<i>5<s>1|"
+                        + "<>:np$<b>64<i>0<i>13<i>1<s>2|"
                         + "<:stanford/d:tag$<i>1<s>1<s>18<s>19]"
 
-                        + "[(14-19)s:treat|_1#14-19|<>:vb#14-19$<i>2<s>19|<>:vp#14-36$<i>5<s>3|"
+                        + "[(14-19)s:treat|_1$<i>14<i>19|<>:vb$<b>64<i>14<i>19<i>2<s>19|<>:vp$<b>64<i>14<i>36<i>5<s>3|"
                         + ">:stanford/d:tag$<i>0<s>2<s>19<s>18|"
                         + ">:stanford/d:tag$<i>3<s>3<s>19<s>21|"
                         + ">:stanford/d:tag$<i>4<s>4<s>19<s>22]"
 
-                        + "[(20-22)s:my|_2#20-22|<>:prp#20-22$<i>3<s>20|<>:np#20-31$<i>4<s>4]"
+                        + "[(20-22)s:my|_2$<i>20<i>22|<>:prp$<b>64<i>20<i>22<i>3<s>20|<>:np$<b>64<i>20<i>31<i>4<s>4]"
 
-                        + "[(23-31)s:daughter|_3#23-31|<>:nn#23-31$<i>4<s>21|"
+                        + "[(23-31)s:daughter|_3$<i>23<i>31|<>:nn$<b>64<i>23<i>31<i>4<s>21|"
                         + ">:stanford/d:tag$<i>2<s>5<s>21<s>20]"
 
-                        + "[(32-36)s:well|_4#32-36|<>:rb#32-36$<i>5<s>22|<>:advp#32-36$<i>5<s>5]"
+                        + "[(32-36)s:well|_4$<i>32<i>36|<>:rb$<b>64<i>32<i>36<i>5<s>22|<>:advp$<b>64<i>32<i>36<i>5<s>5]"
 
-                        + "[(38-41)s:She|_5#38-41|<>:prp#38-41$<i>6<s>23|<>:np#38-41$<i>6<s>36|<>:s#38-97$<i>18<s>6]"
+                        + "[(38-41)s:She|_5$<i>38<i>41|<>:prp$<b>64<i>38<i>41<i>6<s>23|<>:np$<b>64<i>38<i>41<i>6<s>36|<>:s$<b>64<i>38<i>97<i>18<s>6]"
 
-                        + "[(42-44)s:is|_6#42-44|<>:vb#42-44$<i>7<s>24|<>:vp#42-96$<i>18<s>7]"
+                        + "[(42-44)s:is|_6$<i>42<i>44|<>:vb$<b>64<i>42<i>44<i>7<s>24|<>:vp$<b>64<i>42<i>96<i>18<s>7]"
 
-                        + "[(45-48)s:the|_7#45-48|<>:dt#45-48$<i>8<s>25|<>:np#45-52$<i>9<s>8|<>:np#45-96$<i>18<s>9]"
+                        + "[(45-48)s:the|_7$<i>45<i>48|<>:dt$<b>64<i>45<i>48<i>8<s>25|<>:np$<b>64<i>45<i>52<i>9<s>8|<>:np$<b>64<i>45<i>96<i>18<s>9]"
 
-                        + "[(49-52)s:one|_8#49-52|<>:nn#49-52$<i>9<s>26|"
+                        + "[(49-52)s:one|_8$<i>49<i>52|<>:nn$<b>64<i>49<i>52<i>9<s>26|"
                         + ">:stanford/d:tag$<i>5<s>6<s>26<s>23|"
                         + ">:stanford/d:tag$<i>6<s>7<s>26<s>24|"
                         + ">:stanford/d:tag$<i>7<s>8<s>26<s>25|"
                         + ">:stanford/d:tag$<i>10<s>9<s>26<s>28]"
 
-                        + "[(53-57)s:that|_9#53-57|<>:rp#53-57$<i>10<s>27|<>:sb#53-96$<i>18<s>10]"
+                        + "[(53-57)s:that|_9$<i>53<i>57|<>:rp$<b>64<i>53<i>57<i>10<s>27|<>:sb$<b>64<i>53<i>96<i>18<s>10]"
 
-                        + "[(58-63)s:saved|_10#58-63|<>:vb#58-63$<i>11<s>28|<>:s#58-96$<i>18<s>11|"
-                        + "<>:vp#58-96$<i>18<s>12|"
+                        + "[(58-63)s:saved|_10$<i>58<i>63|<>:vb$<b>64<i>58<i>63<i>11<s>28|<>:s$<b>64<i>58<i>96<i>18<s>11|"
+                        + "<>:vp$<b>64<i>58<i>96<i>18<s>12|"
                         + ">:stanford/d:tag$<i>9<s>10<s>28<s>27|"
                         + ">:stanford/d:tag$<i>12<s>11<s>28<s>30|"
                         + ">:stanford/d:tag$<i>15<s>12<s>28<s>33]"
 
-                        + "[(64-68)s:your|_11#64-68|<>:prp#64-68$<i>12<s>29|<>:np#64-75$<i>13<s>13]"
+                        + "[(64-68)s:your|_11$<i>64<i>68|<>:prp$<b>64<i>64<i>68<i>12<s>29|<>:np$<b>64<i>64<i>75<i>13<s>13]"
 
-                        + "[(69-75)s:master|_12#69-75|<>:nn#69-75$<i>13<s>30|"
+                        + "[(69-75)s:master|_12$<i>69<i>75|<>:nn$<b>64<i>69<i>75<i>13<s>30|"
                         + ">:stanford/d:tag$<i>11<s>13<s>30<s>29]"
 
-                        + "[(76-79)s:who|_13#76-79|<>:rp#76-79$<i>14<s>31|<>:sb#76-96$<i>18<s>14]"
+                        + "[(76-79)s:who|_13$<i>76<i>79|<>:rp$<b>64<i>76<i>79<i>14<s>31|<>:sb$<b>64<i>76<i>96<i>18<s>14]"
 
-                        + "[(80-83)s:you|_14#80-83|<>:prp#80-83$<i>15<s>32|<>:np#80-83$<i>15<s>37|<>:s#80-96$<i>18<s>15]"
+                        + "[(80-83)s:you|_14$<i>80<i>83|<>:prp$<b>64<i>80<i>83<i>15<s>32|<>:np$<b>64<i>80<i>83<i>15<s>37|<>:s$<b>64<i>80<i>96<i>18<s>15]"
 
-                        + "[(84-88)s:hold|_15#84-88|<>:vb#84-88$<i>16<s>33|<>:vp#84-96$<i>18<s>16|"
+                        + "[(84-88)s:hold|_15$<i>84<i>88|<>:vb$<b>64<i>84<i>88<i>16<s>33|<>:vp$<b>64<i>84<i>96<i>18<s>16|"
                         + ">:stanford/d:tag$<i>13<s>14<s>33<s>31|"
                         + ">:stanford/d:tag$<i>14<s>15<s>33<s>32|"
                         + ">:stanford/d:tag$<i>17<s>16<s>33<s>35]"
 
-                        + "[(89-91)s:so|_16#89-91|<>:rb#89-91$<i>17<s>341|<>:adjp#89-96$<i>18<s>17]"
+                        + "[(89-91)s:so|_16$<i>89<i>91|<>:rb$<b>64<i>89<i>91<i>17<s>341|<>:adjp$<b>64<i>89<i>96<i>18<s>17]"
 
-                        + "[(92-96)s:dear|_17#92-96|<>:jj#92-96$<i>18<s>35|"
+                        + "[(92-96)s:dear|_17$<i>92<i>96|<>:jj$<b>64<i>92<i>96<i>18<s>35|"
                         + ">:stanford/d:tag$<i>16<s>17<s>35<s>34]");
 
         return fd;
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
index da6851e..78d115c 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
@@ -14,12 +14,10 @@
 import org.slf4j.LoggerFactory;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.SpanSegmentQuery;
-import de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper;
-import de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper;
+import de.ids_mannheim.korap.response.Result;
 
 
 @RunWith(JUnit4.class)
@@ -181,12 +179,12 @@
     private FieldDocument createFieldDoc0 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "bcbabd", "[(0-1)s:b|i:b|_1#0-1]"
-                + "[(1-2)s:c|i:c|s:b|_2#1-2]"
-                + "[(2-3)s:b|i:b|_3#2-3|<>:e#2-4$<i>4]"
-                + "[(3-4)s:a|i:a|_4#3-4|<>:e#3-5$<i>5|<>:e2#3-5$<i>5]"
-                + "[(4-5)s:b|i:b|s:c|_5#4-5]"
-                + "[(5-6)s:d|i:d|_6#5-6|<>:e2#5-6$<i>6]");
+        fd.addTV("base", "bcbabd", "[(0-1)s:b|i:b|_1$<i>0<i>1]"
+                + "[(1-2)s:c|i:c|s:b|_2$<i>1<i>2]"
+                        + "[(2-3)s:b|i:b|_3$<i>2<i>3|<>:e$<b>64<i>2<i>4<i>4]"
+                        + "[(3-4)s:a|i:a|_4$<i>3<i>4|<>:e$<b>64<i>3<i>5<i>5|<>:e2$<b>64<i>3<i>5<i>5]"
+                + "[(4-5)s:b|i:b|s:c|_5$<i>4<i>5]"
+                        + "[(5-6)s:d|i:d|_6$<i>5<i>6|<>:e2$<b>64<i>5<i>6<i>6]");
         return fd;
     }
 
@@ -194,10 +192,10 @@
     private FieldDocument createFieldDoc1 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "babaa", "[(0-1)s:b|i:b|s:c|_1#0-1]"
-                + "[(1-2)s:a|i:a|s:b|_2#1-2|<>:e#1-3$<i>3]"
-                + "[(2-3)s:b|i:b|s:a|_3#2-3]" + "[(3-4)s:a|i:a|_4#3-4]"
-                + "[(4-5)s:a|i:a|_5#4-5]");
+        fd.addTV("base", "babaa", "[(0-1)s:b|i:b|s:c|_1$<i>0<i>1]"
+                + "[(1-2)s:a|i:a|s:b|_2$<i>1<i>2|<>:e$<b>64<i>1<i>3<i>3]"
+                + "[(2-3)s:b|i:b|s:a|_3$<i>2<i>3]"
+                + "[(3-4)s:a|i:a|_4$<i>3<i>4]" + "[(4-5)s:a|i:a|_5$<i>4<i>5]");
         return fd;
     }
 
@@ -205,8 +203,9 @@
     private FieldDocument createFieldDoc2 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "bdb", "[(0-1)s:b|i:b|_1#0-1]"
-                + "[(1-2)s:d|i:d|s:b|_2#1-2]" + "[(2-3)s:b|i:b|s:a|_3#2-3]");
+        fd.addTV("base", "bdb", "[(0-1)s:b|i:b|_1$<i>0<i>1]"
+                + "[(1-2)s:d|i:d|s:b|_2$<i>1<i>2]"
+                + "[(2-3)s:b|i:b|s:a|_3$<i>2<i>3]");
         return fd;
     }
 
@@ -214,8 +213,8 @@
     private FieldDocument createFieldDoc4 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-4");
-        fd.addTV("base", "bdb", "[(0-1)s:b|i:b|s:c|_1#0-1]"
-                + "[(1-2)s:d|_2#1-2]" + "[(2-3)s:d|i:d|_3#2-3]");
+        fd.addTV("base", "bdb", "[(0-1)s:b|i:b|s:c|_1$<i>0<i>1]"
+                + "[(1-2)s:d|_2$<i>1<i>2]" + "[(2-3)s:d|i:d|_3$<i>2<i>3]");
         return fd;
     }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
index 1cb78c9..3de9dc9 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
@@ -12,11 +12,11 @@
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.DistanceConstraint;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
+import de.ids_mannheim.korap.response.Result;
 
 @RunWith(JUnit4.class)
 public class TestUnorderedDistanceIndex {
@@ -28,13 +28,16 @@
     private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "text", "[(0-1)s:c|_1#0-1]" + "[(1-2)s:e|_2#1-2]"
-                + "[(2-3)s:c|_3#2-3|<>:y#2-4$<i>4]"
-                + "[(3-4)s:c|_4#3-4|<>:x#3-7$<i>7]"
-                + "[(4-5)s:d|_5#4-5|<>:y#4-6$<i>6]"
-                + "[(5-6)s:c|_6#5-6|<>:y#5-8$<i>8]" + "[(6-7)s:d|_7#6-7]"
-                + "[(7-8)s:f|_8#7-8|<>:x#7-9$<i>9]"
-                + "[(8-9)s:e|_9#8-9|<>:x#8-10$<i>10]" + "[(9-10)s:d|_10#9-10]");
+        fd.addTV("base", "text", "[(0-1)s:c|_1$<i>0<i>1]"
+                + "[(1-2)s:e|_2$<i>1<i>2]"
+                + "[(2-3)s:c|_3$<i>2<i>3|<>:y$<b>64<i>2<i>4<i>4]"
+                + "[(3-4)s:c|_4$<i>3<i>4|<>:x$<b>64<i>3<i>7<i>7]"
+                + "[(4-5)s:d|_5$<i>4<i>5|<>:y$<b>64<i>4<i>6<i>6]"
+                + "[(5-6)s:c|_6$<i>5<i>6|<>:y$<b>64<i>5<i>8<i>8]"
+                + "[(6-7)s:d|_7$<i>6<i>7]"
+                + "[(7-8)s:f|_8$<i>7<i>8|<>:x$<b>64<i>7<i>9<i>9]"
+                + "[(8-9)s:e|_9$<i>8<i>9|<>:x$<b>64<i>8<i>10<i>10]"
+                + "[(9-10)s:d|_10$<i>9<i>10]");
         return fd;
     }
 
@@ -42,11 +45,12 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "text", "[(0-1)s:d|_1#0-1]" + "[(1-2)s:c|_2#1-2]"
-                + "[(2-3)s:e|_3#2-3]" + "[(3-4)s:e|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5]" + "[(5-6)s:e|_6#5-6]"
-                + "[(6-7)s:e|_7#6-7]" + "[(7-8)s:c|_8#7-8]"
-                + "[(8-9)s:e|_9#8-9]" + "[(9-10)s:d|_10#9-10]");
+        fd.addTV("base", "text", "[(0-1)s:d|_1$<i>0<i>1]"
+                + "[(1-2)s:c|_2$<i>1<i>2]" + "[(2-3)s:e|_3$<i>2<i>3]"
+                + "[(3-4)s:e|_4$<i>3<i>4]" + "[(4-5)s:d|_5$<i>4<i>5]"
+                + "[(5-6)s:e|_6$<i>5<i>6]" + "[(6-7)s:e|_7$<i>6<i>7]"
+                + "[(7-8)s:c|_8$<i>7<i>8]" + "[(8-9)s:e|_9$<i>8<i>9]"
+                + "[(9-10)s:d|_10$<i>9<i>10]");
         return fd;
     }
 
@@ -54,10 +58,10 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "text", "[(0-1)s:f|_1#0-1]" + "[(1-2)s:c|_2#1-2]"
-                + "[(2-3)s:e|_3#2-3]" + "[(3-4)s:e|_4#3-4]"
-                + "[(4-5)s:d|_5#4-5]" + "[(5-6)s:f|_6#5-6]"
-                + "[(6-7)s:f|_7#6-7]");
+        fd.addTV("base", "text", "[(0-1)s:f|_1$<i>0<i>1]"
+                + "[(1-2)s:c|_2$<i>1<i>2]" + "[(2-3)s:e|_3$<i>2<i>3]"
+                + "[(3-4)s:e|_4$<i>3<i>4]" + "[(4-5)s:d|_5$<i>4<i>5]"
+                + "[(5-6)s:f|_6$<i>5<i>6]" + "[(6-7)s:f|_7$<i>6<i>7]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
index 7700678..cb8b84e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
@@ -12,11 +12,11 @@
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.query.DistanceConstraint;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
+import de.ids_mannheim.korap.response.Result;
 
 @RunWith(JUnit4.class)
 public class TestUnorderedElementDistanceIndex {
@@ -28,11 +28,14 @@
     private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "text", "[(0-1)s:b|s:c|_1#0-1|<>:s#0-2$<i>1]"
-                + "[(1-2)s:b|_2#1-2]" + "[(2-3)s:b|_3#2-3|<>:s#2-3$<i>3]"
-                + "[(3-4)s:c|_4#3-4|<>:s#3-4$<i>4]"
-                + "[(4-5)s:b|_5#4-5|<>:s#4-5$<i>5]" + "[(5-6)s:b|_6#5-6]"
-                + "[(6-7)s:c|_7#6-7|<>:s#6-7$<i>7]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|s:c|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:b|_2$<i>1<i>2]"
+                        + "[(2-3)s:b|_3$<i>2<i>3|<>:s$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:c|_4$<i>3<i>4|<>:s$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:b|_5$<i>4<i>5|<>:s$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:b|_6$<i>5<i>6]"
+                        + "[(6-7)s:c|_7$<i>6<i>7|<>:s$<b>64<i>6<i>7<i>7]");
         return fd;
     }
 
@@ -40,10 +43,12 @@
     private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "text", "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>1]"
-                + "[(1-2)s:c|_2#1-2|<>:s#1-2$<i>4]" + "[(2-3)s:e|_3#2-3]"
-                + "[(3-4)s:c|_4#3-4]" + "[(4-5)s:b|_5#4-5|<>:s#4-5$<i>7]"
-                + "[(5-6)s:e|_6#5-6]" + "[(6-7)s:e|_7#6-7]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:c|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>4]"
+                        + "[(2-3)s:e|_3$<i>2<i>3]" + "[(3-4)s:c|_4$<i>3<i>4]"
+                        + "[(4-5)s:b|_5$<i>4<i>5|<>:s$<b>64<i>4<i>5<i>7]"
+                        + "[(5-6)s:e|_6$<i>5<i>6]" + "[(6-7)s:e|_7$<i>6<i>7]");
         return fd;
     }
 
@@ -51,14 +56,15 @@
     private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base", "text", "[(0-1)s:e|_1#0-1|<>:p#0-2$<i>1]"
-                + "[(1-2)s:e|_2#1-2|<>:p#1-2$<i>2]"
-                + "[(2-3)s:c|_3#2-3|<>:p#2-3$<i>3]"
-                + "[(3-4)s:e|_4#3-4|<>:p#3-4$<i>4]"
-                + "[(4-5)s:b|_5#4-5|<>:p#4-5$<i>5]"
-                + "[(5-6)s:c|_6#5-6|<>:p#5-6$<i>6]"
-                + "[(6-7)s:e|_7#6-7|<>:p#6-7$<i>7]"
-                + "[(7-8)s:b|_8#7-8|<>:p#7-8$<i>8]");
+        fd.addTV("base", "text",
+                "[(0-1)s:e|_1$<i>0<i>1|<>:p$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:e|_2$<i>1<i>2|<>:p$<b>64<i>1<i>2<i>2]"
+                        + "[(2-3)s:c|_3$<i>2<i>3|<>:p$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:e|_4$<i>3<i>4|<>:p$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:b|_5$<i>4<i>5|<>:p$<b>64<i>4<i>5<i>5]"
+                        + "[(5-6)s:c|_6$<i>5<i>6|<>:p$<b>64<i>5<i>6<i>6]"
+                        + "[(6-7)s:e|_7$<i>6<i>7|<>:p$<b>64<i>6<i>7<i>7]"
+                        + "[(7-8)s:b|_8$<i>7<i>8|<>:p$<b>64<i>7<i>8<i>8]");
         return fd;
     }
 
@@ -66,8 +72,10 @@
     private FieldDocument createFieldDoc3 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-3");
-        fd.addTV("base", "text", "[(0-1)s:a|_1#0-1|<>:s#0-2$<i>1]"
-                + "[(1-2)s:d|_2#1-2|<>:s#1-2$<i>3]" + "[(2-3)s:e|_3#2-3]");
+        fd.addTV("base", "text",
+                "[(0-1)s:a|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>1]"
+                        + "[(1-2)s:d|_2$<i>1<i>2|<>:s$<b>64<i>1<i>2<i>3]"
+                        + "[(2-3)s:e|_3$<i>2<i>3]");
         return fd;
     }
 
@@ -75,9 +83,11 @@
     private FieldDocument createFieldDoc4 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-4");
-        fd.addTV("base", "text", "[(0-1)s:c|_1#0-1|<>:s#0-2$<i>2]"
-                + "[(1-2)s:e|_2#1-2]" + "[(2-3)s:b|_3#2-3|<>:s#2-3$<i>3]"
-                + "[(3-4)s:e|_4#3-4|<>:s#3-4$<i>4]");
+        fd.addTV("base", "text",
+                "[(0-1)s:c|_1$<i>0<i>1|<>:s$<b>64<i>0<i>2<i>2]"
+                        + "[(1-2)s:e|_2$<i>1<i>2]"
+                        + "[(2-3)s:b|_3$<i>2<i>3|<>:s$<b>64<i>2<i>3<i>3]"
+                        + "[(3-4)s:e|_4$<i>3<i>4|<>:s$<b>64<i>3<i>4<i>4]");
         return fd;
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
index 9acd416..0c6582c 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -1,36 +1,28 @@
 package de.ids_mannheim.korap.index;
 
-import java.util.*;
-import java.io.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
-import org.apache.lucene.util.Version;
-import org.apache.lucene.util.BytesRef;
-import org.apache.lucene.util.Bits;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
 
-import static org.junit.Assert.*;
-
+import org.apache.lucene.index.Term;
+import org.apache.lucene.search.spans.SpanQuery;
+import org.apache.lucene.search.spans.SpanTermQuery;
 import org.junit.Test;
-import org.junit.Ignore;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import de.ids_mannheim.korap.KrillIndex;
-import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.KrillQuery;
-import de.ids_mannheim.korap.response.Result;
-import de.ids_mannheim.korap.query.SpanElementQuery;
-import de.ids_mannheim.korap.query.SpanWithinQuery;
-import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.SpanClassQuery;
+import de.ids_mannheim.korap.query.SpanElementQuery;
+import de.ids_mannheim.korap.query.SpanNextQuery;
+import de.ids_mannheim.korap.query.SpanWithinQuery;
 import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
+import de.ids_mannheim.korap.response.Result;
 import de.ids_mannheim.korap.util.QueryException;
-import de.ids_mannheim.korap.index.FieldDocument;
-import de.ids_mannheim.korap.index.MultiTermTokenStream;
-import org.apache.lucene.search.spans.SpanQuery;
-import org.apache.lucene.search.spans.SpanTermQuery;
-import org.apache.lucene.index.Term;
-
-import java.nio.ByteBuffer;
 
 // mvn -Dtest=TestWithinIndex#indexExample1 test
 
@@ -51,9 +43,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x   y   z   h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:h]" +   // 4
                         "[(12-15)s:i]" +  // 5
                         "[(15-18)s:j]" +  // 6
@@ -102,9 +94,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x   y   z   h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:h]" +   // 4
                         "[(12-15)s:i]" +  // 5
                         "[(15-18)s:j]" +  // 6
@@ -119,9 +111,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         fd = new FieldDocument();
         fd.addTV("base", "x   y   z   h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:h]" +   // 4
                         "[(12-15)s:i]" +  // 5
                         "[(15-18)s:j]" +  // 6
@@ -204,9 +196,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x   y   z   h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:h]" +   // 4
                         "[(12-15)s:i]" +  // 5
                         "[(15-18)s:j]" +  // 6
@@ -221,9 +213,9 @@
         // <a>x<a>y<a>zabc</a>abc</a>abc</a>
         fd = new FieldDocument();
         fd.addTV("base", "x   y   z   a   b   c   a   b   c   a   b   c   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:a]" +   // 4
                         "[(12-15)s:b]" +  // 5
                         "[(15-18)s:c]" +  // 6
@@ -279,9 +271,9 @@
         // <a>x<a>y<a>zhij</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "x   y   z   h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:h]" +   // 4
                         "[(12-15)s:i]" +  // 5
                         "[(15-18)s:j]" +  // 6
@@ -303,9 +295,9 @@
         // <a>x<a>y<a>zabc</a>abc</a>abc</a>
         fd = new FieldDocument();
         fd.addTV("base", "x   y   z   a   b   c   a   b   c   a   b   c   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12]" + // 1
-                        "[(3-6)s:y|<>:a#3-27$<i>9]" +  // 2
-                        "[(6-9)s:z|<>:a#6-18$<i>6]" +  // 3
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12]" + // 1
+                        "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]" + // 2
+                        "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + // 3
                         "[(9-12)s:a]" +   // 4
                         "[(12-15)s:b]" +  // 5
                         "[(15-18)s:c]" +  // 6
@@ -365,16 +357,17 @@
         fd.addTV("base",
                 // <a><a>hhij</a>hijh</a>ij</a>
                 "h  h  i  j  h  i  j  h  i  j        ",
-                "[s:h|_0#0-3|<>:a#0-24$<i>7|<>:a#0-12$<i>3|<>:a#0-30$<i>9]" + // 1
-                        "[s:h|_1#3-6]" +    // 2
-                        "[s:i|_2#6-9]" +    // 3
-                        "[s:j|_3#9-12]" +   // 4
-                        "[s:h|_4#12-15]" +  // 5
-                        "[s:i|_5#15-18]" +  // 6
-                        "[s:j|_6#18-21]" +  // 7
-                        "[s:h|_7#21-24]" +  // 8
-                        "[s:i|_8#24-27]" +  // 9
-                        "[s:j|_9#27-30]");  // 10
+                "[s:h|_0$<i>0<i>3|<>:a$<b>64<i>0<i>12<i>3|<>:a$<b>64<i>0<i>24<i>7|<>:a$<b>64<i>0<i>30<i>9]"
+                        + // 1
+                        "[s:h|_1$<i>3<i>6]" + // 2
+                        "[s:i|_2$<i>6<i>9]" + // 3
+                        "[s:j|_3$<i>9<i>12]" + // 4
+                        "[s:h|_4$<i>12<i>15]" + // 5
+                        "[s:i|_5$<i>15<i>18]" + // 6
+                        "[s:j|_6$<i>18<i>21]" + // 7
+                        "[s:h|_7$<i>21<i>24]" + // 8
+                        "[s:i|_8$<i>24<i>27]" + // 9
+                        "[s:j|_9$<i>27<i>30]"); // 10
         ki.addDoc(fd);
 
         // Save documents
@@ -436,7 +429,8 @@
         // <a><a><a>h</a>hij</a>hij</a>h
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "h  h  i  j  h  i  j  h  i  j  h  ",
-                "[(0-3)s:h|<>:a#0-21$<i>6|<>:a#0-12$<i>3|<>:a#0-30$<i>9]" + // 1
+                "[(0-3)s:h|<>:a$<b>64<i>0<i>12<i>3|<>:a$<b>64<i>0<i>21<i>6|<>:a$<b>64<i>0<i>30<i>9]"
+                        + // 1
                         "[(3-6)s:h]" +    // 2
                         "[(6-9)s:i]" +    // 3
                         "[(9-12)s:j]" +   // 4
@@ -500,7 +494,8 @@
         // <a><a><a>h</a>hij</a>hij</a>h<a>i</i>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "h  h  i  j  h  i  j  h  i  j  h  i  ",
-                "[(0-3)s:h|<>:a#0-21$<i>7|<>:a#0-15$<i>4|<>:a#0-30$<i>10]" + // 1
+                "[(0-3)s:h|<>:a$<b>64<i>0<i>15<i>4|<>:a$<b>64<i>0<i>21<i>7|<>:a$<b>64<i>0<i>30<i>10]"
+                        + // 1
                         "[(3-6)s:h]" +    // 2
                         "[(6-9)s:i]" +  // 3
                         "[(9-12)s:j]" +  // 4
@@ -511,7 +506,7 @@
                         "[(24-27)s:i]" +  // 9
                         "[(27-30)s:j]" +  // 10
                         "[(30-33)s:h]" +  // 11
-                        "[(33-36)s:i|<>:a#33-36$<i>12]"); // 12
+                        "[(33-36)s:i|<>:a$<b>64<i>33<i>36<i>12]"); // 12
         ki.addDoc(fd);
 
         // Save documents
@@ -572,19 +567,29 @@
         // <a><a><a>h</a>hij</a>hij</a>h<a>h</h>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "h  h  i  j  h  i  j  h  i  j  h  h  ",
-                "[(0-3)s:h|_0#0-3|<>:a#0-18$<i>6|<>:a#0-15$<i>4|<>:a#0-27$<i>8]"
+                "[(0-3)s:h|_0$<i>0<i>3|<>:a$<b>64<i>0<i>15<i>4|<>:a$<b>64<i>0<i>18<i>6|<>:a$<b>64<i>0<i>27<i>8]"
                         + // 1
-                        "[(3-6)s:h|_1#3-6]" +    // 2
-                        "[(6-9)s:i|_2#6-9]" +  // 3
-                        "[(9-12)s:j|_3#9-12]" +  // 4
-                        "[(12-15)s:h|_4#12-15]" +  // 5
-                        "[(15-18)s:i|_5#15-18]" +  // 6
-                        "[(18-21)s:j|_6#18-21]" +  // 7
-                        "[(21-24)s:h|_7#21-24]" +  // 8
-                        "[(24-27)s:i|_8#24-27]" +  // 9
-                        "[(27-30)s:j|_9#27-30]" +  // 10
-                        "[(30-33)s:h|_10#30-33|<>:a#30-36$<i>12]" + // 11
-                        "[(33-36)s:h|_11#33-36|<>:a#33-36$<i>12]"); // 12
+                        "[(3-6)s:h|_1$<i>3<i>6]"
+                        + // 2
+                        "[(6-9)s:i|_2$<i>6<i>9]"
+                        + // 3
+                        "[(9-12)s:j|_3$<i>9<i>12]"
+                        + // 4
+                        "[(12-15)s:h|_4$<i>12<i>15]"
+                        + // 5
+                        "[(15-18)s:i|_5$<i>15<i>18]"
+                        + // 6
+                        "[(18-21)s:j|_6$<i>18<i>21]"
+                        + // 7
+                        "[(21-24)s:h|_7$<i>21<i>24]"
+                        + // 8
+                        "[(24-27)s:i|_8$<i>24<i>27]"
+                        + // 9
+                        "[(27-30)s:j|_9$<i>27<i>30]"
+                        + // 10
+                        "[(30-33)s:h|_10$<i>30<i>33|<>:a$<b>64<i>30<i>36<i>12]"
+                        + // 11
+                        "[(33-36)s:h|_11$<i>33<i>36|<>:a$<b>64<i>33<i>36<i>12]"); // 12
         ki.addDoc(fd);
 
         // Save documents
@@ -655,15 +660,15 @@
         // <a><a><a>u</a></a></a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "xyz",
-                "[(0-3)s:xyz|<>:a#0-3$<i>0|<>:a#0-3$<i>0|<>:a#0-3$<i>0|<>:b#0-3$<i>0]");
+                "[(0-3)s:xyz|<>:a$<b>64<i>0<i>3<i>0|<>:a$<b>64<i>0<i>3<i>0|<>:a$<b>64<i>0<i>3<i>0|<>:b$<b>64<i>0<i>3<i>0]");
         ki.addDoc(fd);
 
         // <a><b>x<a>y<a>zcde</a>cde</a>cde</b></a>
         fd = new FieldDocument();
         fd.addTV("base", "x   y   z   c   d   e   c   d   e   c   d   e   ",
-                "[(0-3)s:x|<>:a#0-36$<i>12|<>:b#0-36$<i>12]"
-                        + "[(3-6)s:y|<>:a#3-27$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-18$<i>6]" + "[(9-12)s:c]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>36<i>12|<>:b$<b>64<i>0<i>36<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>27<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>18<i>6]" + "[(9-12)s:c]"
                         + "[(12-15)s:d]" + "[(15-18)s:e]" + "[(18-21)s:c]"
                         + "[(21-24)s:d]" + "[(24-27)s:e]" + "[(27-30)s:c]"
                         + "[(30-33)s:d]" + "[(33-36)s:e]");
@@ -678,9 +683,9 @@
         // <a>x<a><b>y<a>zcde</a>cde</b></a>cde</a>
         fd = new FieldDocument();
         fd.addTV("base", "x   y   z   k   l   m   k   l   m   k   l   m   ",
-                "[(0-3)s:x|<>:a#0-3$<i>12]"
-                        + "[(3-6)s:y|<>:a#3-6$<i>9|<>:b#3-6$<i>9]"
-                        + "[(6-9)s:z|<>:a#6-9$<i>6]" + "[(9-12)s:k]"
+                "[(0-3)s:x|<>:a$<b>64<i>0<i>3<i>12]"
+                        + "[(3-6)s:y|<>:a$<b>64<i>3<i>6<i>9|<>:b$<b>64<i>3<i>6<i>9]"
+                        + "[(6-9)s:z|<>:a$<b>64<i>6<i>9<i>6]" + "[(9-12)s:k]"
                         + "[(12-15)s:l]" + "[(15-18)s:m]" + "[(18-21)s:k]"
                         + "[(21-24)s:l]" + "[(24-27)s:m]" + "[(27-30)s:k]"
                         + "[(30-33)s:l]" + "[(33-36)s:m]");
@@ -689,7 +694,10 @@
         // <a><a><a>h</a>hhij</a>hij</a>hij</a>
         fd = new FieldDocument();
         fd.addTV("base", "h   i   j   h   i   j   h   i   j   ",
-                "[(0-3)s:h|<>:a#0-27$<i>6|<>:a#0-18$<i>3|<>:a#0-36$<i>9]"
+                "[(0-3)s:h|"
+                        + "<>:a$<b>64<i>0<i>18<i>3|" 
+                        + "<>:a$<b>64<i>0<i>27<i>6|" 
+                        + "<>:a$<b>64<i>0<i>36<i>9]"
                         + "[(3-6)s:h]" + "[(12-15)s:i]" + "[(15-18)s:j]"
                         + "[(18-21)s:h]" + "[(21-24)s:i]" + "[(24-27)s:j]"
                         + "[(27-30)s:h]" + "[(30-33)s:i]" + "[(33-36)s:j]");
@@ -748,11 +756,13 @@
         FieldDocument fd = new FieldDocument();
         fd = new FieldDocument();
         fd.addTV("base", "Er schrie: \"Das war ich!\" und ging.",
-                "[(0-2)s:Er|_0#0-3]" + "[(3-9)s:schrie|_1#3-9]"
-                        + "[(12-15)s:Das|_2#12-15|<>:sentence#11-25$<i>5]"
-                        + "[(16-19)s:war|_3#16-19]" + "[(20-23)s:ich|_4#20-23]"
-                        + "[(26-29)s:und|_5#26-29]"
-                        + "[(30-34)s:ging|_6#30-34]");
+                "[(0-2)s:Er|_0$<i>0<i>3]"
+                        + "[(3-9)s:schrie|_1$<i>3<i>9]"
+                        + "[(12-15)s:Das|_2$<i>12<i>15|<>:sentence$<b>64<i>11<i>25<i>5]"
+                        + "[(16-19)s:war|_3$<i>16<i>19]"
+                        + "[(20-23)s:ich|_4$<i>20<i>23]"
+                        + "[(26-29)s:und|_5$<i>26<i>29]"
+                        + "[(30-34)s:ging|_6$<i>30<i>34]");
         ki.addDoc(fd);
 
         // Save documents
@@ -835,12 +845,15 @@
         // Case 1, 6, 7, 13
         // xy<a><a>x</a>b<a>c</a></a>x
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base", "x  y  x  b  c  x  ", "[(0-3)s:x|_0#0-3]"
-                + "[(3-6)s:y|_1#3-6]"
-                + "[(6-9)s:x|_2#6-9|<>:a#6-15$<i>5|<>:a#6-9$<i>3]"
-                + "[(9-12)s:b|_3#9-12]"
-                + "[(12-15)s:c|_4#12-15|<>:a#12-15$<i>5]"
-                + "[(15-18)s:x|_5#15-18]");
+        fd.addTV(
+                "base",
+                "x  y  x  b  c  x  ",
+                "[(0-3)s:x|_0$<i>0<i>3]"
+                        + "[(3-6)s:y|_1$<i>3<i>6]"
+                        + "[(6-9)s:x|_2$<i>6<i>9|<>:a$<b>64<i>6<i>9<i>3|<>:a$<b>64<i>6<i>15<i>5]"
+                        + "[(9-12)s:b|_3$<i>9<i>12]"
+                        + "[(12-15)s:c|_4$<i>12<i>15|<>:a$<b>64<i>12<i>15<i>5]"
+                        + "[(15-18)s:x|_5$<i>15<i>18]");
         ki.addDoc(fd);
 
         // Save documents
@@ -869,14 +882,16 @@
         // hij<a>hi<a>h<a>ij</a></a>hi</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "hijhihijhi",
-                "[(0-1)s:h|i:h|_0#0-1|-:a$<i>3|-:t$<i>10]"
-                        + "[(1-2)s:i|i:i|_1#1-2]" + "[(2-3)s:j|i:j|_2#2-3]"
-                        + "[(3-4)s:h|i:h|_3#3-4|<>:a#3-10$<i>10]"
-                        + "[(4-5)s:i|i:i|_4#4-5]"
-                        + "[(5-6)s:h|i:h|_5#5-6|<>:a#5-8$<i>8]"
-                        + "[(6-7)s:i|i:i|_6#6-7|<>:a#6-8$<i>8]"
-                        + "[(7-8)s:j|i:j|_7#7-8]" + "[(8-9)s:h|i:h|_8#8-9]"
-                        + "[(9-10)s:i|i:i|_9#9-10]");
+                "[(0-1)s:h|i:h|_0$<i>0<i>1|-:a$<i>3|-:t$<i>10]"
+                        + "[(1-2)s:i|i:i|_1$<i>1<i>2]"
+                        + "[(2-3)s:j|i:j|_2$<i>2<i>3]"
+                        + "[(3-4)s:h|i:h|_3$<i>3<i>4|<>:a$<b>64<i>3<i>10<i>10]"
+                        + "[(4-5)s:i|i:i|_4$<i>4<i>5]"
+                        + "[(5-6)s:h|i:h|_5$<i>5<i>6|<>:a$<b>64<i>5<i>8<i>8]"
+                        + "[(6-7)s:i|i:i|_6$<i>6<i>7|<>:a$<b>64<i>6<i>8<i>8]"
+                        + "[(7-8)s:j|i:j|_7$<i>7<i>8]"
+                        + "[(8-9)s:h|i:h|_8$<i>8<i>9]"
+                        + "[(9-10)s:i|i:i|_9$<i>9<i>10]");
         ki.addDoc(fd);
 
         // Save documents
@@ -910,14 +925,15 @@
         // h<a><a>i</a>j</a><a>h</a>i j<a>h i</a>j
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "hijhi jh ij",
-                "[(0-1)s:h|i:h|_0#0-1|-:a$<i>4|-:t$<i>9]"
-                        + "[(1-2)s:i|i:i|_1#1-2|<>:a#1-2$<i>2|<>:a#1-3$<i>3]"
-                        + "[(2-3)s:j|i:j|_2#2-3]"
-                        + "[(3-4)s:h|i:h|_3#3-4|<>:a#3-4$<i>4]"
-                        + "[(4-5)s:i|i:i|_4#4-5]" + "[(6-7)s:j|i:j|_5#6-7]"
-                        + "[(7-8)s:h|i:h|_6#7-8|<>:a#7-10$<i>8]"
-                        + "[(9-10)s:i|i:i|_7#9-10]"
-                        + "[(10-11)s:j|i:j|_8#10-11]");
+                "[(0-1)s:h|i:h|_0$<i>0<i>1|-:a$<i>4|-:t$<i>9]"
+                        + "[(1-2)s:i|i:i|_1$<i>1<i>2|<>:a$<b>64<i>1<i>2<i>2|<>:a$<b>64<i>1<i>3<i>3]"
+                        + "[(2-3)s:j|i:j|_2$<i>2<i>3]"
+                        + "[(3-4)s:h|i:h|_3$<i>3<i>4|<>:a$<b>64<i>3<i>4<i>4]"
+                        + "[(4-5)s:i|i:i|_4$<i>4<i>5]"
+                        + "[(6-7)s:j|i:j|_5$<i>6<i>7]"
+                        + "[(7-8)s:h|i:h|_6$<i>7<i>8|<>:a$<b>64<i>7<i>10<i>8]"
+                        + "[(9-10)s:i|i:i|_7$<i>9<i>10]"
+                        + "[(10-11)s:j|i:j|_8$<i>10<i>11]");
         ki.addDoc(fd);
 
         // Save documents
@@ -943,12 +959,14 @@
         // x<a>x h</a>i j h<a>i j</a>
         FieldDocument fd = new FieldDocument();
         fd.addTV("base", "xx hi j hi j",
-                "[(0-1)s:x|i:x|_0#0-1|-:a$<i>2|-:t$<i>8]"
-                        + "[(1-2)s:x|i:x|_1#1-2|<>:a#1-4$<i>3]"
-                        + "[(3-4)s:h|i:h|_2#3-4]" + "[(4-5)s:i|i:i|_3#4-5]"
-                        + "[(6-7)s:j|i:j|_4#6-7]" + "[(8-9)s:h|i:h|_5#8-9]"
-                        + "[(9-10)s:i|i:i|_6#9-10|<>:a#9-12$<i>8]"
-                        + "[(11-12)s:j|i:j|_7#11-12]");
+                "[(0-1)s:x|i:x|_0$<i>0<i>1|-:a$<i>2|-:t$<i>8]"
+                        + "[(1-2)s:x|i:x|_1$<i>1<i>2|<>:a$<b>64<i>1<i>4<i>3]"
+                        + "[(3-4)s:h|i:h|_2$<i>3<i>4]"
+                        + "[(4-5)s:i|i:i|_3$<i>4<i>5]"
+                        + "[(6-7)s:j|i:j|_4$<i>6<i>7]"
+                        + "[(8-9)s:h|i:h|_5$<i>8<i>9]"
+                        + "[(9-10)s:i|i:i|_6$<i>9<i>10|<>:a$<b>64<i>9<i>12<i>8]"
+                        + "[(11-12)s:j|i:j|_7$<i>11<i>12]");
         ki.addDoc(fd);
 
         // Save documents
@@ -974,12 +992,15 @@
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         // <a>xx <e>hi j <e>hi j</e></e></a>
-        fd.addTV("base", "xx hi j hi j", "[(0-1)s:x|i:x|_0#0-1|<>:a#1-12$<i>8]"
-                + "[(1-2)s:x|i:x|_1#1-2]"
-                + "[(3-4)s:h|i:h|_2#3-4|<>:e#3-12$<i>8]"
-                + "[(4-5)s:i|i:i|_3#4-5]" + "[(6-7)s:j|i:j|_4#6-7]"
-                + "[(8-9)s:h|i:h|_5#8-9|<>:e#8-9$<i>8]"
-                + "[(9-10)s:i|i:i|_6#9-10]" + "[(11-12)s:j|i:j|_7#11-12]");
+        fd.addTV("base", "xx hi j hi j",
+                "[(0-1)s:x|i:x|_0$<i>0<i>1|<>:a$<b>64<i>1<i>12<i>8]"
+                        + "[(1-2)s:x|i:x|_1$<i>1<i>2]"
+                        + "[(3-4)s:h|i:h|_2$<i>3<i>4|<>:e$<b>64<i>3<i>12<i>8]"
+                        + "[(4-5)s:i|i:i|_3$<i>4<i>5]"
+                        + "[(6-7)s:j|i:j|_4$<i>6<i>7]"
+                        + "[(8-9)s:h|i:h|_5$<i>8<i>9|<>:e$<b>64<i>8<i>9<i>8]"
+                        + "[(9-10)s:i|i:i|_6$<i>9<i>10]"
+                        + "[(11-12)s:j|i:j|_7$<i>11<i>12]");
         ki.addDoc(fd);
     };