More tests on deserialized sequences
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index e15eeef..b8a3e52 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -382,8 +382,9 @@
 
 		SpanQueryWrapper sqw = this.fromJSON(operands.get(0));
 
-		if (sqw.maybeExtension())
+		if (sqw.maybeExtension()) {
 		    return sqw.setMin(min).setMax(max);
+		};
 
 		return new SpanRepetitionQueryWrapper(sqw, min, max);
 	    };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
index 3022adb..f9eb3ea 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
@@ -21,7 +21,8 @@
     protected boolean isNull = true,
 	              isOptional = false,
  	              isNegative = false,
-	              isEmpty = false;
+ 	              isEmpty = false,
+	              isExtendedToTheRight;
 
     // Serialize query to Lucene SpanQuery
     public SpanQuery toQuery () throws QueryException {
@@ -39,6 +40,8 @@
     // like in
     // "the [pos=ADJ]{0} tree"
     public boolean isNull () {
+	if (this.getMin() == 0 && this.getMax() == 0)
+	    return true;
 	return this.isNull;
     };
 
@@ -54,6 +57,15 @@
 	return this.isEmpty;
     };
 
+    // The subquery may exceed the right text offset due to an empty extension
+    // [base=tree][]{3,4}
+    // This makes it necessary to check the last position of the span
+    // for match testing
+    public boolean isExtendedToTheRight () {
+	return this.isExtendedToTheRight;
+    };
+
+
     // Check, if the query may be an anchor
     // in a SpanSequenceQueryWrapper
     public boolean maybeAnchor () {
@@ -69,6 +81,7 @@
 	return true;
     };
 
+    // Oposite to maybeAnchor - means "it is complicated"
     public boolean maybeExtension () {
 	return !this.maybeAnchor();
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
index 3b9763d..a6c5640 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRepetitionQueryWrapper.java
@@ -63,6 +63,7 @@
 	    min = 1;
 	    if (max == 0)
 		this.isNull = true;
+	    System.err.println("++++++++++++++++++++++++++++++");
 	};
 
 	this.min = min;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
index 297281e..1180aeb 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSequenceQueryWrapper.java
@@ -28,6 +28,10 @@
   TODO:
   Make isNegative work!
   Make isEmpty work!
+  Make isExtendedToTheRight work!
+
+  Probably the problemsolving should be done on attribute check
+  not on toQuery().
 */