Performance improvements
diff --git a/src/test/resources/queries/benchmark1.jsonld b/src/test/resources/queries/benchmark1.jsonld
new file mode 100644
index 0000000..79403b4
--- /dev/null
+++ b/src/test/resources/queries/benchmark1.jsonld
@@ -0,0 +1,25 @@
+{
+    "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+	"@type": "korap:group", 
+	"operation": "operation:position", 
+	"frame": "frame:contains",
+	"operands": [
+	    {
+		"@type": "korap:span",
+		"layer" : "c",
+		"foundry" : "cnx",
+		"key": "np"
+	    }, 
+	    {
+		"@type": "korap:token",
+		"wrap" : {
+		    "@type": "korap:term", 
+		    "foundry": "mate",
+		    "layer": "pos",
+		    "key" : "NE"
+		}
+	    }
+	]
+    }
+}
diff --git a/src/test/resources/queries/benchmark2.jsonld b/src/test/resources/queries/benchmark2.jsonld
new file mode 100644
index 0000000..81c1016
--- /dev/null
+++ b/src/test/resources/queries/benchmark2.jsonld
@@ -0,0 +1,20 @@
+{
+    "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+	"@type": "korap:token", 
+	"wrap" : {
+	    "@type": "korap:term", 
+	    "layer": "orth",
+	    "key" : "Buchstabe"
+	}
+    },
+    "meta" : {
+	"count": 100,
+	"cutOff": false,
+	"context":{
+	    "left": [ "token", 10 ],
+	    "right": [ "token", 10 ]
+	},
+	"startPage": 1
+    }
+}
diff --git a/src/test/resources/queries/benchmark3.jsonld b/src/test/resources/queries/benchmark3.jsonld
new file mode 100644
index 0000000..36acfe9
--- /dev/null
+++ b/src/test/resources/queries/benchmark3.jsonld
@@ -0,0 +1,27 @@
+{
+    "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+	"@type": "korap:group", 
+	"operation": "operation:sequence",
+	"operands": [
+	    {
+		"@type": "korap:token",
+		"wrap" : {
+		    "@type": "korap:term", 
+		    "foundry": "mate",
+		    "layer": "pos",
+		    "key" : "ADJA"
+		}
+	    },
+	    {
+		"@type": "korap:token",
+		"wrap" : {
+		    "@type": "korap:term", 
+		    "foundry": "mate",
+		    "layer": "pos",
+		    "key" : "NE"
+		}
+	    }
+	]
+    }
+}
diff --git a/src/test/resources/queries/bsp1.jsonld b/src/test/resources/queries/bsp1.jsonld
index 36fb042..5361a5c 100644
--- a/src/test/resources/queries/bsp1.jsonld
+++ b/src/test/resources/queries/bsp1.jsonld
@@ -1,146 +1,46 @@
 {
-  "@context" : {
-    "korap" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/",
-    "query" : "korap:query",
-    "meta" : "korap:meta",
-    "collections" : {
-      "@id" : "korap:collections",
-      "@container" : "@list"
-    },
-    "token" : "korap:token/",
-    "distance" : "korap:distance/",
-    "boundary" : "korap:boundary/",
-    "group" : "korap:group/",
-    "span" : "korap:span/",
-    "term" : "korap:term/",
-    "termGroup" : "korap:termGroup/",
-    "wrap" : "token:wrap",
-    "operation" : {
-      "@id" : "group:operation/",
-      "@type" : "@id"
-    },
-    "class" : {
-      "@id" : "group:class",
-      "@type" : "xsd:integer"
-    },
-    "operands" : {
-      "@id" : "group:operands",
-      "@container" : "@list"
-    },
-    "frame" : {
-      "@id" : "group:frame/",
-      "@type" : "@id"
-    },
-    "classRef" : {
-      "@id" : "group:classRef",
-      "@type" : "xsd:integer"
-    },
-    "spanRef" : {
-      "@id" : "group:spanRef",
-      "@type" : "xsd:integer"
-    },
-    "classRefOp" : {
-      "@id" : "group:classRefOp",
-      "@type" : "@id"
-    },
-    "min" : {
-      "@id" : "boundary:min",
-      "@type" : "xsd:integer"
-    },
-    "max" : {
-      "@id" : "boundary:max",
-      "@type" : "xsd:integer"
-    },
-    "exclude" : {
-      "@id" : "group:exclude",
-      "@type" : "xsd:boolean"
-    },
-    "distances" : {
-      "@id" : "group:distances",
-      "@container" : "@list"
-    },
-    "inOrder" : {
-      "@id" : "group:inOrder",
-      "@type" : "xsd:boolean"
-    },
-    "exclude" : {
-      "@id" : "group:exclude",
-      "@type" : "xsd:boolean"
-    },
-    "key" : {
-      "@id" : "korap:key",
-      "@type" : "xsd:string"
-    },
-    "foundry" : {
-      "@id" : "korap:foundry",
-      "@type" : "xsd:string"
-    },
-    "layer" : {
-      "@id" : "korap:layer",
-      "@type" : "xsd:string"
-    },
-    "value" : {
-      "@id" : "korap:value",
-      "@type" : "xsd:string"
-    },
-    "caseInsensitive" : {
-      "@id" : "term:caseInsensitive",
-      "@type" : "xsd:boolean"
-    },
-    "type" : {
-      "@id" : "term:type/",
-      "@type" : "@id"
-    },
-    "match" : {
-      "@id" : "term:match/",
-      "@type" : "@id"
-    },
-    "relation" : {
-      "@id" : "korap:relation/",
-      "@type" : "@id"
+    "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+	"@type": "korap:group", 
+	"operation": "operation:or",
+	"operands": [
+	    {
+		"@type": "korap:token", 
+		"wrap": {
+		    "@type": "korap:term", 
+		    "layer": "base",
+		    "key": "foo"
+		}
+	    }, 
+	    {
+		"@type": "korap:group", 
+		"min" : 0,
+		"operation": "operation:repetition",
+		"operands": [
+		    {
+			"@type": "korap:group", 
+			"operation" : "operation:sequence",
+			"operands": [
+			    {
+				"@type": "korap:token", 
+				"wrap": {
+				    "@type": "korap:term", 
+				    "key": "foo", 
+				    "layer" : "base"
+				}
+			    }, 
+			    {
+				"@type": "korap:token", 
+				"wrap": {
+				    "@type": "korap:term",
+				    "layer": "base",
+				    "key" : "bar"
+				}
+			    }
+			]
+		    }
+		]
+	    }
+	]
     }
-  },
-  "query": {
-    "@type": "korap:group", 
-    "operation": "operation:or",
-    "operands": [
-      {
-        "@type": "korap:token", 
-        "wrap": {
-          "@type": "korap:term", 
-	  "layer": "base",
-          "key": "foo"
-        }
-      }, 
-      {
-        "@type": "korap:group", 
-	"min" : 0,
-        "operation": "operation:repetition",
-        "operands": [
-          {
-            "@type": "korap:group", 
-            "operation" : "operation:sequence",
-            "operands": [
-              {
-                "@type": "korap:token", 
-                "wrap": {
-                  "@type": "korap:term", 
-                  "key": "foo", 
-                  "layer" : "base"
-                }
-              }, 
-              {
-                "@type": "korap:token", 
-                "wrap": {
-                  "@type": "korap:term",
-                  "layer": "base",
-                  "key" : "bar"
-                }
-              }
-            ]
-          }
-        ]
-      }
-    ]
-  }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/bsp19.jsonld b/src/test/resources/queries/bsp19.jsonld
index 5145e9f..1e12ed9 100644
--- a/src/test/resources/queries/bsp19.jsonld
+++ b/src/test/resources/queries/bsp19.jsonld
@@ -39,7 +39,7 @@
     },
     "meta" : {
 	"count": 25,
-	"cutOff": true,
+	"cutOff": false,
 	"context":{
 	    "left": [ "char", 110 ],
 	    "right": [ "char", 110 ]
diff --git a/src/test/resources/queries/bsp2.jsonld b/src/test/resources/queries/bsp2.jsonld
index 08ac500..9a3a076 100644
--- a/src/test/resources/queries/bsp2.jsonld
+++ b/src/test/resources/queries/bsp2.jsonld
@@ -1,142 +1,42 @@
 {
-  "@context" : {
-    "korap" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/",
-    "query" : "korap:query",
-    "meta" : "korap:meta",
-    "collections" : {
-      "@id" : "korap:collections",
-      "@container" : "@list"
-    },
-    "token" : "korap:token/",
-    "distance" : "korap:distance/",
-    "boundary" : "korap:boundary/",
-    "group" : "korap:group/",
-    "span" : "korap:span/",
-    "term" : "korap:term/",
-    "termGroup" : "korap:termGroup/",
-    "wrap" : "token:wrap",
-    "operation" : {
-      "@id" : "group:operation/",
-      "@type" : "@id"
-    },
-    "class" : {
-      "@id" : "group:class",
-      "@type" : "xsd:integer"
-    },
-    "operands" : {
-      "@id" : "group:operands",
-      "@container" : "@list"
-    },
-    "frame" : {
-      "@id" : "group:frame/",
-      "@type" : "@id"
-    },
-    "classRef" : {
-      "@id" : "group:classRef",
-      "@type" : "xsd:integer"
-    },
-    "spanRef" : {
-      "@id" : "group:spanRef",
-      "@type" : "xsd:integer"
-    },
-    "classRefOp" : {
-      "@id" : "group:classRefOp",
-      "@type" : "@id"
-    },
-    "min" : {
-      "@id" : "boundary:min",
-      "@type" : "xsd:integer"
-    },
-    "max" : {
-      "@id" : "boundary:max",
-      "@type" : "xsd:integer"
-    },
-    "exclude" : {
-      "@id" : "group:exclude",
-      "@type" : "xsd:boolean"
-    },
-    "distances" : {
-      "@id" : "group:distances",
-      "@container" : "@list"
-    },
-    "inOrder" : {
-      "@id" : "group:inOrder",
-      "@type" : "xsd:boolean"
-    },
-    "exclude" : {
-      "@id" : "group:exclude",
-      "@type" : "xsd:boolean"
-    },
-    "key" : {
-      "@id" : "korap:key",
-      "@type" : "xsd:string"
-    },
-    "foundry" : {
-      "@id" : "korap:foundry",
-      "@type" : "xsd:string"
-    },
-    "layer" : {
-      "@id" : "korap:layer",
-      "@type" : "xsd:string"
-    },
-    "value" : {
-      "@id" : "korap:value",
-      "@type" : "xsd:string"
-    },
-    "caseInsensitive" : {
-      "@id" : "term:caseInsensitive",
-      "@type" : "xsd:boolean"
-    },
-    "type" : {
-      "@id" : "term:type/",
-      "@type" : "@id"
-    },
-    "match" : {
-      "@id" : "term:match/",
-      "@type" : "@id"
-    },
-    "relation" : {
-      "@id" : "korap:relation/",
-      "@type" : "@id"
+    "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+    "query": {
+	"@type": "korap:group", 
+	"operation" : "operation:sequence",
+	"operands": [
+	    {
+		"@type": "korap:group", 
+		"operation": "operation:or",
+		"operands": [
+		    {
+			"@type": "korap:token", 
+			"wrap": {
+			    "@type": "korap:term", 
+			    "foundry": "mate", 
+			    "layer": "lemma", 
+			    "key" : "foo"
+			}
+		    }, 
+		    {
+			"@type": "korap:token", 
+			"wrap": {
+			    "@type": "korap:term", 
+			    "foundry": "mate", 
+			    "layer": "lemma",
+			    "key" : "bar"
+			}
+		    }
+		]
+	    }, 
+	    {
+		"@type": "korap:token", 
+		"wrap": {
+		    "@type": "korap:term", 
+		    "foundry": "mate", 
+		    "layer": "lemma",
+		    "key" : "foobar"
+		}
+	    }
+	]
     }
-  },
-  "query": {
-    "@type": "korap:group", 
-    "operation" : "operation:sequence",
-    "operands": [
-      {
-        "@type": "korap:group", 
-        "operation": "operation:or",
-        "operands": [
-          {
-            "@type": "korap:token", 
-            "wrap": {
-              "@type": "korap:term", 
-	      "foundry": "mate", 
-              "layer": "lemma", 
-              "key" : "foo"
-            }
-          }, 
-          {
-            "@type": "korap:token", 
-            "wrap": {
-              "@type": "korap:term", 
-	      "foundry": "mate", 
-              "layer": "lemma",
-              "key" : "bar"
-            }
-          }
-        ]
-      }, 
-      {
-        "@type": "korap:token", 
-        "wrap": {
-          "@type": "korap:term", 
-	  "foundry": "mate", 
-          "layer": "lemma",
-          "key" : "foobar"
-        }
-      }
-    ]
-  }
 }
diff --git a/src/test/resources/queries/cosmas10.json b/src/test/resources/queries/cosmas10.json
index d958810..08361d2 100644
--- a/src/test/resources/queries/cosmas10.json
+++ b/src/test/resources/queries/cosmas10.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:sequence",
@@ -38,4 +38,4 @@
       }
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas10b.json b/src/test/resources/queries/cosmas10b.json
index 6f84a2b..618a25f 100644
--- a/src/test/resources/queries/cosmas10b.json
+++ b/src/test/resources/queries/cosmas10b.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:sequence",
diff --git a/src/test/resources/queries/cosmas16.json b/src/test/resources/queries/cosmas16.json
index 61333fd..b392098 100644
--- a/src/test/resources/queries/cosmas16.json
+++ b/src/test/resources/queries/cosmas16.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:submatch",
@@ -28,4 +28,4 @@
       } ]
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas17.json b/src/test/resources/queries/cosmas17.json
index 32e073b..1eec888 100644
--- a/src/test/resources/queries/cosmas17.json
+++ b/src/test/resources/queries/cosmas17.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:position",
@@ -18,4 +18,4 @@
       }
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas20.json b/src/test/resources/queries/cosmas20.json
index 32887c7..3a4e040 100644
--- a/src/test/resources/queries/cosmas20.json
+++ b/src/test/resources/queries/cosmas20.json
@@ -27,4 +27,4 @@
       } ]
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas3.json b/src/test/resources/queries/cosmas3.json
index 2c77f42..d86045e 100644
--- a/src/test/resources/queries/cosmas3.json
+++ b/src/test/resources/queries/cosmas3.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:sequence",
@@ -28,4 +28,4 @@
       }
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas4.json b/src/test/resources/queries/cosmas4.json
index 2040995..2dff321 100644
--- a/src/test/resources/queries/cosmas4.json
+++ b/src/test/resources/queries/cosmas4.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:sequence",
@@ -37,4 +37,4 @@
       }
     } ]
   }
-}
\ No newline at end of file
+}
diff --git a/src/test/resources/queries/cosmas4b.json b/src/test/resources/queries/cosmas4b.json
index 8fe2344..4b44753 100644
--- a/src/test/resources/queries/cosmas4b.json
+++ b/src/test/resources/queries/cosmas4b.json
@@ -1,5 +1,5 @@
 {
-  "context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
   "query" : {
     "@type" : "korap:group",
     "operation" : "operation:sequence",
diff --git a/src/test/resources/queries/cosmas5.json b/src/test/resources/queries/cosmas5.json
new file mode 100644
index 0000000..a96845d
--- /dev/null
+++ b/src/test/resources/queries/cosmas5.json
@@ -0,0 +1,55 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query" : {
+    "@type" : "korap:group",
+    "operation" : "operation:sequence",
+    "inOrder" : true,
+    "distances" : [ {
+      "@type" : "korap:distance",
+      "key" : "w",
+      "min" : 0,
+      "max" : 5
+    } ],
+    "operands" : [ {
+      "@type" : "korap:group",
+      "operation" : "operation:sequence",
+      "inOrder" : true,
+      "distances" : [ {
+        "@type" : "korap:distance",
+        "key" : "w",
+        "min" : 1,
+        "max" : 3
+      }, {
+        "@type" : "korap:distance",
+        "key" : "s",
+        "min" : 0,
+        "max" : 1
+      } ],
+      "operands" : [ {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "key" : "das",
+          "layer" : "orth",
+          "match" : "match:eq"
+        }
+      }, {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "key" : "Buch",
+          "layer" : "orth",
+          "match" : "match:eq"
+        }
+      } ]
+    }, {
+      "@type" : "korap:token",
+      "wrap" : {
+        "@type" : "korap:term",
+        "key" : "Tisch",
+        "layer" : "orth",
+        "match" : "match:eq"
+      }
+    } ]
+  }
+}
\ No newline at end of file
diff --git a/src/test/resources/queries/cosmas6.json b/src/test/resources/queries/cosmas6.json
new file mode 100644
index 0000000..06a9726
--- /dev/null
+++ b/src/test/resources/queries/cosmas6.json
@@ -0,0 +1,55 @@
+{
+  "@context" : "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld",
+  "query" : {
+    "@type" : "korap:group",
+    "operation" : "operation:sequence",
+    "inOrder" : true,
+    "distances" : [ {
+      "@type" : "korap:distance",
+      "key" : "w",
+      "min" : 0,
+      "max" : 5
+    } ],
+    "operands" : [ {
+      "@type" : "korap:token",
+      "wrap" : {
+        "@type" : "korap:term",
+        "key" : "Tisch",
+        "layer" : "orth",
+        "match" : "match:eq"
+      }
+    }, {
+      "@type" : "korap:group",
+      "operation" : "operation:sequence",
+      "inOrder" : true,
+      "distances" : [ {
+        "@type" : "korap:distance",
+        "key" : "w",
+        "min" : 1,
+        "max" : 3
+      }, {
+        "@type" : "korap:distance",
+        "key" : "s",
+        "min" : 0,
+        "max" : 1
+      } ],
+      "operands" : [ {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "key" : "das",
+          "layer" : "orth",
+          "match" : "match:eq"
+        }
+      }, {
+        "@type" : "korap:token",
+        "wrap" : {
+          "@type" : "korap:term",
+          "key" : "Buch",
+          "layer" : "orth",
+          "match" : "match:eq"
+        }
+      } ]
+    } ]
+  }
+}
\ No newline at end of file