Prepare SpanQueryWrapper for empty token support
diff --git a/CHANGES b/CHANGES
index 3b0f651..7cf9e58 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,7 @@
-0.45 2014-10-01
+0.45 2014-10-06
         - [bugfix] Correctly respond request in JSON results (diewald)
+        - [cleanup] Made SpanQueryWrapper an abstract class instead
+	  of an interface (diewald)
 
 0.44.1 2014-09-29
         - [cleanup] Prepare test suite for publication (diewald)
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index e693b48..f07ce51 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -102,7 +102,7 @@
 	};
     };
 
-    public SpanQueryWrapperInterface fromJSON (String jsonString) throws QueryException {
+    public SpanQueryWrapper fromJSON (String jsonString) throws QueryException {
 	JsonNode json;
 	try {
 	    json = this.json.readValue(jsonString, JsonNode.class);
@@ -122,7 +122,7 @@
     // TODO: Use the shortcuts implemented in this class instead of the wrapper constructors
     // TODO: Check for isArray()
     // TODO: Rename this span context!
-    public SpanQueryWrapperInterface fromJSON (JsonNode json) throws QueryException {
+    public SpanQueryWrapper fromJSON (JsonNode json) throws QueryException {
 
 	int number = 0;
 
@@ -374,6 +374,7 @@
 		if (min > max)
 		    max = max;
 
+		// This may be an empty repetitor
 		return new SpanRepetitionQueryWrapper(
 		    this.fromJSON(operands.get(0)), min, max
 		);
@@ -420,8 +421,9 @@
 	    );
 
 	case "korap:token":
+
 	    if (!json.has("wrap"))
-		throw new QueryException("Empty Tokens are not supported yet");
+		return new SpanEmptyTokenWrapper();
 
 	    return this._segFromJSON(json.get("wrap"));
 
@@ -436,7 +438,7 @@
 
 
 
-    private SpanQueryWrapperInterface _segFromJSON (JsonNode json) throws QueryException {
+    private SpanQueryWrapper _segFromJSON (JsonNode json) throws QueryException {
 	String type = json.get("@type").asText();
 
 	if (DEBUG)
@@ -477,7 +479,7 @@
 	    case "relation:and":
 
 		for (JsonNode operand : json.get("operands")) {
-		    SpanQueryWrapperInterface part = this._segFromJSON(operand);
+		    SpanQueryWrapper part = this._segFromJSON(operand);
 		    if (part instanceof SpanAlterQueryWrapper) {
 			ssegqw.with((SpanAlterQueryWrapper) part);			
 		    }
@@ -506,7 +508,7 @@
 
 
 
-    private SpanQueryWrapperInterface _termFromJSON (JsonNode json) throws QueryException {
+    private SpanQueryWrapper _termFromJSON (JsonNode json) throws QueryException {
 	if (!json.has("key") || json.get("key").asText().length() < 1)
 	    throw new QueryException("Terms and spans have to provide key attributes");
 	    
@@ -681,9 +683,9 @@
      * Create a segment alternation query object.
      * @param terms[] An array of alternative terms.
      */
-    public SpanAlterQueryWrapper or (SpanQueryWrapperInterface ... terms) {
+    public SpanAlterQueryWrapper or (SpanQueryWrapper ... terms) {
 	SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
-	for (SpanQueryWrapperInterface t : terms) {
+	for (SpanQueryWrapper t : terms) {
 	    ssaq.or(t);
 	};
 	return ssaq;
@@ -711,9 +713,9 @@
      * Create a sequence of segments query object.
      * @param terms[] An array of segment defining terms.
      */
-    public SpanSequenceQueryWrapper seq (SpanQueryWrapperInterface ... terms) {
+    public SpanSequenceQueryWrapper seq (SpanQueryWrapper ... terms) {
 	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper(this.field);
-	for (SpanQueryWrapperInterface t : terms) {
+	for (SpanQueryWrapper t : terms) {
 	    sssq.append(t);
 	};
 	return sssq;
@@ -732,8 +734,8 @@
     public SpanSequenceQueryWrapper seq (Object ... terms) {
 	SpanSequenceQueryWrapper ssq = new SpanSequenceQueryWrapper(this.field);
 	for (Object t : terms) {
-	    if (t instanceof SpanQueryWrapperInterface) {
-		ssq.append((SpanQueryWrapperInterface) t);
+	    if (t instanceof SpanQueryWrapper) {
+		ssq.append((SpanQueryWrapper) t);
 	    }
 	    else if (t instanceof SpanRegexQueryWrapper) {
 		ssq.append((SpanRegexQueryWrapper) t);
@@ -756,79 +758,78 @@
      * @param embedded A SpanQuery that is wrapped in the element.
      */
     @Deprecated
-    public SpanWithinQueryWrapper within (SpanQueryWrapperInterface element,
-					  SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper within (SpanQueryWrapper element,
+					  SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded);
     };
 
-    public SpanWithinQueryWrapper contains (SpanQueryWrapperInterface element,
-					  SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper contains (SpanQueryWrapper element,
+					  SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded, WITHIN);
     };
 
-    public SpanWithinQueryWrapper startswith (SpanQueryWrapperInterface element,
-					      SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper startswith (SpanQueryWrapper element,
+					      SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded, STARTSWITH);
     };
 
-    public SpanWithinQueryWrapper endswith (SpanQueryWrapperInterface element,
-					    SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper endswith (SpanQueryWrapper element,
+					    SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded, ENDSWITH);
     };
 
-    public SpanWithinQueryWrapper overlaps (SpanQueryWrapperInterface element,
-					    SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper overlaps (SpanQueryWrapper element,
+					    SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded, OVERLAP);
     }; 
 
-    public SpanWithinQueryWrapper matches (SpanQueryWrapperInterface element,
-					   SpanQueryWrapperInterface embedded) {
+    public SpanWithinQueryWrapper matches (SpanQueryWrapper element,
+					   SpanQueryWrapper embedded) {
 	return new SpanWithinQueryWrapper(element, embedded, MATCH);
     }; 
 
     // Class
-    public SpanClassQueryWrapper _ (byte number, SpanQueryWrapperInterface element) {
+    public SpanClassQueryWrapper _ (byte number, SpanQueryWrapper element) {
 	return new SpanClassQueryWrapper(element, number);
     };
 
-    public SpanClassQueryWrapper _ (int number, SpanQueryWrapperInterface element) {
+    public SpanClassQueryWrapper _ (int number, SpanQueryWrapper element) {
 	return new SpanClassQueryWrapper(element, number);
     };
 
-    public SpanClassQueryWrapper _ (short number, SpanQueryWrapperInterface element) {
+    public SpanClassQueryWrapper _ (short number, SpanQueryWrapper element) {
 	return new SpanClassQueryWrapper(element, number);
     };
 
-    public SpanClassQueryWrapper _ (SpanQueryWrapperInterface element) {
+    public SpanClassQueryWrapper _ (SpanQueryWrapper element) {
 	return new SpanClassQueryWrapper(element);
     };
 
     // MatchModify
-    public SpanMatchModifyQueryWrapper shrink (byte number, SpanQueryWrapperInterface element) {
+    public SpanMatchModifyQueryWrapper shrink (byte number, SpanQueryWrapper element) {
 	return new SpanMatchModifyQueryWrapper(element, number);
     };
 
-    public SpanMatchModifyQueryWrapper shrink (int number, SpanQueryWrapperInterface element) {
+    public SpanMatchModifyQueryWrapper shrink (int number, SpanQueryWrapper element) {
 	return new SpanMatchModifyQueryWrapper(element, number);
     };
 
-    public SpanMatchModifyQueryWrapper shrink (short number, SpanQueryWrapperInterface element) {
+    public SpanMatchModifyQueryWrapper shrink (short number, SpanQueryWrapper element) {
 	return new SpanMatchModifyQueryWrapper(element, number);
     };
 
-    public SpanMatchModifyQueryWrapper shrink (SpanQueryWrapperInterface element) {
+    public SpanMatchModifyQueryWrapper shrink (SpanQueryWrapper element) {
 	return new SpanMatchModifyQueryWrapper(element);
     };
 
     // Repetition
-    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapperInterface element, int exact) {
+    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element, int exact) {
 	return new SpanRepetitionQueryWrapper(element, exact);
     };
 
-    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapperInterface element, int min, int max) {
+    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element, int min, int max) {
 	return new SpanRepetitionQueryWrapper(element, min, max);
     };
 
-
     // split
 };
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index 6d14e7e..bdb059d 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -3,7 +3,7 @@
 import java.io.*;
 
 import org.apache.lucene.search.spans.SpanQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.KorapCollection;
 import de.ids_mannheim.korap.KorapIndex;
 import de.ids_mannheim.korap.KorapResult;
@@ -54,7 +54,7 @@
 	    // "query" value
 	    if (this.request.has("query")) {
 		try {
-		    SpanQueryWrapperInterface queryIface = new KorapQuery("tokens").fromJSON(this.request.get("query"));
+		    SpanQueryWrapper queryIface = new KorapQuery("tokens").fromJSON(this.request.get("query"));
 		    
 		    this.query = queryIface.toQuery();
 		    if (queryIface.isOptional())
@@ -116,7 +116,7 @@
     };
 
     // Maybe accept queryWrapperStuff
-    public KorapSearch (SpanQueryWrapperInterface sqwi) {
+    public KorapSearch (SpanQueryWrapper sqwi) {
 	this.query = sqwi.toQuery();
     };
 
@@ -150,7 +150,7 @@
 	return this.request;
     };
 
-    public KorapSearch setQuery (SpanQueryWrapperInterface sqwi) {
+    public KorapSearch setQuery (SpanQueryWrapper sqwi) {
 	this.query = sqwi.toQuery();
 	return this;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
index 7f6f394..2a04554 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAlterQueryWrapper.java
@@ -3,7 +3,7 @@
 import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanWildcardQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
@@ -12,13 +12,10 @@
 
 import java.util.*;
 
-public class SpanAlterQueryWrapper implements SpanQueryWrapperInterface {
+public class SpanAlterQueryWrapper extends SpanQueryWrapper {
     private String field;
     private SpanQuery query;
     private List<SpanQuery> alternatives;
-    private boolean isNull = true;
-    private boolean isOptional = false;
-    private boolean isNegative = false;
 
     public SpanAlterQueryWrapper (String field) {
 	this.field = field;
@@ -50,7 +47,7 @@
 	return this;
     };
 
-    public SpanAlterQueryWrapper or (SpanQueryWrapperInterface term) {
+    public SpanAlterQueryWrapper or (SpanQueryWrapper term) {
 	if (term.isNull())
 	    return this;
 
@@ -94,16 +91,4 @@
 	};
 	return (SpanQuery) soquery;
     };
-
-    public boolean isOptional () {
-	return this.isOptional;
-    };
-
-    public boolean isNull () {
-	return this.isNull;
-    };
-
-    public boolean isNegative () {
-	return this.isNegative;
-    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
index bb43edc..865c61e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanClassQueryWrapper.java
@@ -3,31 +3,31 @@
 import org.apache.lucene.search.spans.SpanQuery;
 
 import de.ids_mannheim.korap.query.SpanClassQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import java.util.*;
 
 
-public class SpanClassQueryWrapper implements SpanQueryWrapperInterface {
-    private SpanQueryWrapperInterface subquery;
+public class SpanClassQueryWrapper extends SpanQueryWrapper {
+    private SpanQueryWrapper subquery;
     private byte number = (byte) 0;
 
-    public SpanClassQueryWrapper (SpanQueryWrapperInterface subquery, byte number) {
+    public SpanClassQueryWrapper (SpanQueryWrapper subquery, byte number) {
 	this.subquery = subquery;
 	this.number = number;
     };
 
-    public SpanClassQueryWrapper (SpanQueryWrapperInterface subquery, short number) {
+    public SpanClassQueryWrapper (SpanQueryWrapper subquery, short number) {
 	this.subquery = subquery;
 	this.number = (byte) number;
     };
 
-    public SpanClassQueryWrapper (SpanQueryWrapperInterface subquery, int number) {
+    public SpanClassQueryWrapper (SpanQueryWrapper subquery, int number) {
 	this.subquery = subquery;
 	this.number = (byte) number;
     };
 
-    public SpanClassQueryWrapper (SpanQueryWrapperInterface subquery) {
+    public SpanClassQueryWrapper (SpanQueryWrapper subquery) {
 	this.subquery = subquery;
 	this.number = (byte) 0;
     };
@@ -35,6 +35,9 @@
     public SpanQuery toQuery () {
 	if (this.subquery.isNull())
 	    return (SpanQuery) null;
+
+	// TODO: If this.subquery.isNegative(), it may be an Expansion!
+	// SpanExpansionQuery(x, y.negative, min, max. direction???, classNumber, true)
 	
 	if (this.number == (byte) 0) {
 	    return new SpanClassQuery((SpanQuery) this.subquery.toQuery());
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
index 4add693..92a7090 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanElementQueryWrapper.java
@@ -3,9 +3,9 @@
 import org.apache.lucene.search.spans.SpanQuery;
 
 import de.ids_mannheim.korap.query.SpanElementQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
-public class SpanElementQueryWrapper implements SpanQueryWrapperInterface {
+public class SpanElementQueryWrapper extends SpanQueryWrapper {
     String element;
     String field;
 
@@ -18,15 +18,7 @@
 	return (SpanQuery) new SpanElementQuery(this.field, this.element);
     };
 
-    public boolean isOptional () {
-	return false;
-    };
-
     public boolean isNull () {
 	return false;
     };
-
-    public boolean isNegative () {
-	return false;
-    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanEmptyTokenWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanEmptyTokenWrapper.java
new file mode 100644
index 0000000..a4691f0
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanEmptyTokenWrapper.java
@@ -0,0 +1,12 @@
+package de.ids_mannheim.korap.query.wrap;
+
+import org.apache.lucene.search.spans.SpanQuery;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
+
+import java.util.*;
+
+/**
+ * Implement an empty token
+ */
+public class SpanEmptyTokenWrapper extends SpanQueryWrapper {
+};
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
index 252ee0a..8e9a812 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanMatchModifyQueryWrapper.java
@@ -3,31 +3,31 @@
 import org.apache.lucene.search.spans.SpanQuery;
 
 import de.ids_mannheim.korap.query.SpanMatchModifyClassQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import java.util.*;
 
 
-public class SpanMatchModifyQueryWrapper implements SpanQueryWrapperInterface {
-    private SpanQueryWrapperInterface subquery;
+public class SpanMatchModifyQueryWrapper extends SpanQueryWrapper {
+    private SpanQueryWrapper subquery;
     private byte number;
 
-    public SpanMatchModifyQueryWrapper (SpanQueryWrapperInterface subquery, byte number) {
+    public SpanMatchModifyQueryWrapper (SpanQueryWrapper subquery, byte number) {
 	this.subquery = subquery;
 	this.number = number;
     };
 
-    public SpanMatchModifyQueryWrapper (SpanQueryWrapperInterface subquery, short number) {
+    public SpanMatchModifyQueryWrapper (SpanQueryWrapper subquery, short number) {
 	this.subquery = subquery;
 	this.number = (byte) number;
     };
 
-    public SpanMatchModifyQueryWrapper (SpanQueryWrapperInterface subquery, int number) {
+    public SpanMatchModifyQueryWrapper (SpanQueryWrapper subquery, int number) {
 	this.subquery = subquery;
 	this.number = (byte) number;
     };
 
-    public SpanMatchModifyQueryWrapper (SpanQueryWrapperInterface subquery) {
+    public SpanMatchModifyQueryWrapper (SpanQueryWrapper subquery) {
 	this.subquery = subquery;
 	this.number = (byte) 0;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQuantifierQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQuantifierQueryWrapper.java
index f6d3718..1926310 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQuantifierQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQuantifierQueryWrapper.java
@@ -5,12 +5,12 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.Query;
 
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import org.apache.lucene.search.spans.SpanQuery;
 
 // This might be irrelevant now with repetition!
 
-public class SpanQuantifierQueryWrapper implements SpanQueryWrapperInterface {
+public class SpanQuantifierQueryWrapper extends SpanQueryWrapper {
     private String field;
 
     public SpanQuantifierQueryWrapper (String field) {
@@ -21,19 +21,10 @@
 	return (SpanQuery) null;
     };
 
-    public boolean isOptional () {
-	return false;
-    };
-
     public boolean isNull () {
 	return false;
     };
 
-    public boolean isNegative () {
-	return false;
-    };
-
-
     /*
 
 Only support spans with minimal one occurrence and then
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
new file mode 100644
index 0000000..30fe7b9
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapper.java
@@ -0,0 +1,56 @@
+package de.ids_mannheim.korap.query.wrap;
+
+import org.apache.lucene.search.spans.SpanQuery;
+
+// TODO: Add warning and error
+
+/**
+ * A wrapper class for Lucene Spanqueries that add certain information
+ * to the queries, necessary for correct deserialization of nested queries.
+ *
+ * @author Nils Diewald
+ */
+public class SpanQueryWrapper {
+    protected boolean isNull = true,
+	              isOptional = false,
+	              isNegative = false;
+    protected int min = 1,
+	          max = 1;
+
+    // Serialize query to Lucene SpanQuery
+    public SpanQuery toQuery () {
+	return (SpanQuery) null;
+    };
+
+    // The subquery is not necessary, like in
+    // "the [pos=ADJ]? tree"
+    // The adjective can be there, but it's not necessary
+    public boolean isOptional () {
+	return this.isOptional;
+    };
+
+    // The subquery won't match anything at all,
+    // like in
+    // "the [pos=ADJ]{0} tree"
+    public boolean isNull () {
+	return this.isNull;
+    };
+
+    // The subquery should match if the condition does not hold true like in
+    // "the [base!=tree]"
+    public boolean isNegative () {
+	return this.isNegative;
+    };
+
+    // Repetition queries may be more specific regarding repetition
+    // This is a minimum repetition value
+    public int min () {
+	return this.min;
+    };
+
+    // Repetition queries may be more specific regarding repetition
+    // This is a maximum repetition value
+    public int max () {
+	return this.max;
+    };
+};
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapperInterface.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapperInterface.java
deleted file mode 100644
index 9a24a50..0000000
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanQueryWrapperInterface.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package de.ids_mannheim.korap.query.wrap;
-
-import org.apache.lucene.search.spans.SpanQuery;
-
-// Todo: Make this an abstract class to deal with regexes
-// in a parent abstract class!
-// Add warning and error
-
-public interface SpanQueryWrapperInterface {
-    public SpanQuery toQuery    ();
-    public boolean   isOptional ();
-    public boolean   isNull     ();
-    public boolean   isNegative ();
-};
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRegexQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRegexQueryWrapper.java
index 8be32cc..d39a960 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRegexQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanRegexQueryWrapper.java
@@ -5,6 +5,7 @@
 import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper;
 import org.apache.lucene.util.automaton.RegExp;
 import org.apache.lucene.index.Term;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import java.util.*;
 
@@ -12,7 +13,7 @@
   TODO: Don't allow queries like ".*?"!!!
 */
 
-public class SpanRegexQueryWrapper {
+public class SpanRegexQueryWrapper extends SpanQueryWrapper {
     private SpanQuery query;
 
     public SpanRegexQueryWrapper (String field, String re) {
@@ -43,15 +44,7 @@
 	return this.query;
     };
 
-    public boolean isOptional () {
-	return false;
-    };
-
     public boolean isNull () {
 	return false;
     };
-
-    public boolean isNegative () {
-	return false;
-    };
 };
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 3ad592d..b46d929 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
@@ -3,22 +3,21 @@
 import org.apache.lucene.search.spans.SpanQuery;
 
 import de.ids_mannheim.korap.query.SpanRepetitionQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 
-public class SpanRepetitionQueryWrapper implements SpanQueryWrapperInterface {
-    private SpanQueryWrapperInterface subquery;
-    private int min = 1;
-    private int max = 1;
-    private boolean isOptional = false;
-    private boolean isNull = false;
+public class SpanRepetitionQueryWrapper extends SpanQueryWrapper {
+    private SpanQueryWrapper subquery;
 
-    public SpanRepetitionQueryWrapper (SpanQueryWrapperInterface subquery, int exact) {
+    // This is for exact enumbered repetition, like in a{3}
+    public SpanRepetitionQueryWrapper (SpanQueryWrapper subquery, int exact) {
 	this.subquery = subquery;
 
 	if (exact < 1 || this.subquery.isNull()) {
 	    this.isNull = true;
 	    this.isOptional = true;
+	    this.min = 0;
+	    this.max = 0;
 	    return;
 	};
 	
@@ -26,12 +25,18 @@
 	this.max = exact;
     };
 
-    public SpanRepetitionQueryWrapper (SpanQueryWrapperInterface subquery, int min, int max) {
+    // This is for a range of repetitions, like in a{2,3}, a{,4}, a{3,}, a+, a*, a?
+    public SpanRepetitionQueryWrapper (SpanQueryWrapper subquery, int min, int max) {
+
 	this.subquery = subquery;
 
+	// Subquery may be an empty token
 	if (this.subquery.isNull()) {
 	    this.isNull = true;
 	    return;
+	}
+	else {
+	    this.isNull = false;
 	};
 	
 	if (min == 0) {
@@ -40,24 +45,30 @@
 	    if (max == 0)
 		this.isNull = true;
 	};
+
 	this.min = min;
 	this.max = max;
     };
 
+
+    // Serialize to Lucene SpanQuery
     public SpanQuery toQuery () {
+
+	// The query is null
 	if (this.isNull)
 	    return (SpanQuery) null;
+
+	// The query is not a repetition query at all, but may be optional
 	if (this.min == 1 && this.max == 1)
 	    return this.subquery.toQuery();
-	return new SpanRepetitionQuery(this.subquery.toQuery(), this.min, this.max, true);
-    };
 
-    public boolean isOptional () {
-	return this.isOptional;
-    };
-
-    public boolean isNull () {
-	return this.isNull;
+	// That's a fine repetition query
+	return new SpanRepetitionQuery(
+	    this.subquery.toQuery(),
+	    this.min,
+	    this.max,
+	    true
+	);
     };
 
     public boolean isNegative () {
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
index e72c566..21032a9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSegmentQueryWrapper.java
@@ -8,6 +8,7 @@
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.SpanNotQuery;
 import org.apache.lucene.search.spans.SpanOrQuery;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanWildcardQueryWrapper;
 import de.ids_mannheim.korap.query.SpanSegmentQuery;
@@ -21,12 +22,10 @@
  * regular expressions and alternatives. These elements can also be excluded.
  */
 
-public class SpanSegmentQueryWrapper implements SpanQueryWrapperInterface {
+public class SpanSegmentQueryWrapper extends SpanQueryWrapper {
     public ArrayList<SpanQuery> inclusive;
     public ArrayList<SpanQuery> exclusive;
     private String field;
-    private boolean isNull = true;
-    private boolean isNegative = false;
 
     /**
      * Constructor.
@@ -220,10 +219,6 @@
 	return false;
     };
 
-    public boolean isNull () {
-	return this.isNull;
-    };
-
     public boolean isNegative () {
 	if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
 	    return true;
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 b316fdf..2afb15b 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
@@ -5,8 +5,10 @@
 import de.ids_mannheim.korap.query.SpanElementQuery;
 import de.ids_mannheim.korap.query.SpanNextQuery;
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
+import de.ids_mannheim.korap.query.SpanExpansionQuery;
 import de.ids_mannheim.korap.query.SpanMultipleDistanceQuery;
 
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanAlterQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
@@ -15,7 +17,6 @@
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -26,9 +27,11 @@
 
 
 /**
+ * Deserialize complexe sequence queries to Lucene SpanQueries.
+ *
  * @author Nils Diewald
  */
-public class SpanSequenceQueryWrapper implements SpanQueryWrapperInterface {
+public class SpanSequenceQueryWrapper extends SpanQueryWrapper {
     private String field;
     private ArrayList<SpanQuery> segments;
     private ArrayList<DistanceConstraint> constraints;
@@ -37,15 +40,13 @@
     private final static Logger log = LoggerFactory.getLogger(SpanSequenceQueryWrapper.class);
 
     // This advices the java compiler to ignore all loggings
-    public static final boolean DEBUG = false;
+    public static final boolean DEBUG = true;
     
     private boolean
 	isInOrder = true,
-	isNull = true,
 	isOptional = true,
 	lastIsOptional = false,
-	firstIsOptional = false,
-	isNegative = false;
+	firstIsOptional = false;
 
     public SpanSequenceQueryWrapper (String field) {
 	this.field = field;
@@ -70,7 +71,7 @@
 	this.isNull = false;
     };
 
-    public SpanSequenceQueryWrapper (String field, SpanQueryWrapperInterface sswq) {
+    public SpanSequenceQueryWrapper (String field, SpanQueryWrapper sswq) {
 	this(field);
 
 	if (!sswq.isNull()) {
@@ -141,6 +142,7 @@
 
 	    SpanAlterQueryWrapper saqw = new SpanAlterQueryWrapper(field, query);
 	    SpanSequenceQueryWrapper ssqw = new SpanSequenceQueryWrapper(field, query);
+
 	    // Remove last element of the list and prepend it
 	    ssqw.prepend(this.segments.remove(this.segments.size() - 1));
 	    saqw.or(ssqw);
@@ -164,22 +166,30 @@
 	return this;
     };
 
-    public SpanSequenceQueryWrapper append (SpanQueryWrapperInterface ssq) {
+    public SpanSequenceQueryWrapper append (SpanQueryWrapper ssq) {
+
+	if (DEBUG)
+	    log.trace("Try to append query {}", ssq.toString());
+
 	if (!ssq.isNull()) {
 
+	    if (DEBUG)
+		log.trace("THe query {} is not null", ssq.toString());
+
 	    if (ssq.isNegative())
 		this.isNegative = true;
 	    
 	    SpanQuery appendQuery = ssq.toQuery();
 	    if (!ssq.isOptional()) {
 		if (DEBUG)
-		    log.trace("Append non-opt query to non-opt query " +
+		    log.trace("Append non-opt query to non-opt query {}",
 			      appendQuery.toString());
 		return this.append(appendQuery);
 	    };
 	    
 	    // Situation is ab? or a?b?
 	    if (this.segments.size() != 0) {
+
 		// Remove last element of the list and prepend it
 		SpanQuery lastQuery = this.segments.remove(this.segments.size() - 1);
 		SpanAlterQueryWrapper saqw = new SpanAlterQueryWrapper(field, lastQuery);
@@ -191,12 +201,12 @@
 		    saqw.or(appendQuery);
 		    // last stays optional
 		    if (DEBUG)
-			log.trace("Append opt query to opt query " +
+			log.trace("Append opt query to opt query {}",
 				  appendQuery.toString());
 
 		}
 		else if (DEBUG) {
-		    log.trace("Append opt query to non-opt query " +
+		    log.trace("Append opt query to non-opt query {}",
 			      appendQuery.toString());
 		};
 
@@ -209,7 +219,7 @@
 		this.segments.add(appendQuery);
 
 		if (DEBUG)
-		    log.trace("Append opt query " +
+		    log.trace("Append opt query {}",
 			      appendQuery.toString());
 
 		// Update boundary optionality
@@ -265,7 +275,7 @@
 	return this;
     };
 
-    public SpanSequenceQueryWrapper prepend (SpanQueryWrapperInterface ssq) {
+    public SpanSequenceQueryWrapper prepend (SpanQueryWrapper ssq) {
 	if (!ssq.isNull()) {
 
 	    if (ssq.isNegative())
@@ -436,16 +446,4 @@
 	    return false;
 	return true;
     };
-
-    public boolean isOptional () {
-	return this.isOptional;
-    };
-
-    public boolean isNull () {
-	return this.isNull;
-    };
-
-    public boolean isNegative () {
-	return this.isNegative;
-    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWildcardQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWildcardQueryWrapper.java
index 38d60ce..87d777a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWildcardQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWildcardQueryWrapper.java
@@ -3,11 +3,12 @@
 import org.apache.lucene.search.WildcardQuery;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import org.apache.lucene.index.Term;
 
 import java.util.*;
 
-public class SpanWildcardQueryWrapper {
+public class SpanWildcardQueryWrapper extends SpanQueryWrapper {
     private SpanQuery query;
 
     public SpanWildcardQueryWrapper (String field, String wc) {
@@ -29,15 +30,7 @@
 	return this.query;
     };
 
-    public boolean isOptional () {
-	return false;
-    };
-
     public boolean isNull () {
 	return false;
     };
-
-    public boolean isNegative () {
-	return false;
-    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
index d67505c..0707882 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithinQueryWrapper.java
@@ -4,7 +4,7 @@
 import de.ids_mannheim.korap.query.wrap.SpanSegmentQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanRegexQueryWrapper;
 import de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import java.util.*;
 
@@ -51,13 +51,12 @@
 */
 
 
-public class SpanWithinQueryWrapper implements SpanQueryWrapperInterface {
-    private SpanQueryWrapperInterface element;
-    private SpanQueryWrapperInterface wrap;
+public class SpanWithinQueryWrapper extends SpanQueryWrapper {
+    private SpanQueryWrapper element;
+    private SpanQueryWrapper wrap;
     private byte flag;
-    private boolean isNull = true;
 
-    public SpanWithinQueryWrapper (SpanQueryWrapperInterface element, SpanQueryWrapperInterface wrap) {
+    public SpanWithinQueryWrapper (SpanQueryWrapper element, SpanQueryWrapper wrap) {
 	this.element = element;
 	this.wrap = wrap;
 
@@ -68,7 +67,7 @@
 	    this.isNull = false;
     };
 
-    public SpanWithinQueryWrapper (SpanQueryWrapperInterface element, SpanQueryWrapperInterface wrap, byte flag) {
+    public SpanWithinQueryWrapper (SpanQueryWrapper element, SpanQueryWrapper wrap, byte flag) {
 	this.element = element;
 	this.wrap = wrap;
 	this.flag = flag;
@@ -88,14 +87,6 @@
 	return new SpanWithinQuery(this.element.toQuery(), this.wrap.toQuery(), this.flag);
     };
 
-    public boolean isOptional () {
-	return false;
-    };
-
-    public boolean isNull () {
-	return this.isNull;
-    };
-
     public boolean isNegative () {
 	if (this.element.isNegative())
 	    return true;
diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties
index 48c48d1..2ed007e 100644
--- a/src/main/resources/log4j.properties
+++ b/src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
 ## logger file can be used with
 
-log4j.rootLogger = ERROR, stdout
+# log4j.rootLogger = ERROR, stdout
 
 # Spans:
 #log4j.logger.de.ids_mannheim.korap.query.spans.ElementSpans = TRACE, stdout
@@ -15,8 +15,8 @@
 #log4j.logger.de.ids_mannheim.korap.query.spans.MatchSpans = TRACE, stdout
 
 # Wrapper
-#log4j.logger.de.ids_mannheim.korap.KorapQuery = TRACE, stdout
-#log4j.logger.de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper = TRACE, stdout
+# log4j.logger.de.ids_mannheim.korap.KorapQuery = TRACE, stdout
+# log4j.logger.de.ids_mannheim.korap.query.wrap.SpanSequenceQueryWrapper = TRACE, stdout
 
 # Collections
 #log4j.logger.de.ids_mannheim.korap.KorapFilter = TRACE, stdout
diff --git a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
index a41a983..78e3909 100644
--- a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
+++ b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
@@ -13,7 +13,7 @@
 import org.apache.lucene.store.MMapDirectory;
 import de.ids_mannheim.korap.filter.BooleanFilter;
 import org.apache.lucene.search.spans.SpanQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.util.QueryException;
 
 import static org.junit.Assert.*;
@@ -366,8 +366,8 @@
 	return contentBuilder.toString();
     };
 
-    public static SpanQueryWrapperInterface jsonQuery (String jsonFile) {
-	SpanQueryWrapperInterface sqwi;
+    public static SpanQueryWrapper jsonQuery (String jsonFile) {
+	SpanQueryWrapper sqwi;
 	
 	try {
 	    String json = getString(jsonFile);
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 7263d01..c94a7fc 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -23,7 +23,7 @@
 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.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 import de.ids_mannheim.korap.util.QueryException;
 
 @RunWith(JUnit4.class)
@@ -209,7 +209,7 @@
         }                
         json = sb.toString();
         
-        SpanQueryWrapperInterface sqwi;
+        SpanQueryWrapper sqwi;
         try {    	    
     	    sqwi = new KorapQuery("tokens").fromJSON(json);
     	}
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
index 6ab2f47..0b47add 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -28,7 +28,7 @@
 import de.ids_mannheim.korap.index.FieldDocument;
 import de.ids_mannheim.korap.analysis.MultiTermTokenStream;
 
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import de.ids_mannheim.korap.util.QueryException;
 
@@ -223,7 +223,7 @@
 	};
 	ki.commit();
 
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp18.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp18.jsonld").getFile());
 
 	KorapResult kr = ki.search(sqwi.toQuery(), 0, (short) 5, true, (short) 2, false, (short) 5);
 
@@ -246,8 +246,8 @@
 	return contentBuilder.toString();
     };
 
-    public static SpanQueryWrapperInterface jsonQuery (String jsonFile) {
-	SpanQueryWrapperInterface sqwi;
+    public static SpanQueryWrapper jsonQuery (String jsonFile) {
+	SpanQueryWrapper sqwi;
 	
 	try {
 	    String json = getString(jsonFile);
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index 842cead..486d0c3 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -4,7 +4,7 @@
 import java.io.*;
 
 import org.apache.lucene.search.spans.SpanQuery;
-import de.ids_mannheim.korap.query.wrap.SpanQueryWrapperInterface;
+import de.ids_mannheim.korap.query.wrap.SpanQueryWrapper;
 
 import de.ids_mannheim.korap.KorapQuery;
 import de.ids_mannheim.korap.util.QueryException;
@@ -22,7 +22,7 @@
 
     @Test
     public void queryJSONBsp1 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp1.jsonld").getFile());
 
 	// There is a repetition in here
 	// ([base=foo]|[base=bar])[base=foobar]
@@ -34,7 +34,7 @@
     @Test
     public void queryJSONBsp1b () {
 
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp1b.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp1b.jsonld").getFile());
 
 	// [base=foo]|([base=foo][base=bar]) meta author=Goethe&year=1815
 	assertEquals(sqwi.toQuery().toString(), "spanOr([tokens:"+defaultFoundry+"l:foo, spanNext(tokens:"+defaultFoundry+"l:foo, tokens:"+defaultFoundry+"l:bar)])");
@@ -43,7 +43,7 @@
 
     @Test
     public void queryJSONBsp2 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp2.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp2.jsonld").getFile());
 
 	// ([base=foo]|[base=bar])[base=foobar]
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanOr([tokens:"+defaultFoundry+"l:foo, tokens:"+defaultFoundry+"l:bar]), tokens:"+defaultFoundry+"l:foobar)");
@@ -51,7 +51,7 @@
 
     @Test
     public void queryJSONBsp3 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp3.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp3.jsonld").getFile());
 
 	// shrink({[base=Mann]})
 	assertEquals(sqwi.toQuery().toString(), "shrink(0: {0: tokens:"+defaultFoundry+"l:Mann})");
@@ -59,7 +59,7 @@
 
     @Test
     public void queryJSONBsp4 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp4.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp4.jsonld").getFile());
 
 	// shrink({[base=foo]}[orth=bar])
 	assertEquals(sqwi.toQuery().toString(), "shrink(0: spanNext({0: tokens:"+defaultFoundry+"l:foo}, tokens:s:bar))");
@@ -67,7 +67,7 @@
 
     @Test
     public void queryJSONBsp5 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
 
 	// shrink(1:[base=Der]{1:[base=Mann]}) 
 	assertEquals(sqwi.toQuery().toString(), "shrink(1: spanNext(tokens:"+defaultFoundry+"l:Der, {1: tokens:"+defaultFoundry+"l:Mann}))");
@@ -75,7 +75,7 @@
 
     @Test
     public void queryJSONBsp6 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp6.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp6.jsonld").getFile());
 
 	// [base=katze]
 	assertEquals(sqwi.toQuery().toString(), "tokens:"+defaultFoundry+"l:Katze");
@@ -83,7 +83,7 @@
 
     @Test
     public void queryJSONBsp7 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp7.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp7.jsonld").getFile());
 
 	// [!base=Katze]
 	assertEquals("tokens:mate/l:Katze", sqwi.toQuery().toString());
@@ -92,7 +92,7 @@
 
     @Test
     public void queryJSONBsp9 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp9.jsonld").getFile());
 
 	// [base=Katze&orth=Katzen]
 	assertEquals(sqwi.toQuery().toString(), "spanSegment(tokens:"+defaultFoundry+"l:Katze, tokens:s:Katzen)");
@@ -100,7 +100,7 @@
 
     @Test
     public void queryJSONBsp9b () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp9b.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp9b.jsonld").getFile());
 
 	// [base=Katze&orth=Katzen]
 	assertEquals(sqwi.toQuery().toString(), "spanSegment(tokens:mate/m:number:pl, tokens:tt/p:NN)");
@@ -109,7 +109,7 @@
 
     @Test
     public void queryJSONBsp10 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp10.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp10.jsonld").getFile());
 
 	// [base=Katze][orth=und][orth=Hunde]
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(tokens:"+defaultFoundry+"l:Katze, tokens:s:und), tokens:s:Hunde)");
@@ -117,7 +117,7 @@
 
     @Test
     public void queryJSONBsp11 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp11.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp11.jsonld").getFile());
 
 	// [base!=Katze | orth!=Katzen]
 	/*
@@ -131,7 +131,7 @@
 
     @Test
     public void queryJSONBsp12 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp12.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp12.jsonld").getFile());
 
 	// contains(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "spanContain(<tokens:np />, tokens:"+defaultFoundry+"l:Mann)");
@@ -139,14 +139,14 @@
 
     @Test
     public void queryJSONBsp13 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp13.jsonld").getFile());
 
 	assertEquals(sqwi.toQuery().toString(), "spanStartsWith(<tokens:np />, tokens:mate/p:Det)");
     };
 
     @Test
     public void queryJSONBsp13b () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp13b.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp13b.jsonld").getFile());
 
 	// startswith(<np>,[pos=Det])
 	assertEquals(sqwi.toQuery().toString(), "spanStartsWith(<tokens:np />, tokens:mate/p:Det)");
@@ -154,7 +154,7 @@
 
     @Test
     public void queryJSONBsp14 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp14.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp14.jsonld").getFile());
 
 	// 'vers{2,3}uch'
 	assertEquals(sqwi.toQuery().toString(), "SpanMultiTermQueryWrapper(tokens:/s:vers{2,3}uch/)");
@@ -162,7 +162,7 @@
 
     @Test
     public void queryJSONBsp15 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp15.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp15.jsonld").getFile());
 
 	// [orth='vers.*ch']
 	assertEquals(sqwi.toQuery().toString(), "SpanMultiTermQueryWrapper(tokens:/s:vers.*ch/)");
@@ -170,7 +170,7 @@
 
     @Test
     public void queryJSONBsp16 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp16.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp16.jsonld").getFile());
 
 	// [(base=bar|base=foo)&orth=foobar]
 	assertEquals(sqwi.toQuery().toString(), "spanSegment(spanOr([tokens:"+defaultFoundry+"l:bar, tokens:"+defaultFoundry+"l:foo]), tokens:s:foobar)");
@@ -178,7 +178,7 @@
 
     @Test
     public void queryJSONBsp17 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp17.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp17.jsonld").getFile());
 
 	// within(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "spanContain(<tokens:np />, tokens:"+defaultFoundry+"l:Mann)");
@@ -186,14 +186,14 @@
 
     @Test
     public void queryJSONDemo () throws QueryException {
-	SpanQueryWrapperInterface sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"wrap\" : { \"@type\" : \"korap:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
+	SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"wrap\" : { \"@type\" : \"korap:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
 
 	assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
     };
 
     @Test
     public void queryJSONBspClass () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp-class.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp-class.jsonld").getFile());
 
 	// within(<np>,[base=Mann])
 	assertEquals(sqwi.toQuery().toString(), "{0: spanNext(tokens:tt/p:ADJA, tokens:mate/p:NN)}");
@@ -202,7 +202,7 @@
 
     @Test
     public void queryJSONcosmas3 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas3.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas3.json").getFile());
 
 	// "das /+w1:3 Buch"
 	assertEquals(sqwi.toQuery().toString(), "spanDistance(tokens:s:das, tokens:s:Buch, [(w[1:3], ordered, notExcluded)])");
@@ -210,7 +210,7 @@
 
     @Test
     public void queryJSONcosmas4 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas4.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas4.json").getFile());
 
 	// "das /+w1:3,s1:1 Buch"
 	assertEquals(sqwi.toQuery().toString(), "spanMultipleDistance(tokens:s:das, tokens:s:Buch, [(w[1:3], ordered, notExcluded), (s[1:1], ordered, notExcluded)])");
@@ -218,7 +218,7 @@
 
     @Test
     public void queryJSONcosmas4b () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas4b.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas4b.json").getFile());
 
 	// "das /+w1:3,s1 Buch"
 	assertEquals(sqwi.toQuery().toString(), "spanMultipleDistance(tokens:s:das, tokens:s:Buch, [(w[1:3], ordered, notExcluded), (s[0:1], ordered, notExcluded)])");
@@ -226,7 +226,7 @@
 
     @Test
     public void queryJSONcosmas10 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas10.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas10.json").getFile());
 
 	// "Institut für $deutsche Sprache"
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(spanNext(tokens:s:Institut, tokens:s:für), tokens:i:deutsche), tokens:s:Sprache)");
@@ -234,7 +234,7 @@
 
     @Test
     public void queryJSONcosmas10b () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas10b.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas10b.json").getFile());
 
 	// "Institut $FÜR $deutsche Sprache"
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(spanNext(tokens:s:Institut, tokens:i:für), tokens:i:deutsche), tokens:s:Sprache)");
@@ -242,7 +242,7 @@
 
     @Test
     public void queryJSONcosmas16 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas16.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas16.json").getFile());
 
 	// "$wegen #IN(L) <s>"
 	assertEquals(sqwi.toQuery().toString(), "shrink(1: spanStartsWith(<tokens:s />, {1: tokens:i:wegen}))");
@@ -250,7 +250,7 @@
 
     @Test
     public void queryJSONcosmas17 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas17.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas17.json").getFile());
 
 	// "#BED($wegen , +sa)"
 	assertEquals(sqwi.toQuery().toString(), "spanStartsWith(<tokens:s />, tokens:i:wegen)");
@@ -258,7 +258,7 @@
 
     @Test
     public void queryJSONcosmas20 () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/cosmas20.json").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas20.json").getFile());
 
 	//     "MORPH(V) #IN(R) #ELEM(S)"
 	// TODO: Uses defaultfoundry!
@@ -268,7 +268,7 @@
 
     @Test
     public void queryJSONrepetition () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp-repetition.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp-repetition.jsonld").getFile());
 
 	// der[cnx/p=A]{0,2}[tt/p=NN]
 	assertEquals(sqwi.toQuery().toString(), "spanNext(spanOr([tokens:s:der, spanNext(tokens:s:der, spanRepetition(tokens:cnx/p:A{1,2}))]), tokens:tt/p:NN)");
@@ -277,7 +277,7 @@
 
     @Test
     public void queryJSONboundaryBug () {
-	SpanQueryWrapperInterface sqwi = jsonQuery(getClass().getResource("/queries/bsp-boundary.jsonld").getFile());
+	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp-boundary.jsonld").getFile());
 
 	// Tal []{1,} Wald
 	assertEquals(sqwi.toQuery().toString(), "spanDistance(tokens:s:Tal, tokens:s:Wald, [(w[2:100], ordered, notExcluded)])");
@@ -301,8 +301,8 @@
 	return contentBuilder.toString();
     };
 
-    public static SpanQueryWrapperInterface jsonQuery (String jsonFile) {
-	SpanQueryWrapperInterface sqwi;
+    public static SpanQueryWrapper jsonQuery (String jsonFile) {
+	SpanQueryWrapper sqwi;
 	
 	try {
 	    String json = getString(jsonFile);