autoformat
diff --git a/Changes b/Changes
index 8bd48bd..f1ec155 100644
--- a/Changes
+++ b/Changes
@@ -1,10 +1,13 @@
-0.51 2015-03-03
+0.51 2015-03-04
         - This is a major version (prepared for the GitHub release)
         - [cleanup] Changed groupID to "de.ids_mannheim.korap",
 	  renamed korap-style.xml to Format.xml (diewald)
 	- [bugfix] Updated Format.xml to work with
 	  recent versions of Eclipse (diewald)
         - [documentation] Improved documentation for API classes (diewald)
+	- [bugfix] Updated AttributeSpans (margaretha)
+	- [bugfix] Updated SpanRelationQuery (margaretha)
+	- [cleanup] Autoformat (diewald)
 
 0.50.1 2015-03-02
 	- [feature] Deserialization of arbitrary elements with
diff --git a/src/main/java/de/ids_mannheim/korap/Krill.java b/src/main/java/de/ids_mannheim/korap/Krill.java
index 0fdf5d0..85d64b4 100644
--- a/src/main/java/de/ids_mannheim/korap/Krill.java
+++ b/src/main/java/de/ids_mannheim/korap/Krill.java
@@ -18,35 +18,38 @@
 import org.slf4j.LoggerFactory;
 
 /**
- * <p>Krill is a corpus data retrieval index using Lucene for Look-Ups.</p>
- *
+ * <p>Krill is a corpus data retrieval index using Lucene for
+ * Look-Ups.</p>
+ * 
  * <p>
  * It is the reference implementation for KoralQuery consumption,
  * and this class acts as the central point for consuming and
  * responding to KoralQuery requests.
  * </p>
- *
+ * 
  * <p>
- * The processing of the collection section of the request is delegated
- * to {@link KrillCollection}, the query section to {@link KrillQuery},
+ * The processing of the collection section of the request is
+ * delegated
+ * to {@link KrillCollection}, the query section to {@link KrillQuery}
+ * ,
  * and the meta section to {@link KrillMeta}.
  * </p>
- *
+ * 
  * <blockquote><pre>
- *   // Create or receive a KoralQuery JSON string
- *   String koral = "{\"query\":{...}, \"collection\":{...}, ... }";
- *
- *   // Create a new krill search object by passing the Query
- *   Krill krill = new Krill(koral);
- *
- *   // Apply the query to an index and receive a search result
- *   // This may invoke different actions depending on the request
- *   Result result = krill.setIndex(new KrillIndex()).apply();
+ * // Create or receive a KoralQuery JSON string
+ * String koral = "{\"query\":{...}, \"collection\":{...}, ... }";
+ * 
+ * // Create a new krill search object by passing the Query
+ * Krill krill = new Krill(koral);
+ * 
+ * // Apply the query to an index and receive a search result
+ * // This may invoke different actions depending on the request
+ * Result result = krill.setIndex(new KrillIndex()).apply();
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  * @author margaretha
- *
+ * 
  * @see KrillCollection
  * @see KrillQuery
  * @see KrillMeta
@@ -62,6 +65,7 @@
     // Logger
     private final static Logger log = LoggerFactory.getLogger(Krill.class);
 
+
     /**
      * Construct a new Krill object.
      */
@@ -71,8 +75,9 @@
     /**
      * Construct a new Krill object,
      * consuming a KoralQuery json string.
-     *
-     * @param query The KoralQuery json string.
+     * 
+     * @param query
+     *            The KoralQuery json string.
      */
     public Krill (String query) {
         this.fromJson(query);
@@ -82,8 +87,9 @@
     /**
      * Construct a new Krill object,
      * consuming a KoralQuery {@link JsonNode} object.
-     *
-     * @param query The KoralQuery {@link JsonNode} object.
+     * 
+     * @param query
+     *            The KoralQuery {@link JsonNode} object.
      */
     public Krill (JsonNode query) {
         this.fromJson(query);
@@ -93,8 +99,9 @@
     /**
      * Construct a new Krill object,
      * consuming a {@link SpanQueryWrapper} object.
-     *
-     * @param query The {@link SpanQueryWrapper} object.
+     * 
+     * @param query
+     *            The {@link SpanQueryWrapper} object.
      */
     public Krill (SpanQueryWrapper query) {
         try {
@@ -106,13 +113,14 @@
             this.addError(q.getErrorCode(), q.getMessage());
         };
     };
-    
+
 
     /**
      * Construct a new Krill object,
      * consuming a {@link SpanQuery} object.
-     *
-     * @param query The {@link SpanQuery} object.
+     * 
+     * @param query
+     *            The {@link SpanQuery} object.
      */
     public Krill (SpanQuery query) {
         this.spanQuery = query;
@@ -121,8 +129,9 @@
 
     /**
      * Parse KoralQuery as a json string.
-     *
-     * @param query The KoralQuery json string.
+     * 
+     * @param query
+     *            The KoralQuery json string.
      * @return The {@link Krill} object for chaining.
      * @throws QueryException
      */
@@ -145,8 +154,9 @@
 
     /**
      * Parse KoralQuery as a {@link JsonNode} object.
-     *
-     * @param query The KoralQuery {@link JsonNode} object.
+     * 
+     * @param query
+     *            The KoralQuery {@link JsonNode} object.
      * @return The {@link Krill} object for chaining.
      * @throws QueryException
      */
@@ -185,21 +195,19 @@
             this.addError(700, "No query given");
 
         // <legacycode>
-        if (json.has("warning") &&
-            json.get("warning").asText().length() > 0) {
+        if (json.has("warning") && json.get("warning").asText().length() > 0) {
             this.addWarning(799, json.get("warning").asText());
         };
         // </legacycode>
 
         // Copy notifications from request
         this.copyNotificationsFrom(json);
-	    
+
         // Parse "collection" or "collections" attribute
         try {
             if (json.has("collection")) {
-                this.setCollection(
-                    new KrillCollection().fromJson(json.get("collection"))
-                );
+                this.setCollection(new KrillCollection().fromJson(json
+                        .get("collection")));
             }
 
             // <legacycode>
@@ -208,7 +216,7 @@
                 for (JsonNode collection : json.get("collections")) {
                     kc.fromJsonLegacy(collection);
                 };
-                
+
                 this.setCollection(kc);
             };
             // </legacycode>
@@ -227,7 +235,7 @@
 
     /**
      * Get the associated {@link KrillIndex} object.
-     *
+     * 
      * @return The associated {@link KrillIndex} object.
      */
     public KrillIndex getIndex () {
@@ -237,8 +245,9 @@
 
     /**
      * Set the {@link KrillIndex} object.
-     *
-     * @param index The associated {@link KrillIndex} object.
+     * 
+     * @param index
+     *            The associated {@link KrillIndex} object.
      * @return The {@link Krill} object for chaining.
      */
     public Krill setIndex (KrillIndex index) {
@@ -250,11 +259,12 @@
     /**
      * Apply the KoralQuery to an index.
      * This may invoke different actions depending
-     * on the meta information, like {@link KrillIndex#search}
-     * or {@link KrillIndex#collect}.
-     *
-     * @param index The {@link KrillIndex}
-     *        the search should be applyied to.
+     * on the meta information, like {@link KrillIndex#search} or
+     * {@link KrillIndex#collect}.
+     * 
+     * @param index
+     *            The {@link KrillIndex} the search should be applyied
+     *            to.
      * @return The result as a {@link Result} object.
      */
     public Result apply (KrillIndex index) {
@@ -265,9 +275,9 @@
     /**
      * Apply the KoralQuery to an index.
      * This may invoke different actions depending
-     * on the meta information, like {@link KrillIndex#search}
-     * or {@link KrillIndex#collect}.
-     *
+     * on the meta information, like {@link KrillIndex#search} or
+     * {@link KrillIndex#collect}.
+     * 
      * @return The result as a {@link Result} object.
      */
     public Result apply () {
@@ -302,11 +312,12 @@
 
     /**
      * Get the associated {@link SpanQuery} deserialization
-     * (i.e. the internal correspandence to KoralQuery's query object).
-     *
+     * (i.e. the internal correspandence to KoralQuery's query
+     * object).
+     * 
      * <strong>Warning</strong>: SpanQueries may be lazy deserialized
      * in future versions of Krill, rendering this API obsolete.
-     *
+     * 
      * @return The deserialized {@link SpanQuery} object.
      */
     @Deprecated
@@ -317,13 +328,15 @@
 
     /**
      * Set the SpanQuery by means of a {@link SpanQueryWrapper} object
-     * (i.e. the internal correspandence to KoralQuery's query object).
-     *
+     * (i.e. the internal correspandence to KoralQuery's query
+     * object).
+     * 
      * <strong>Warning</strong>: SpanQueries may be lazy deserialized
      * in future versions of Krill, rendering this API obsolete.
-     *
-     * @param query The {@link SpanQueryWrapper} to unwrap
-     *        the {@link SpanQuery} object.
+     * 
+     * @param query
+     *            The {@link SpanQueryWrapper} to unwrap
+     *            the {@link SpanQuery} object.
      * @return The {@link Krill} object for chaining.
      */
     @Deprecated
@@ -340,14 +353,16 @@
 
     /**
      * Set the {@link SpanQuery} object
-     * (i.e. the internal correspandence to KoralQuery's query object).
-     *
+     * (i.e. the internal correspandence to KoralQuery's query
+     * object).
+     * 
      * <strong>Warning</strong>: SpanQueries may be lazy deserialized
      * in future versions of Krill, rendering this API obsolete.
-     *
-     * @param query The {@link SpanQuery} object.
+     * 
+     * @param query
+     *            The {@link SpanQuery} object.
      * @return The {@link Krill} object for chaining.
-     */    
+     */
     @Deprecated
     public Krill setSpanQuery (SpanQuery sq) {
         this.spanQuery = sq;
diff --git a/src/main/java/de/ids_mannheim/korap/KrillCollection.java b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
index 2b7e771..e593eff 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
@@ -30,17 +30,18 @@
 /**
  * Create a Virtual Collection of documents by means of a KoralQuery
  * collection object.
- * Alternatively by applying manual filters and extensions on Lucene fields.
- *
+ * Alternatively by applying manual filters and extensions on Lucene
+ * fields.
+ * 
  * <blockquote><pre>
- *   KrillCollection kc = new KrillCollection(json);
- *   kc.filterUIDS("a1", "a2", "a3");
+ * KrillCollection kc = new KrillCollection(json);
+ * kc.filterUIDS("a1", "a2", "a3");
  * </pre></blockquote>
- *
+ * 
  * <strong>Warning</strong>: This API is deprecated and will
  * be replaced in future versions. It supports legacy versions of
  * KoralQuery that will be disabled.
- *
+ * 
  * @author diewald
  */
 /*
@@ -58,9 +59,10 @@
     private String id;
     private ArrayList<FilterOperation> filter;
     private int filterCount = 0;
-    
+
     // Logger
-    private final static Logger log = LoggerFactory.getLogger(KrillCollection.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(KrillCollection.class);
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
@@ -68,8 +70,9 @@
 
     /**
      * Construct a new KrillCollection by passing a KrillIndex.
-     *
-     * @param index The {@link KrillIndex} object.
+     * 
+     * @param index
+     *            The {@link KrillIndex} object.
      */
     public KrillCollection (KrillIndex index) {
         this.index = index;
@@ -81,8 +84,9 @@
      * Construct a new KrillCollection by passing a KoralQuery.
      * This supports collections with the key "collection" and
      * legacy collections with the key "collections".
-     *
-     * @param jsonString The virtual collection as a KoralQuery.
+     * 
+     * @param jsonString
+     *            The virtual collection as a KoralQuery.
      */
     public KrillCollection (String jsonString) {
         ObjectMapper mapper = new ObjectMapper();
@@ -90,19 +94,17 @@
 
         try {
             JsonNode json = mapper.readTree(jsonString);
-            
+
             // Deserialize from recent collections
             if (json.has("collection")) {
                 this.fromJson(json.get("collection"));
             }
-	    
+
             // Legacy collection serialization
             // This will be removed!
             else if (json.has("collections")) {
-                this.addMessage(
-                    850,
-                    "Collections are deprecated in favour of a single collection"
-                );
+                this.addMessage(850,
+                        "Collections are deprecated in favour of a single collection");
                 for (JsonNode collection : json.get("collections")) {
                     this.fromJsonLegacy(collection);
                 };
@@ -113,12 +115,8 @@
             this.addError(qe.getErrorCode(), qe.getMessage());
         }
         catch (IOException e) {
-            this.addError(
-                621,
-                "Unable to parse JSON",
-                "KrillCollection",
-                e.getLocalizedMessage()
-            );
+            this.addError(621, "Unable to parse JSON", "KrillCollection",
+                    e.getLocalizedMessage());
         };
     };
 
@@ -133,8 +131,9 @@
 
     /**
      * Import the "collection" part of a KoralQuery.
-     *
-     * @param jsonString The "collection" part of a KoralQuery.
+     * 
+     * @param jsonString
+     *            The "collection" part of a KoralQuery.
      * @throws QueryException
      */
     public KrillCollection fromJson (String jsonString) throws QueryException {
@@ -152,9 +151,10 @@
 
     /**
      * Import the "collection" part of a KoralQuery.
-     *
-     * @param json The "collection" part of a KoralQuery
-     *        as a {@link JsonNode} object.
+     * 
+     * @param json
+     *            The "collection" part of a KoralQuery
+     *            as a {@link JsonNode} object.
      * @throws QueryException
      */
     public KrillCollection fromJson (JsonNode json) throws QueryException {
@@ -170,25 +170,27 @@
 
 
     // Create a booleanfilter from JSON
-    private BooleanFilter _fromJson (JsonNode json, String field) throws QueryException {
+    private BooleanFilter _fromJson (JsonNode json, String field)
+            throws QueryException {
         BooleanFilter bfilter = new BooleanFilter();
 
         // TODO: THIS UNFORTUNATELY BREAKS TESTS
         if (!json.has("@type"))
-            throw new QueryException(701, "JSON-LD group has no @type attribute");
+            throw new QueryException(701,
+                    "JSON-LD group has no @type attribute");
 
         String type = json.get("@type").asText();
-        
+
         // Single filter
         if (type.equals("koral:doc")) {
 
-            String key     = "tokens";
+            String key = "tokens";
             String valtype = "type:string";
-            String match   = "match:eq";
+            String match = "match:eq";
 
             if (json.has("key"))
                 key = json.get("key").asText();
-            
+
             if (json.has("type"))
                 valtype = json.get("type").asText();
 
@@ -204,15 +206,15 @@
 
                 // TODO: This isn't stable yet
                 switch (match) {
-                case "match:eq":
-                    bfilter.date(dateStr);
-                    break;
-                case "match:geq":
-                    bfilter.since(dateStr);
-                    break;
-                case "match:leq":
-                    bfilter.till(dateStr);
-                    break;
+                    case "match:eq":
+                        bfilter.date(dateStr);
+                        break;
+                    case "match:geq":
+                        bfilter.since(dateStr);
+                        break;
+                    case "match:leq":
+                        bfilter.till(dateStr);
+                        break;
                 };
                 // No good reason for gt or lt
                 return bfilter;
@@ -248,15 +250,18 @@
                     group.or(this._fromJson(operand, field));
 
                 else
-                    throw new QueryException(613, "Unknown document group operation");
+                    throw new QueryException(613,
+                            "Unknown document group operation");
             };
             bfilter.and(group);
             return bfilter;
         }
 
         // Unknown type
-        else throw new QueryException(613, "Collection query type has to be doc or docGroup");
-        
+        else
+            throw new QueryException(613,
+                    "Collection query type has to be doc or docGroup");
+
         return new BooleanFilter();
     };
 
@@ -264,15 +269,18 @@
     /**
      * Import the "collections" part of a KoralQuery.
      * This method is deprecated and will vanish in future versions.
-     *
-     * @param jsonString The "collections" part of a KoralQuery.
+     * 
+     * @param jsonString
+     *            The "collections" part of a KoralQuery.
      * @throws QueryException
      */
     @Deprecated
-    public KrillCollection fromJsonLegacy (String jsonString) throws QueryException {
+    public KrillCollection fromJsonLegacy (String jsonString)
+            throws QueryException {
         ObjectMapper mapper = new ObjectMapper();
         try {
-            this.fromJsonLegacy((JsonNode) mapper.readValue(jsonString, JsonNode.class));
+            this.fromJsonLegacy((JsonNode) mapper.readValue(jsonString,
+                    JsonNode.class));
         }
         catch (Exception e) {
             this.addError(621, "Unable to parse JSON", "KrillCollection");
@@ -284,15 +292,17 @@
     /**
      * Import the "collections" part of a KoralQuery.
      * This method is deprecated and will vanish in future versions.
-     *
-     * @param json The "collections" part of a KoralQuery
-     *        as a {@link JsonNode} object.
+     * 
+     * @param json
+     *            The "collections" part of a KoralQuery
+     *            as a {@link JsonNode} object.
      * @throws QueryException
      */
     @Deprecated
     public KrillCollection fromJsonLegacy (JsonNode json) throws QueryException {
         if (!json.has("@type"))
-            throw new QueryException(701, "JSON-LD group has no @type attribute");
+            throw new QueryException(701,
+                    "JSON-LD group has no @type attribute");
 
         if (!json.has("@value"))
             throw new QueryException(851, "Legacy filter need @value fields");
@@ -306,7 +316,7 @@
                 log.trace("Add Filter LEGACY");
             this.filter(bf);
         }
-        
+
         // Extend the collection
         else if (type.equals("koral:meta-extend")) {
             if (DEBUG)
@@ -321,15 +331,17 @@
     // Create a boolean filter from a Json string
     @Deprecated
     private BooleanFilter _fromJsonLegacy (JsonNode json, String field)
-        throws QueryException {
+            throws QueryException {
         BooleanFilter bfilter = new BooleanFilter();
 
         if (!json.has("@type"))
-            throw new QueryException(612, "JSON-LD group has no @type attribute");
-	
+            throw new QueryException(612,
+                    "JSON-LD group has no @type attribute");
+
         String type = json.get("@type").asText();
-        
-        if (DEBUG) log.trace("@type: " + type);
+
+        if (DEBUG)
+            log.trace("@type: " + type);
 
         if (json.has("@field"))
             field = _getFieldLegacy(json);
@@ -353,62 +365,67 @@
                 throw new QueryException(612, "Group needs operand list");
 
             if (DEBUG)
-                log.trace("relation found {}",  json.get("relation").asText());
+                log.trace("relation found {}", json.get("relation").asText());
 
             BooleanFilter group = new BooleanFilter();
-	    
-            switch (json.get("relation").asText())  {
-            case "between":
-                dateStr = _getDateLegacy(json, 0);
-                till = _getDateLegacy(json, 1);
-                if (dateStr != null && till != null)
-                    bfilter.between(dateStr, till);
-                break;
 
-            case "until":
-                dateStr = _getDateLegacy(json, 0);
-                if (dateStr != null)
-                    bfilter.till(dateStr);
-                break;
+            switch (json.get("relation").asText()) {
+                case "between":
+                    dateStr = _getDateLegacy(json, 0);
+                    till = _getDateLegacy(json, 1);
+                    if (dateStr != null && till != null)
+                        bfilter.between(dateStr, till);
+                    break;
 
-            case "since":
-                dateStr = _getDateLegacy(json, 0);
-                if (dateStr != null)
-                    bfilter.since(dateStr);
-                break;
+                case "until":
+                    dateStr = _getDateLegacy(json, 0);
+                    if (dateStr != null)
+                        bfilter.till(dateStr);
+                    break;
 
-            case "equals":
-                dateStr = _getDateLegacy(json, 0);
-                if (dateStr != null)
-                    bfilter.date(dateStr);
-                break;
+                case "since":
+                    dateStr = _getDateLegacy(json, 0);
+                    if (dateStr != null)
+                        bfilter.since(dateStr);
+                    break;
 
-            case "and":
-                if (operands.size() < 1)
-                    throw new QueryException(612, "Operation needs at least two operands");
+                case "equals":
+                    dateStr = _getDateLegacy(json, 0);
+                    if (dateStr != null)
+                        bfilter.date(dateStr);
+                    break;
 
-                for (JsonNode operand : operands) {
-                    group.and(this._fromJsonLegacy(operand, field));
-                };
-                bfilter.and(group);
-                break;
+                case "and":
+                    if (operands.size() < 1)
+                        throw new QueryException(612,
+                                "Operation needs at least two operands");
 
-            case "or":
-                if (operands.size() < 1)
-                    throw new QueryException(612, "Operation needs at least two operands");
+                    for (JsonNode operand : operands) {
+                        group.and(this._fromJsonLegacy(operand, field));
+                    }
+                    ;
+                    bfilter.and(group);
+                    break;
 
-                for (JsonNode operand : operands) {
-                    group.or(this._fromJsonLegacy(operand, field));
-                };
-                bfilter.and(group);
-                break;
+                case "or":
+                    if (operands.size() < 1)
+                        throw new QueryException(612,
+                                "Operation needs at least two operands");
 
-            default:
-                throw new QueryException(613, "Relation is not supported");
+                    for (JsonNode operand : operands) {
+                        group.or(this._fromJsonLegacy(operand, field));
+                    }
+                    ;
+                    bfilter.and(group);
+                    break;
+
+                default:
+                    throw new QueryException(613, "Relation is not supported");
             };
         }
         else {
-            throw new QueryException(613, "Filter type is not a supported group");
+            throw new QueryException(613,
+                    "Filter type is not a supported group");
         };
         return bfilter;
     };
@@ -416,8 +433,10 @@
 
     /**
      * Set the {@link KrillIndex} the virtual collection refers to.
-     *
-     * @param index The {@link KrillIndex} the virtual collection refers to.
+     * 
+     * @param index
+     *            The {@link KrillIndex} the virtual collection refers
+     *            to.
      */
     public void setIndex (KrillIndex index) {
         this.index = index;
@@ -426,18 +445,19 @@
 
     /**
      * Add a filter by means of a {@link BooleanFilter}.
-     *
+     * 
      * <strong>Warning</strong>: Filters are part of the collections
      * legacy API and may vanish without warning.
-     *
-     * @param filter The filter to add to the collection.
+     * 
+     * @param filter
+     *            The filter to add to the collection.
      * @return The {@link KrillCollection} object for chaining.
      */
     // TODO: The checks may not be necessary
     public KrillCollection filter (BooleanFilter filter) {
         if (DEBUG)
             log.trace("Added filter: {}", filter.toString());
-        
+
         if (filter == null) {
             this.addWarning(830, "Filter was empty");
             return this;
@@ -461,11 +481,12 @@
 
     /**
      * Add a filter by means of a {@link CollectionBuilder} object.
-     *
+     * 
      * <strong>Warning</strong>: Filters are part of the collections
      * legacy API and may vanish without warning.
-     *
-     * @param filter The filter to add to the collection.
+     * 
+     * @param filter
+     *            The filter to add to the collection.
      * @return The {@link KrillCollection} object for chaining.
      */
     public KrillCollection filter (CollectionBuilder filter) {
@@ -475,35 +496,36 @@
 
     /**
      * Add an extension by means of a {@link BooleanFilter}.
-     *
-     * <strong>Warning</strong>: Extensions are part of the collections
+     * 
+     * <strong>Warning</strong>: Extensions are part of the
+     * collections
      * legacy API and may vanish without warning.
-     *
-     * @param extension The extension to add to the collection.
+     * 
+     * @param extension
+     *            The extension to add to the collection.
      * @return The {@link KrillCollection} object for chaining.
      */
     public KrillCollection extend (BooleanFilter extension) {
         if (DEBUG)
             log.trace("Added extension: {}", extension.toString());
 
-        this.filter.add(
-            new FilterOperation(
-                (Filter) new QueryWrapperFilter(extension.toQuery()),
-                true
-            )
-        );
+        this.filter.add(new FilterOperation((Filter) new QueryWrapperFilter(
+                extension.toQuery()), true));
         this.filterCount++;
         return this;
     };
 
 
     /**
-     * Add an extension by means of a {@link CollectionBuilder} object.
-     *
-     * <strong>Warning</strong>: Extensions are part of the collections
+     * Add an extension by means of a {@link CollectionBuilder}
+     * object.
+     * 
+     * <strong>Warning</strong>: Extensions are part of the
+     * collections
      * legacy API and may vanish without warning.
-     *
-     * @param extension The extension to add to the collection.
+     * 
+     * @param extension
+     *            The extension to add to the collection.
      * @return The {@link KrillCollection} object for chaining.
      */
     public KrillCollection extend (CollectionBuilder extension) {
@@ -514,10 +536,11 @@
     /**
      * Add a filter based on a list of unique document identifiers.
      * UIDs may be indexed in the field "UID".
-     *
+     * 
      * This filter is not part of the legacy API!
-     *
-     * @param uids The list of unique document identifier.
+     * 
+     * @param uids
+     *            The list of unique document identifier.
      * @return The {@link KrillCollection} object for chaining.
      */
     public KrillCollection filterUIDs (String ... uids) {
@@ -531,10 +554,10 @@
 
     /**
      * Get the list of filters constructing the collection.
-     *
+     * 
      * <strong>Warning</strong>: This is part of the collections
      * legacy API and may vanish without warning.
-     *
+     * 
      * @return The list of filters.
      */
     public List<FilterOperation> getFilters () {
@@ -545,12 +568,15 @@
     /**
      * Get a certain {@link FilterOperation} from the list of filters
      * constructing the collection by its numerical index.
-     *
+     * 
      * <strong>Warning</strong>: This is part of the collections
      * legacy API and may vanish without warning.
-     *
-     * @param index The index position of the requested {@link FilterOperation}.
-     * @return The {@link FilterOperation} at the certain list position.
+     * 
+     * @param index
+     *            The index position of the requested
+     *            {@link FilterOperation}.
+     * @return The {@link FilterOperation} at the certain list
+     *         position.
      */
     public FilterOperation getFilter (int index) {
         return this.filter.get(index);
@@ -558,24 +584,27 @@
 
 
     /**
-     * Get the number of filter operations constructing this collection.
-     *
+     * Get the number of filter operations constructing this
+     * collection.
+     * 
      * <strong>Warning</strong>: This is part of the collections
      * legacy API and may vanish without warning.
-     *
-     * @return The number of filter operations constructing this collection.
+     * 
+     * @return The number of filter operations constructing this
+     *         collection.
      */
-    public int getCount() {
+    public int getCount () {
         return this.filterCount;
     };
 
 
     /**
      * Generate a string representatio of the virtual collection.
-     *
-     * <strong>Warning</strong>: This currently does not generate a valid
+     * 
+     * <strong>Warning</strong>: This currently does not generate a
+     * valid
      * KoralQuery string, so this may change in a future version.
-     *
+     * 
      * @return A string representation of the virtual collection.
      */
     public String toString () {
@@ -592,69 +621,68 @@
      * This is mostly used for testing purposes
      * and <strong>is not recommended</strong>
      * as a common search API.
-     *
+     * 
      * Please use {@link KrillQuery#run} instead.
-     *
-     * @param query a {@link SpanQuery} to apply on the
-     *        virtual collection.
+     * 
+     * @param query
+     *            a {@link SpanQuery} to apply on the
+     *            virtual collection.
      * @return A {@link Result} object representing the search's
      *         result.
      */
     public Result search (SpanQuery query) {
-        return this.index.search(
-            this,
-            query,
-            0,
-            (short) 20,
-            true, (short) 5,
-            true, (short) 5
-        );
+        return this.index.search(this, query, 0, (short) 20, true, (short) 5,
+                true, (short) 5);
     };
 
 
     /**
      * Create a bit vector representing the live documents of the
      * virtual collection to be used in searches.
-     *
-     * @param The {@link AtomicReaderContext} to search in.
+     * 
+     * @param The
+     *            {@link AtomicReaderContext} to search in.
      * @return A bit vector representing the live documents of the
      *         virtual collection.
      * @throws IOException
      */
-    public FixedBitSet bits (AtomicReaderContext atomic) throws IOException  {
+    public FixedBitSet bits (AtomicReaderContext atomic) throws IOException {
         // TODO: Probably use Bits.MatchAllBits(int len)
         boolean noDoc = true;
         FixedBitSet bitset;
-        
+
         // There are filters set
         if (this.filterCount > 0) {
             bitset = new FixedBitSet(atomic.reader().maxDoc());
 
-            ArrayList<FilterOperation> filters =
-                (ArrayList<FilterOperation>) this.filter.clone();
+            ArrayList<FilterOperation> filters = (ArrayList<FilterOperation>) this.filter
+                    .clone();
 
             FilterOperation kcInit = filters.remove(0);
             if (DEBUG)
                 log.trace("FILTER: {}", kcInit);
-            
+
             // Init vector
             DocIdSet docids = kcInit.filter.getDocIdSet(atomic, null);
 
             DocIdSetIterator filterIter = docids.iterator();
-            
+
             // The filter has an effect
             if (filterIter != null) {
-                if (DEBUG) log.trace("InitFilter has effect");
+                if (DEBUG)
+                    log.trace("InitFilter has effect");
                 bitset.or(filterIter);
                 noDoc = false;
             };
-            
+
             // Apply all filters sequentially
             for (FilterOperation kc : filters) {
-                if (DEBUG) log.trace("FILTER: {}", kc);
+                if (DEBUG)
+                    log.trace("FILTER: {}", kc);
 
                 // TODO: BUG???
-                docids = kc.filter.getDocIdSet(atomic, kc.isExtension() ? null : bitset);
+                docids = kc.filter.getDocIdSet(atomic, kc.isExtension() ? null
+                        : bitset);
                 filterIter = docids.iterator();
 
                 if (filterIter == null) {
@@ -674,7 +702,8 @@
             };
 
             if (!noDoc) {
-                FixedBitSet livedocs = (FixedBitSet) atomic.reader().getLiveDocs();
+                FixedBitSet livedocs = (FixedBitSet) atomic.reader()
+                        .getLiveDocs();
                 if (livedocs != null)
                     bitset.and(livedocs);
             };
@@ -691,11 +720,14 @@
      * Search for the number of occurrences of different types,
      * e.g. <i>documents</i>, <i>sentences</i> etc. in the virtual
      * collection.
-     *
-     * @param field The field containing the textual data and the
-     *        annotations as a string.
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param field
+     *            The field containing the textual data and the
+     *            annotations as a string.
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @throws IOException
      * @see KrillIndex#numberOf
@@ -712,9 +744,11 @@
      * Search for the number of occurrences of different types,
      * e.g. <i>documents</i>, <i>sentences</i> etc. in the virtual
      * collection, in the <i>base</i> foundry.
-     *
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @throws IOException
      * @see KrillIndex#numberOf
@@ -731,7 +765,7 @@
     @Deprecated
     public HashMap getTermRelation (String field) throws Exception {
         if (this.index == null) {
-            HashMap<String,Long> map = new HashMap<>(1);
+            HashMap<String, Long> map = new HashMap<>(1);
             map.put("-docs", (long) 0);
             return map;
         };
@@ -746,26 +780,26 @@
         ObjectMapper mapper = new ObjectMapper();
         StringWriter sw = new StringWriter();
         sw.append("{\"field\":");
-        mapper.writeValue(sw,field);
+        mapper.writeValue(sw, field);
         sw.append(",");
 
         try {
             HashMap<String, Long> map = this.getTermRelation(field);
 
             sw.append("\"documents\":");
-            mapper.writeValue(sw,map.remove("-docs"));
+            mapper.writeValue(sw, map.remove("-docs"));
             sw.append(",");
 
             String[] keys = map.keySet().toArray(new String[map.size()]);
 
-            HashMap<String,Integer> setHash = new HashMap<>(20);
-            ArrayList<HashMap<String,Long>> set = new ArrayList<>(20);
+            HashMap<String, Integer> setHash = new HashMap<>(20);
+            ArrayList<HashMap<String, Long>> set = new ArrayList<>(20);
             ArrayList<Long[]> overlap = new ArrayList<>(100);
-	    
+
             int count = 0;
             for (String key : keys) {
                 if (!key.startsWith("#__")) {
-                    HashMap<String,Long> simpleMap = new HashMap<>();
+                    HashMap<String, Long> simpleMap = new HashMap<>();
                     simpleMap.put(key, map.remove(key));
                     set.add(simpleMap);
                     setHash.put(key, count++);
@@ -790,7 +824,7 @@
         }
         catch (Exception e) {
             sw.append("\"error\":");
-            mapper.writeValue(sw,e.getMessage());
+            mapper.writeValue(sw, e.getMessage());
         };
 
         sw.append("}");
@@ -800,7 +834,7 @@
 
     // Get legacy field
     @Deprecated
-    private static String  _getFieldLegacy (JsonNode json)  {
+    private static String _getFieldLegacy (JsonNode json) {
         if (!json.has("@field"))
             return (String) null;
 
@@ -825,7 +859,7 @@
 
         if (!date.get("@type").asText().equals("koral:date"))
             return (String) null;
-        
+
         if (!date.has("@value"))
             return (String) null;
 
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index d77b481..a425f36 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -38,29 +38,32 @@
 import java.nio.ByteBuffer;
 
 /**
- * <p>KrillIndex implements a simple API for searching in and writing to a
- * Lucene index and requesting several information about the index' nature.
- * Please consult {@link Krill} for the preferred use of this class.</p>
- *
+ * <p>KrillIndex implements a simple API for searching in and writing
+ * to a
+ * Lucene index and requesting several information about the index'
+ * nature.
+ * Please consult {@link Krill} for the preferred use of this
+ * class.</p>
+ * 
  * <blockquote><pre>
- *   // Create new file backed index
- *   KrillIndex ki = new KrillIndex(
- *       new MMapDirectory(new File("/myindex"))
- *   );
- *
- *   // Add documents to the index
- *   ki.addDoc(1, "{\"ID\":\"WPD-001\", ... }");
- *   ki.addDoc(2, "{\"ID\":\"WPD-002\", ... }");
- *
- *   // Apply Krill searches on the index
- *   String koral = "{\"@type\":"koral:group", ... }";
- *   Result result = new Krill(koral).apply(ki);
+ * // Create new file backed index
+ * KrillIndex ki = new KrillIndex(
+ * new MMapDirectory(new File("/myindex"))
+ * );
+ * 
+ * // Add documents to the index
+ * ki.addDoc(1, "{\"ID\":\"WPD-001\", ... }");
+ * ki.addDoc(2, "{\"ID\":\"WPD-002\", ... }");
+ * 
+ * // Apply Krill searches on the index
+ * String koral = "{\"@type\":"koral:group", ... }";
+ * Result result = new Krill(koral).apply(ki);
  * </pre></blockquote>
- *
+ * 
  * <p>Properties can be stored in a properies file called
  * <tt>krill.properties</tt>. Relevant properties are
  * <tt>krill.version</tt> and <tt>krill.name</tt>.</p>
- *
+ * 
  * @author diewald
  */
 /*
@@ -133,10 +136,9 @@
     private ObjectMapper mapper = new ObjectMapper();
 
     private byte[] pl = new byte[4];
-    private static ByteBuffer
-        bb       = ByteBuffer.allocate(4),
-        bbOffset = ByteBuffer.allocate(8),
-        bbTerm   = ByteBuffer.allocate(16);
+    private static ByteBuffer bb = ByteBuffer.allocate(4),
+            bbOffset = ByteBuffer.allocate(8),
+            bbTerm = ByteBuffer.allocate(16);
 
     // Some initializations ...
     // TODO: This should probably happen at a more central point
@@ -151,8 +153,8 @@
             try {
                 InputStream fr = new FileInputStream(f);
                 prop.load(fr);
-                this.version    = prop.getProperty("krill.version");
-                this.name       = prop.getProperty("krill.name");
+                this.version = prop.getProperty("krill.version");
+                this.name = prop.getProperty("krill.name");
 
                 // Check for auto commit value
                 String stringProp = prop.getProperty("krill.index.commit.auto");
@@ -188,7 +190,7 @@
     /**
      * Constructs a new KrillIndex.
      * This will be in-memory.
-     *
+     * 
      * @throws IOException
      */
     public KrillIndex () throws IOException {
@@ -198,8 +200,9 @@
 
     /**
      * Constructs a new KrillIndex bound to a persistant index.
-     *
-     * @param directory A {@link Directory} pointing to an index
+     * 
+     * @param directory
+     *            A {@link Directory} pointing to an index
      * @throws IOException
      */
     public KrillIndex (Directory directory) throws IOException {
@@ -207,13 +210,13 @@
 
         // Add analyzers
         // TODO: Should probably not be here
-        Map<String,Analyzer> analyzerPerField = new HashMap<String,Analyzer>();
-        analyzerPerField.put("textClass", new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
-        analyzerPerField.put("foundries", new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
+        Map<String, Analyzer> analyzerPerField = new HashMap<String, Analyzer>();
+        analyzerPerField.put("textClass", new WhitespaceAnalyzer(
+                Version.LUCENE_CURRENT));
+        analyzerPerField.put("foundries", new WhitespaceAnalyzer(
+                Version.LUCENE_CURRENT));
         PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(
-            new StandardAnalyzer(Version.LUCENE_CURRENT),
-            analyzerPerField
-        );
+                new StandardAnalyzer(Version.LUCENE_CURRENT), analyzerPerField);
 
         // Create configuration with base analyzer
         this.config = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
@@ -222,9 +225,9 @@
 
     /**
      * Get the version number of the index.
-     *
+     * 
      * @return A string containing the version number.
-     */    
+     */
     public String getVersion () {
         return this.version;
     };
@@ -232,9 +235,9 @@
 
     /**
      * Get the name of the index.
-     *
+     * 
      * @return A string containing the name of the index.
-     */ 
+     */
     public String getName () {
         return this.name;
     };
@@ -242,24 +245,24 @@
 
     /**
      * The Lucene {@link IndexReader} object.
-     *
+     * 
      * Will be opened, in case it's closed.
-     *
+     * 
      * @return The {@link IndexReader} object.
      */
     public IndexReader reader () {
         // Todo: Maybe use DirectoryReader.openIfChanged(DirectoryReader)
         if (!readerOpen)
-            this.openReader();        
+            this.openReader();
         return this.reader;
     };
 
 
     /**
      * The Lucene {@link IndexWriter} object.
-     *
+     * 
      * Will be created, in case it doesn't exist yet.
-     *
+     * 
      * @return The {@link IndexWriter} object.
      * @throws IOException
      */
@@ -273,9 +276,9 @@
 
     /**
      * The Lucene {@link IndexSearcher} object.
-     *
+     * 
      * Will be created, in case it doesn't exist yet.
-     *
+     * 
      * @return The {@link IndexSearcher} object.
      */
     public IndexSearcher searcher () {
@@ -298,7 +301,7 @@
         // Failed to open reader
         catch (IOException e) {
             // e.printStackTrace();
-            log.warn( e.getLocalizedMessage() );
+            log.warn(e.getLocalizedMessage());
         };
     };
 
@@ -320,12 +323,12 @@
 
 
     /**
-     * Close the associated {@link IndexReader}
-     * and the associated {@link IndexWriter},
+     * Close the associated {@link IndexReader} and the associated
+     * {@link IndexWriter},
      * in case they are opened.
-     *
+     * 
      * @throws IOException
-     */ 
+     */
     public void close () throws IOException {
         this.closeReader();
         this.closeWriter();
@@ -335,9 +338,10 @@
     /**
      * Commit staged data to the index,
      * if the commit counter indicates there is staged data.
-     *
-     * @param force Force the commit,
-     *        even if there is no staged data.
+     * 
+     * @param force
+     *            Force the commit,
+     *            even if there is no staged data.
      * @throws IOException
      */
     public void commit (boolean force) throws IOException {
@@ -349,7 +353,7 @@
 
     /**
      * Commit staged data to the index.
-     *
+     * 
      * @throws IOException
      */
     public void commit () throws IOException {
@@ -361,7 +365,7 @@
 
     /**
      * Get autocommit value.
-     *
+     * 
      * @return The autocommit value.
      */
     public int getAutoCommit () {
@@ -371,8 +375,9 @@
 
     /**
      * Set the autocommit value.
-     *
-     * @param value The autocommit value.
+     * 
+     * @param value
+     *            The autocommit value.
      */
     public void setAutoCommit (int value) {
         this.autoCommit = value;
@@ -381,8 +386,9 @@
 
     /**
      * Add a document to the index as a {@link FieldDocument}.
-     *
-     * @param doc The {@link FieldDocument} to add to the index.
+     * 
+     * @param doc
+     *            The {@link FieldDocument} to add to the index.
      * @return The {@link FieldDocument}, which means, the same
      *         object, that was passed to the method.
      */
@@ -393,7 +399,7 @@
         try {
 
             // Add document to writer
-            this.writer().addDocument( doc.doc );
+            this.writer().addDocument(doc.doc);
             if (++commitCounter > autoCommit) {
                 this.commit();
                 commitCounter = 0;
@@ -411,8 +417,9 @@
 
     /**
      * Add a document to the index as a JSON string.
-     *
-     * @param json The document to add to the index as a string.
+     * 
+     * @param json
+     *            The document to add to the index as a string.
      * @return The created {@link FieldDocument}.
      * @throws IOException
      */
@@ -425,9 +432,11 @@
      * Add a document to the index as a JSON string
      * with a unique integer ID (unique throughout the index
      * or even throughout the cluster of indices).
-     *
-     * @param uid The unique document identifier.
-     * @param json The document to add to the index as a string.
+     * 
+     * @param uid
+     *            The unique document identifier.
+     * @param json
+     *            The document to add to the index as a string.
      * @return The created {@link FieldDocument}.
      * @throws IOException
      */
@@ -443,9 +452,10 @@
 
     /**
      * Add a document to the index as a JSON string.
-     *
-     * @param json The document to add to the index as
-     *        an {@link InputStream}.
+     * 
+     * @param json
+     *            The document to add to the index as
+     *            an {@link InputStream}.
      * @return The created {@link FieldDocument}.
      * @throws IOException
      */
@@ -456,10 +466,12 @@
 
     /**
      * Add a document to the index as a JSON string.
-     *
-     * @param json The document to add to the index as
-     *        an {@link InputStream}.
-     * @param gzip Boolean value indicating if the file is gzipped.
+     * 
+     * @param json
+     *            The document to add to the index as
+     *            an {@link InputStream}.
+     * @param gzip
+     *            Boolean value indicating if the file is gzipped.
      * @return The created {@link FieldDocument}.
      * @throws IOException
      */
@@ -472,11 +484,14 @@
      * Add a document to the index as a JSON string
      * with a unique integer ID (unique throughout the index
      * or even throughout the cluster of indices).
-     *
-     * @param uid The unique document identifier.
-     * @param json The document to add to the index as
-     *        an {@link InputStream}.
-     * @param gzip Boolean value indicating if the file is gzipped.
+     * 
+     * @param uid
+     *            The unique document identifier.
+     * @param json
+     *            The document to add to the index as
+     *            an {@link InputStream}.
+     * @param gzip
+     *            Boolean value indicating if the file is gzipped.
      * @return The created {@link FieldDocument}.
      * @throws IOException
      */
@@ -509,10 +524,8 @@
             if (gzip) {
 
                 // Create json field document
-                FieldDocument fd = this.mapper.readValue(
-                    new GZIPInputStream(json),
-                    FieldDocument.class
-                );
+                FieldDocument fd = this.mapper.readValue(new GZIPInputStream(
+                        json), FieldDocument.class);
                 return fd;
             };
             return this.mapper.readValue(json, FieldDocument.class);
@@ -529,19 +542,21 @@
     /**
      * Search for the number of occurrences of different types,
      * e.g. <i>documents</i>, <i>sentences</i> etc.
-     *
-     * @param collection The scope of the numbering by means of a
-     *        {@link KrillCollection}
-     * @param field The field containing the textual data and the
-     *        annotations as a string.
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param collection
+     *            The scope of the numbering by means of a
+     *            {@link KrillCollection}
+     * @param field
+     *            The field containing the textual data and the
+     *            annotations as a string.
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @see KrillCollection#numberOf
      */
-    public long numberOf (KrillCollection collection,
-                          String field,
-                          String type) {
+    public long numberOf (KrillCollection collection, String field, String type) {
         // Short cut for documents
         // This will be only "texts" in the future
         if (type.equals("documents") || type.equals("base/texts")) {
@@ -568,7 +583,7 @@
             };
             return docCount;
         };
-    
+
         // Create search term
         // This may be prefixed by foundries
         Term term = new Term(field, "-:" + type);
@@ -577,17 +592,14 @@
         try {
             // Iterate over all atomic readers and collect occurrences
             for (AtomicReaderContext atomic : this.reader().leaves()) {
-                occurrences += this._numberOfAtomic(
-                    collection.bits(atomic),
-                    atomic,
-                    term
-                );
+                occurrences += this._numberOfAtomic(collection.bits(atomic),
+                        atomic, term);
             };
         }
 
         // Something went wrong
         catch (Exception e) {
-            log.warn( e.getLocalizedMessage() );
+            log.warn(e.getLocalizedMessage());
         };
 
         return occurrences;
@@ -597,11 +609,14 @@
     /**
      * Search for the number of occurrences of different types,
      * e.g. <i>documents</i>, <i>sentences</i> etc.
-     *
-     * @param field The field containing the textual data and the
-     *        annotations as a string.
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param field
+     *            The field containing the textual data and the
+     *            annotations as a string.
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @see KrillCollection#numberOf
      */
@@ -614,9 +629,11 @@
      * Search for the number of occurrences of different types,
      * e.g. <i>documents<i>, <i>sentences</i> etc., in the
      * <i>base</i> foundry.
-     *
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @see KrillCollection#numberOf
      */
@@ -628,23 +645,28 @@
     /**
      * Search for the number of occurrences of different types,
      * e.g. <i>documents</i>, <i>sentences</i> etc.
-     *
-     * @param docvec The scope of the numbering by means of a
-     *        {@link Bits} vector
-     * @param field The field containing the textual data and the
-     *        annotations as a string.
-     * @param type The type of meta information,
-     *        e.g. <i>documents</i> or <i>sentences</i> as a string.
+     * 
+     * @param docvec
+     *            The scope of the numbering by means of a
+     *            {@link Bits} vector
+     * @param field
+     *            The field containing the textual data and the
+     *            annotations as a string.
+     * @param type
+     *            The type of meta information,
+     *            e.g. <i>documents</i> or <i>sentences</i> as a
+     *            string.
      * @return The number of the occurrences.
      * @throws IOException
      */
-    public long numberOf (Bits docvec, String field, String type) throws IOException {
+    public long numberOf (Bits docvec, String field, String type)
+            throws IOException {
         // Shortcut for documents
         if (type.equals("documents")) {
             OpenBitSet os = (OpenBitSet) docvec;
             return os.cardinality();
         };
-    
+
         Term term = new Term(field, "-:" + type);
 
         int occurrences = 0;
@@ -654,21 +676,19 @@
             };
         }
         catch (IOException e) {
-            log.warn( e.getLocalizedMessage() );
+            log.warn(e.getLocalizedMessage());
         };
-        
+
         return occurrences;
     };
 
 
 
-
     // Search for meta information in term vectors
     // This will create the sum of all numerical payloads
     // of the term in the document vector
-    private long _numberOfAtomic (Bits docvec,
-                                  AtomicReaderContext atomic,
-                                  Term term) throws IOException {
+    private long _numberOfAtomic (Bits docvec, AtomicReaderContext atomic,
+            Term term) throws IOException {
 
         // This reimplements docsAndPositionsEnum with payloads
         final Terms terms = atomic.reader().fields().terms(term.field());
@@ -682,11 +702,8 @@
             if (termsEnum.seekExact(term.bytes())) {
 
                 // Start an iterator to fetch all payloads of the term
-                DocsAndPositionsEnum docs = termsEnum.docsAndPositions(
-                    docvec,
-                    null,
-                    DocsAndPositionsEnum.FLAG_PAYLOADS
-                );
+                DocsAndPositionsEnum docs = termsEnum.docsAndPositions(docvec,
+                        null, DocsAndPositionsEnum.FLAG_PAYLOADS);
 
                 // The iterator is empty
                 // This may even be an error, but we return 0
@@ -722,12 +739,6 @@
 
 
 
-
-
-
-
-
-
     public String getMatchIDWithContext (String id) {
         /* No includeHighlights */
         return "";
@@ -735,82 +746,47 @@
 
 
     public Match getMatch (String id) throws QueryException {
-        return this.getMatchInfo(
-            id,       // MatchID
-            "tokens", // field
-            false,    // info
-            (ArrayList) null,     // foundry
-            (ArrayList) null,     // layer
-            false,    // includeSpans
-            true,     // includeHighlights
-            false     // extendToSentence
-        );
+        return this.getMatchInfo(id,       // MatchID
+                "tokens", // field
+                false,    // info
+                (ArrayList) null,     // foundry
+                (ArrayList) null,     // layer
+                false,    // includeSpans
+                true,     // includeHighlights
+                false     // extendToSentence
+                );
     };
 
 
     // There is a good chance that some of these methods will die ...
-    public Match getMatchInfo (String id,
-                                    String field,
-                                    String foundry,
-                                    String layer,
-                                    boolean includeSpans,
-                                    boolean includeHighlights) throws QueryException {
-        return this.getMatchInfo(
-            id,
-            field,
-            true,
-            foundry,
-            layer,
-            includeSpans,
-            includeHighlights,
-            false
-        );
+    public Match getMatchInfo (String id, String field, String foundry,
+            String layer, boolean includeSpans, boolean includeHighlights)
+            throws QueryException {
+        return this.getMatchInfo(id, field, true, foundry, layer, includeSpans,
+                includeHighlights, false);
     };
 
 
-    public Match getMatchInfo (String id,
-                                    String field,
-                                    String foundry,
-                                    String layer,
-                                    boolean includeSpans,
-                                    boolean includeHighlights,
-                                    boolean extendToSentence) throws QueryException {
-        return this.getMatchInfo(
-            id,
-            field,
-            true,
-            foundry,
-            layer,
-            includeSpans,
-            includeHighlights,
-            extendToSentence
-        );
+    public Match getMatchInfo (String id, String field, String foundry,
+            String layer, boolean includeSpans, boolean includeHighlights,
+            boolean extendToSentence) throws QueryException {
+        return this.getMatchInfo(id, field, true, foundry, layer, includeSpans,
+                includeHighlights, extendToSentence);
     };
 
-    public Match getMatchInfo (String id,
-                               String field,
-                               boolean info,
-                               String foundry,
-                               String layer,
-                               boolean includeSpans,
-                               boolean includeHighlights,
-                               boolean extendToSentence) throws QueryException {
-    	ArrayList<String> foundryList = new ArrayList<>(1);
+
+    public Match getMatchInfo (String id, String field, boolean info,
+            String foundry, String layer, boolean includeSpans,
+            boolean includeHighlights, boolean extendToSentence)
+            throws QueryException {
+        ArrayList<String> foundryList = new ArrayList<>(1);
         if (foundry != null)
             foundryList.add(foundry);
         ArrayList<String> layerList = new ArrayList<>(1);
         if (layer != null)
             layerList.add(layer);
-        return this.getMatchInfo(
-            id,
-            field,
-            info,
-            foundryList,
-            layerList,
-            includeSpans,
-            includeHighlights,
-            extendToSentence
-        );
+        return this.getMatchInfo(id, field, info, foundryList, layerList,
+                includeSpans, includeHighlights, extendToSentence);
     };
 
 
@@ -821,14 +797,10 @@
       KorapInfo is associated with a Match and has an array with all informations
       per position in the match.
     */
-    public Match getMatchInfo (String idString,
-                               String field,
-                               boolean info,
-                               List<String> foundry,
-                               List<String> layer,
-                               boolean includeSpans,
-                               boolean includeHighlights,
-                               boolean extendToSentence) throws QueryException {
+    public Match getMatchInfo (String idString, String field, boolean info,
+            List<String> foundry, List<String> layer, boolean includeSpans,
+            boolean includeHighlights, boolean extendToSentence)
+            throws QueryException {
 
         Match match = new Match(idString, includeHighlights);
 
@@ -843,12 +815,14 @@
 
         // Create a filter based on the corpusID and the docID
         BooleanQuery bool = new BooleanQuery();
-        bool.add(new TermQuery(new Term("ID",       match.getDocID())),    BooleanClause.Occur.MUST);
-        bool.add(new TermQuery(new Term("corpusID", match.getCorpusID())), BooleanClause.Occur.MUST);
+        bool.add(new TermQuery(new Term("ID", match.getDocID())),
+                BooleanClause.Occur.MUST);
+        bool.add(new TermQuery(new Term("corpusID", match.getCorpusID())),
+                BooleanClause.Occur.MUST);
         Filter filter = (Filter) new QueryWrapperFilter(bool);
-        
+
         CompiledAutomaton fst = null;
-        
+
         if (info) {
             /* Create an automaton for prefixed terms of interest.
              * You can define the necessary foundry, the necessary layer,
@@ -858,20 +832,21 @@
             StringBuilder regex = new StringBuilder();
             // TODO: Make these static
             Pattern harmlessFoundry = Pattern.compile("^[-a-zA-Z0-9_]+$");
-            Pattern harmlessLayer   = Pattern.compile("^[-a-zA-Z0-9_:]+$");
+            Pattern harmlessLayer = Pattern.compile("^[-a-zA-Z0-9_:]+$");
             Iterator<String> iter;
             int i = 0;
-	    
+
             if (includeSpans)
                 regex.append("((\">\"|\"<\"\">\")\":\")?");
-            
+
             // There is a foundry given
             if (foundry != null && foundry.size() > 0) {
 
                 // Filter out bad foundries
-                for (i = foundry.size() - 1; i >= 0 ; i--) {
+                for (i = foundry.size() - 1; i >= 0; i--) {
                     if (!harmlessFoundry.matcher(foundry.get(i)).matches()) {
-                        throw new QueryException("Invalid foundry requested: '" + foundry.get(i) + "'");
+                        throw new QueryException("Invalid foundry requested: '"
+                                + foundry.get(i) + "'");
                         // foundry.remove(i);
                     };
                 };
@@ -890,9 +865,11 @@
                     if (layer != null && layer.size() > 0) {
 
                         // Filter out bad layers
-                        for (i = layer.size() - 1; i >= 0 ; i--) {
+                        for (i = layer.size() - 1; i >= 0; i--) {
                             if (!harmlessLayer.matcher(layer.get(i)).matches()) {
-                                throw new QueryException("Invalid layer requested: " + layer.get(i));
+                                throw new QueryException(
+                                        "Invalid layer requested: "
+                                                + layer.get(i));
                                 // layer.remove(i);
                             };
                         };
@@ -904,7 +881,8 @@
                             while (iter.hasNext()) {
                                 regex.append(iter.next()).append("|");
                             };
-                            regex.replace(regex.length() - 1, regex.length(), ")");
+                            regex.replace(regex.length() - 1, regex.length(),
+                                    ")");
                             regex.append("\":\"");
                         };
                     };
@@ -919,7 +897,7 @@
                 regex.append("([^-is<>]|[-is>][^:]|<[^:>])");
             };
             regex.append("(.){1,}|_[0-9]+");
-            
+
             if (DEBUG)
                 log.trace("The final regexString is {}", regex.toString());
             RegExp regexObj = new RegExp(regex.toString(), RegExp.COMPLEMENT);
@@ -933,10 +911,8 @@
             for (AtomicReaderContext atomic : this.reader().leaves()) {
 
                 // Retrieve the single document of interest
-                DocIdSet filterSet = filter.getDocIdSet(
-                    atomic,
-                    atomic.reader().getLiveDocs()
-                );
+                DocIdSet filterSet = filter.getDocIdSet(atomic, atomic.reader()
+                        .getLiveDocs());
 
                 // Create a bitset for the correct document
                 Bits bitset = filterSet.bits();
@@ -957,12 +933,13 @@
                 if (DEBUG)
                     log.trace("We've found a matching document");
 
-                HashSet<String> fields = (HashSet<String>)
-                    new Krill().getMeta().getFields().clone();
+                HashSet<String> fields = (HashSet<String>) new Krill()
+                        .getMeta().getFields().clone();
                 fields.add(field);
 
                 // Get terms from the document
-                Terms docTerms = atomic.reader().getTermVector(localDocID, field);
+                Terms docTerms = atomic.reader().getTermVector(localDocID,
+                        field);
 
                 // Load the necessary fields of the document
                 Document doc = atomic.reader().document(localDocID, fields);
@@ -980,7 +957,7 @@
 
                 // Search for minimal surrounding sentences
                 if (extendToSentence) {
-                    int [] spanContext = match.expandContextToSpan("s");
+                    int[] spanContext = match.expandContextToSpan("s");
                     match.setStartPos(spanContext[0]);
                     match.setEndPos(spanContext[1]);
                     match.startMore = false;
@@ -990,7 +967,7 @@
                     if (DEBUG)
                         log.trace("Don't expand context");
                 };
-                
+
                 context.left.setToken(true).setLength(0);
                 context.right.setToken(true).setLength(0);
 
@@ -1004,19 +981,16 @@
 
                 // List of terms to populate
                 SpanInfo termList = new SpanInfo(pto, localDocID);
-        
+
                 // Iterate over all terms in the document
                 while (termsEnum.next() != null) {
-                    
+
                     // Get the positions and payloads of the term in the document
                     // The bitvector may look different (don't know why)
                     // and so the local ID may differ.
                     // That's why the requesting bitset is null.
-                    docs = termsEnum.docsAndPositions(
-                        null,
-                        docs,
-                        DocsAndPositionsEnum.FLAG_PAYLOADS
-                    );
+                    docs = termsEnum.docsAndPositions(null, docs,
+                            DocsAndPositionsEnum.FLAG_PAYLOADS);
 
                     // Init document iterator
                     docs.nextDoc();
@@ -1027,7 +1001,7 @@
 
                     // How often does this term occur in the document?
                     int termOccurrences = docs.freq();
-                    
+
                     // String representation of the term
                     String termString = termsEnum.term().utf8ToString();
 
@@ -1038,29 +1012,23 @@
                         int pos = docs.nextPosition();
 
                         // Check, if the position of the term is in the area of interest
-                        if (pos >= match.getStartPos() && pos < match.getEndPos()) {
+                        if (pos >= match.getStartPos()
+                                && pos < match.getEndPos()) {
 
                             if (DEBUG)
-                                log.trace(
-                                    ">> {}: {}-{}-{}",
-                                    termString, 
-                                    docs.freq(),
-                                    pos,
-                                    docs.getPayload()
-                                );
+                                log.trace(">> {}: {}-{}-{}", termString,
+                                        docs.freq(), pos, docs.getPayload());
 
                             BytesRef payload = docs.getPayload();
 
                             // Copy the payload
                             bbTerm.clear();
                             if (payload != null) {
-                                bbTerm.put(
-                                    payload.bytes,
-                                    payload.offset,
-                                    payload.length
-                                );
+                                bbTerm.put(payload.bytes, payload.offset,
+                                        payload.length);
                             };
-                            TermInfo ti = new TermInfo(termString, pos, bbTerm).analyze();
+                            TermInfo ti = new TermInfo(termString, pos, bbTerm)
+                                    .analyze();
                             if (ti.getEndPos() < match.getEndPos()) {
                                 if (DEBUG)
                                     log.trace("Add {}", ti.toString());
@@ -1073,23 +1041,19 @@
                 // Add annotations based on the retrieved infos
                 for (TermInfo t : termList.getTerms()) {
                     if (DEBUG)
-                        log.trace(
-                            "Add term {}/{}:{} to {}({})-{}({})",
-                            t.getFoundry(),
-                            t.getLayer(),
-                            t.getValue(),
-                            t.getStartChar(),
-                            t.getStartPos(),
-                            t.getEndChar(),
-                            t.getEndPos()
-                        );
+                        log.trace("Add term {}/{}:{} to {}({})-{}({})",
+                                t.getFoundry(), t.getLayer(), t.getValue(),
+                                t.getStartChar(), t.getStartPos(),
+                                t.getEndChar(), t.getEndPos());
 
                     if (t.getType() == "term" || t.getType() == "span")
-                        match.addAnnotation(t.getStartPos(), t.getEndPos(), t.getAnnotation());
+                        match.addAnnotation(t.getStartPos(), t.getEndPos(),
+                                t.getAnnotation());
                     else if (t.getType() == "relSrc")
-                        match.addRelation(t.getStartPos(), t.getEndPos(), t.getAnnotation());
+                        match.addRelation(t.getStartPos(), t.getEndPos(),
+                                t.getAnnotation());
                 };
-                
+
                 break;
             };
         }
@@ -1112,21 +1076,22 @@
      * Analyze how terms relate
      */
     @Deprecated
-    public HashMap getTermRelation (KrillCollection kc, String field) throws Exception {
-        HashMap<String,Long> map = new HashMap<>(100);
+    public HashMap getTermRelation (KrillCollection kc, String field)
+            throws Exception {
+        HashMap<String, Long> map = new HashMap<>(100);
         long docNumber = 0, checkNumber = 0;
-        
+
         try {
             if (kc.getCount() <= 0) {
                 checkNumber = (long) this.reader().numDocs();
             };
 
             for (AtomicReaderContext atomic : this.reader().leaves()) {
-                HashMap<String,FixedBitSet> termVector = new HashMap<>(20);
-        
+                HashMap<String, FixedBitSet> termVector = new HashMap<>(20);
+
                 FixedBitSet docvec = kc.bits(atomic);
                 if (docvec != null) {
-                    docNumber += docvec.cardinality();		    
+                    docNumber += docvec.cardinality();
                 };
 
                 Terms terms = atomic.reader().fields().terms(field);
@@ -1134,7 +1099,7 @@
                 if (terms == null) {
                     continue;
                 };
-		
+
                 int docLength = atomic.reader().maxDoc();
                 FixedBitSet bitset = new FixedBitSet(docLength);
 
@@ -1142,43 +1107,45 @@
                 TermsEnum termsEnum = terms.iterator(null);
 
                 while (termsEnum.next() != null) {
-                    
+
                     String termString = termsEnum.term().utf8ToString();
 
-                    bitset.clear(0,docLength);
-	    
+                    bitset.clear(0, docLength);
+
                     // Get frequency
-                    bitset.or((DocIdSetIterator) termsEnum.docs((Bits) docvec, null));
-            
+                    bitset.or((DocIdSetIterator) termsEnum.docs((Bits) docvec,
+                            null));
+
                     long value = 0;
                     if (map.containsKey(termString))
                         value = map.get(termString);
 
                     map.put(termString, value + bitset.cardinality());
-                    
+
                     termVector.put(termString, bitset.clone());
                 };
-                
+
                 int keySize = termVector.size();
-                String[] keys = termVector.keySet().toArray(new String[keySize]);
+                String[] keys = termVector.keySet()
+                        .toArray(new String[keySize]);
                 java.util.Arrays.sort(keys);
 
                 if (keySize > maxTermRelations) {
-                    throw new Exception(
-                        "termRelations are limited to " + maxTermRelations + " sets" +
-                        " (requested were at least " + keySize + " sets)"
-                    );
+                    throw new Exception("termRelations are limited to "
+                            + maxTermRelations + " sets"
+                            + " (requested were at least " + keySize + " sets)");
                 };
-                
+
                 for (int i = 0; i < keySize; i++) {
-                    for (int j = i+1; j < keySize; j++) {
+                    for (int j = i + 1; j < keySize; j++) {
                         FixedBitSet comby = termVector.get(keys[i]).clone();
                         comby.and(termVector.get(keys[j]));
 
                         StringBuilder sb = new StringBuilder();
-                        sb.append("#__").append(keys[i]).append(":###:").append(keys[j]);
+                        sb.append("#__").append(keys[i]).append(":###:")
+                                .append(keys[j]);
                         String combString = sb.toString();
-                        
+
                         long cap = (long) comby.cardinality();
                         if (map.containsKey(combString)) {
                             cap += map.get(combString);
@@ -1190,12 +1157,12 @@
             map.put("-docs", checkNumber != 0 ? checkNumber : docNumber);
         }
         catch (IOException e) {
-            log.warn(e.getMessage());	    
+            log.warn(e.getMessage());
         };
         return map;
     };
 
-    
+
     /**
      * Search in the index.
      */
@@ -1212,47 +1179,27 @@
 
 
     @Deprecated
-    public Result search (SpanQuery query,
-                               int startIndex,
-                               short count,
-                               boolean leftTokenContext,
-                               short leftContext,
-                               boolean rightTokenContext,
-                               short rightContext) {
+    public Result search (SpanQuery query, int startIndex, short count,
+            boolean leftTokenContext, short leftContext,
+            boolean rightTokenContext, short rightContext) {
 
         Krill ks = new Krill(query);
         KrillMeta meta = ks.getMeta();
         meta.setStartIndex(startIndex).setCount(count);
-        meta.setContext(
-            new SearchContext(
-                leftTokenContext,
-                leftContext,
-                rightTokenContext,
-                rightContext
-            )
-        );	
+        meta.setContext(new SearchContext(leftTokenContext, leftContext,
+                rightTokenContext, rightContext));
         return this.search(ks);
     };
 
 
     @Deprecated
-    public Result search (KrillCollection collection,
-                               SpanQuery query,
-                               int startIndex,
-                               short count,
-                               boolean leftTokenContext,
-                               short leftContext,
-                               boolean rightTokenContext,
-                               short rightContext) {
+    public Result search (KrillCollection collection, SpanQuery query,
+            int startIndex, short count, boolean leftTokenContext,
+            short leftContext, boolean rightTokenContext, short rightContext) {
         Krill ks = new Krill(query);
         ks.getMeta().setContext(
-            new SearchContext(
-                leftTokenContext,
-                leftContext,
-                rightTokenContext,
-                rightContext
-            )
-        );
+                new SearchContext(leftTokenContext, leftContext,
+                        rightTokenContext, rightContext));
         ks.setCollection(collection);
         return this.search(ks);
     };
@@ -1279,12 +1226,8 @@
         KrillMeta meta = ks.getMeta();
 
         // Todo: Make kr subclassing ks - so ks has a method for a new Result!
-        Result kr = new Result(
-            query.toString(),
-            meta.getStartIndex(),
-            meta.getCount(),
-            meta.getContext()
-        );
+        Result kr = new Result(query.toString(), meta.getStartIndex(),
+                meta.getCount(), meta.getContext());
 
         // Set version info to result
         if (this.getVersion() != null)
@@ -1295,14 +1238,11 @@
         fields.add(field);
 
         // Some initializations ...
-        int i                       = 0,
-            startIndex              = kr.getStartIndex(),
-            count                   = kr.getItemsPerPage(),
-            hits                    = kr.getItemsPerPage() + startIndex,
-            limit                   = meta.getLimit(),
-            itemsPerResourceCounter = 0;
-        boolean cutoff              = meta.doCutOff();
-        short itemsPerResource      = meta.getItemsPerResource();
+        int i = 0, startIndex = kr.getStartIndex(), count = kr
+                .getItemsPerPage(), hits = kr.getItemsPerPage() + startIndex, limit = meta
+                .getLimit(), itemsPerResourceCounter = 0;
+        boolean cutoff = meta.doCutOff();
+        short itemsPerResource = meta.getItemsPerResource();
 
         // Check if there is work to do at all
         // TODO: Deprecated
@@ -1316,9 +1256,9 @@
         };
 
         // Collect matches from atomic readers
-        ArrayList<Match> atomicMatches =
-            new ArrayList<Match>(kr.getItemsPerPage());
-        
+        ArrayList<Match> atomicMatches = new ArrayList<Match>(
+                kr.getItemsPerPage());
+
         // Start time out thread
         TimeOutThread tthread = new TimeOutThread();
         tthread.start();
@@ -1332,12 +1272,12 @@
             // Revise!
             // Based on core/src/java/org/apache/lucene/search/IndexSearcher.java
             // and highlighter/src/java/org/apache/lucene/search/postingshighlight/PostingsHighlighter.java
-            for ( Query rewrittenQuery = query.rewrite(this.reader());
-                  !rewrittenQuery.equals(query);
-                  rewrittenQuery = query.rewrite(this.reader())) {
+            for (Query rewrittenQuery = query.rewrite(this.reader()); !rewrittenQuery
+                    .equals(query); rewrittenQuery = query.rewrite(this
+                    .reader())) {
                 query = (SpanQuery) rewrittenQuery;
             };
-	    
+
 
             // Todo: run this in a separated thread
             for (AtomicReaderContext atomic : this.reader().leaves()) {
@@ -1353,16 +1293,17 @@
                 PositionsToOffset pto = new PositionsToOffset(atomic, field);
 
                 // Spans spans = NearSpansOrdered();
-                Spans spans = query.getSpans(atomic, (Bits) bitset, termContexts);
+                Spans spans = query.getSpans(atomic, (Bits) bitset,
+                        termContexts);
 
                 IndexReader lreader = atomic.reader();
-                
+
                 // TODO: Get document information from Cache! Fieldcache?
-                for (; i < hits;i++) {
+                for (; i < hits; i++) {
 
                     if (DEBUG)
                         log.trace("Match Nr {}/{}", i, count);
-                    
+
                     // There are no more spans to find
                     if (!spans.next())
                         break;
@@ -1372,7 +1313,7 @@
                         kr.setTimeExceeded(true);
                         break;
                     };
-                    
+
                     int localDocID = spans.doc();
 
                     // Count hits per resource
@@ -1390,11 +1331,11 @@
                                 };
                             };
                         }
-                        
+
                         // Reset counter
                         else
                             itemsPerResourceCounter = 0;
-                        
+
                         oldLocalDocID = localDocID;
                     };
 
@@ -1403,17 +1344,13 @@
                         continue;
 
                     int docID = atomic.docBase + localDocID;
-                    
+
                     // Do not load all of this, in case the doc is the same!
                     Document doc = lreader.document(localDocID, fields);
 
                     // Create new Match
-                    Match match = new Match(
-                        pto,
-                        localDocID,
-                        spans.start(),
-                        spans.end()
-                    );
+                    Match match = new Match(pto, localDocID, spans.start(),
+                            spans.end());
                     match.setContext(kr.getContext());
 
                     // Add match to Result
@@ -1424,16 +1361,16 @@
 
                     match.internalDocID = docID;
                     match.populateDocument(doc, field, fields);
-		    
+
                     if (DEBUG) {
                         if (match.getDocID() != null)
                             log.trace("I've got a match in {} of {}",
-                                      match.getDocID(), count);
+                                    match.getDocID(), count);
                         else
                             log.trace("I've got a match in {} of {}",
-                                      match.getUID(), count);
+                                    match.getUID(), count);
                     };
-                    
+
                     atomicMatches.add(match);
                 };
 
@@ -1443,7 +1380,7 @@
                     // TODO: Deprecated
                     if (limit > 0 && i >= limit)
                         break;
-                    
+
                     // Timeout!
                     if (tthread.getTime() > timeout) {
                         kr.setTimeExceeded(true);
@@ -1456,7 +1393,7 @@
 
                         if (localDocID == DocIdSetIterator.NO_MORE_DOCS)
                             break;
-			
+
                         // IDS are identical
                         if (localDocID == oldLocalDocID || oldLocalDocID == -1) {
                             if (localDocID == -1)
@@ -1488,12 +1425,8 @@
             kr.setTotalResults(cutoff ? (long) -1 : (long) i);
         }
         catch (IOException e) {
-            kr.addError(
-                600,
-                "Unable to read index",
-                e.getLocalizedMessage()
-            );
-            log.warn( e.getLocalizedMessage() );
+            kr.addError(600, "Unable to read index", e.getLocalizedMessage());
+            log.warn(e.getLocalizedMessage());
         };
 
         // Stop timer thread
@@ -1535,9 +1468,8 @@
         try {
 
             // Rewrite query (for regex and wildcard queries)
-            for (Query rewrittenQuery = query.rewrite(this.reader());
-                 rewrittenQuery != (Query) query;
-                 rewrittenQuery = query.rewrite(this.reader())) {
+            for (Query rewrittenQuery = query.rewrite(this.reader()); rewrittenQuery != (Query) query; rewrittenQuery = query
+                    .rewrite(this.reader())) {
                 query = (SpanQuery) rewrittenQuery;
             };
 
@@ -1555,8 +1487,9 @@
                 Bits bitset = collection.bits(atomic);
 
                 // PositionsToOffset pto = new PositionsToOffset(atomic, field);
-                
-                Spans spans = query.getSpans(atomic, (Bits) bitset, termContexts);
+
+                Spans spans = query.getSpans(atomic, (Bits) bitset,
+                        termContexts);
 
                 IndexReader lreader = atomic.reader();
 
@@ -1582,12 +1515,12 @@
                         };
 
                         // Read document id from index
-                        uniqueDocIDString =
-                            lreader.document(localDocID, fields).get("UID");
+                        uniqueDocIDString = lreader
+                                .document(localDocID, fields).get("UID");
 
                         if (uniqueDocIDString != null)
                             uniqueDocID = Integer.parseInt(uniqueDocIDString);
-                        
+
                         previousDocID = localDocID;
                     }
                     else {
@@ -1607,15 +1540,11 @@
             mc.setBenchmark(t1, System.nanoTime());
         }
         catch (IOException e) {
-            mc.addError(
-                600,
-                "Unable to read index",
-                e.getLocalizedMessage()
-            );
+            mc.addError(600, "Unable to read index", e.getLocalizedMessage());
             log.warn(e.getLocalizedMessage());
         };
 
         mc.close();
-        return mc; 
+        return mc;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/KrillMeta.java b/src/main/java/de/ids_mannheim/korap/KrillMeta.java
index 16b9865..b1023c2 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillMeta.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillMeta.java
@@ -7,7 +7,6 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.*;
 
-
 import de.ids_mannheim.korap.response.SearchContext;
 import de.ids_mannheim.korap.util.QueryException;
 import de.ids_mannheim.korap.response.Notifications;
@@ -28,7 +27,7 @@
     private SearchContext context;
 
     private HashSet<String> fields;
-            HashSet<Integer> highlights;
+    HashSet<Integer> highlights;
 
     // Timeout search after milliseconds
     private long timeout = (long) 120_000;
@@ -42,35 +41,26 @@
 
         // Lift following fields per default
         // These fields are chosen for <legacy /> reasons
-        for (String field : new String[]{
-                "ID",
-                "UID",
-                "textSigle",
-                "corpusID",
-                "author",
-                "title",
-                "subTitle",
-                "textClass",
-                "pubPlace",
-                "pubDate",
-                "foundries",
-                "layerInfo",
-                "tokenization"}) {
+        for (String field : new String[] { "ID", "UID", "textSigle",
+                "corpusID", "author", "title", "subTitle", "textClass",
+                "pubPlace", "pubDate", "foundries", "layerInfo", "tokenization" }) {
             fields.add(field);
         };
 
         // Classes used for highlights
         highlights = new HashSet<Integer>(3);
-        context  = new SearchContext();
+        context = new SearchContext();
     };
 
 
     public KrillMeta () {};
 
+
     public KrillMeta (JsonNode json) {
         this.fromJson(json);
     };
 
+
     public KrillMeta (String json) {
         try {
             this.fromJson(json);
@@ -80,6 +70,7 @@
         };
     };
 
+
     public KrillMeta fromJson (String json) throws QueryException {
         JsonNode jsonN;
         try {
@@ -149,13 +140,13 @@
             else
                 this.addHighlight(json.get("highlight").asInt());
         };
-        
+
         // Defined fields to lift from the index
         if (json.has("fields")) {
-                        
+
             // Remove default fields
             this.fields.clear();
-            
+
             // Add fields
             if (json.get("fields").isArray()) {
                 for (JsonNode field : (JsonNode) json.get("fields")) {
@@ -174,18 +165,21 @@
         return this.count;
     };
 
+
     public KrillMeta setCount (int value) {
         // Todo: Maybe update startIndex with known startPage!
         this.setCount((short) value);
         return this;
     };
 
+
     public KrillMeta setCount (short value) {
         if (value > 0)
             this.count = (value <= this.countMax) ? value : this.countMax;
         return this;
     };
 
+
     public short getCountMax () {
         return this.countMax;
     };
@@ -194,12 +188,14 @@
     public int getStartIndex () {
         return this.startIndex;
     };
-    
+
+
     public KrillMeta setStartIndex (int value) {
         this.startIndex = (value >= 0) ? value : 0;
         return this;
     };
 
+
     public KrillMeta setStartPage (int value) {
         if (value >= 0)
             this.setStartIndex((value * this.getCount()) - this.getCount());
@@ -213,20 +209,24 @@
         return this.timeout;
     };
 
+
     public void setTimeOut (long timeout) {
         this.timeout = timeout;
     };
 
+
     public KrillMeta setItemsPerResource (short value) {
         if (value >= 0)
             this.itemsPerResource = value;
         return this;
     };
 
+
     public KrillMeta setItemsPerResource (int value) {
         return this.setItemsPerResource((short) value);
     };
 
+
     public short getItemsPerResource () {
         return this.itemsPerResource;
     };
@@ -236,6 +236,7 @@
         return this.context;
     };
 
+
     public KrillMeta setContext (SearchContext context) {
         this.context = context;
         return this;
@@ -253,8 +254,9 @@
 
     /**
      * Add a field to the set of fields to retrieve.
-     *
-     * @param field The field to retrieve.
+     * 
+     * @param field
+     *            The field to retrieve.
      * @return The {@link Krill} object for chaining.
      */
     public KrillMeta addField (String field) {
@@ -265,8 +267,9 @@
 
     /**
      * Add class numbers to highlight in KWIC view.
-     *
-     * @param classNumber The number of a class to highlight.
+     * 
+     * @param classNumber
+     *            The number of a class to highlight.
      * @return The {@link Krill} object for chaining.
      */
     public KrillMeta addHighlight (int classNumber) {
@@ -280,6 +283,7 @@
         return this.cutOff;
     };
 
+
     @Deprecated
     public KrillMeta setCutOff (boolean cutOff) {
         this.cutOff = cutOff;
@@ -295,6 +299,7 @@
         return this.limit;
     };
 
+
     // TODO:
     // This limits the search results with offset
     // Maybe can be deprecated!
@@ -309,7 +314,7 @@
     @Override
     public JsonNode toJsonNode () {
         ObjectMapper mapper = new ObjectMapper();
-        ObjectNode json =  mapper.createObjectNode();
+        ObjectNode json = mapper.createObjectNode();
         // json.put("@type", "koral:meta");
 
         ArrayNode fieldNode = mapper.createArrayNode();
@@ -322,23 +327,23 @@
 
         // Add limit attribute
         if (this.limit > 0)
-            json.put("limit",  this.getLimit());
+            json.put("limit", this.getLimit());
         // </legacy>
 
         // Add count attribute
-        json.put("count",      this.getCount());
+        json.put("count", this.getCount());
 
         // Add startindex attribute
         json.put("startIndex", this.getStartIndex());
 
         // Add timeout attribute
-        json.put("timeout",    this.getTimeOut());
+        json.put("timeout", this.getTimeOut());
 
         // Add context attribute
-        json.put("context",    this.getContext().toJsonNode());
+        json.put("context", this.getContext().toJsonNode());
 
         // Add fields attribute
-        json.put("fields",     fieldNode); 
+        json.put("fields", fieldNode);
 
         // Add itemsPerResource attribute
         if (this.itemsPerResource > 0)
diff --git a/src/main/java/de/ids_mannheim/korap/KrillQuery.java b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
index 7ad031e..b5390e3 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillQuery.java
@@ -23,14 +23,15 @@
  * KrillQuery provides deserialization methods
  * for KoralQuery query objects.
  * </p>
- *
+ * 
  * <blockquote><pre>
- *   // Create or receive a KoralQuery JSON string
- *   String koral = "{\"@type\":"koral:group", ... }";
- *
- *   SpanQueryWrapper sqw = new KrillQuery("tokens").fromJson("{... JsonString ...}");
+ * // Create or receive a KoralQuery JSON string
+ * String koral = "{\"@type\":"koral:group", ... }";
+ * 
+ * SpanQueryWrapper sqw = new
+ * KrillQuery("tokens").fromJson("{... JsonString ...}");
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  */
 /*
@@ -62,14 +63,13 @@
     public static final boolean DEBUG = false;
 
     // <legacy>
-    public static final byte
-        OVERLAP      = SpanWithinQuery.OVERLAP,
-        REAL_OVERLAP = SpanWithinQuery.REAL_OVERLAP,
-        WITHIN       = SpanWithinQuery.WITHIN,
-        REAL_WITHIN  = SpanWithinQuery.REAL_WITHIN,
-        ENDSWITH     = SpanWithinQuery.ENDSWITH,
-        STARTSWITH   = SpanWithinQuery.STARTSWITH,
-        MATCH        = SpanWithinQuery.MATCH;
+    public static final byte OVERLAP = SpanWithinQuery.OVERLAP,
+            REAL_OVERLAP = SpanWithinQuery.REAL_OVERLAP,
+            WITHIN = SpanWithinQuery.WITHIN,
+            REAL_WITHIN = SpanWithinQuery.REAL_WITHIN,
+            ENDSWITH = SpanWithinQuery.ENDSWITH,
+            STARTSWITH = SpanWithinQuery.STARTSWITH,
+            MATCH = SpanWithinQuery.MATCH;
     // </legacy>
 
     private static final int MAX_CLASS_NUM = 255; // 127;
@@ -78,16 +78,15 @@
     private class Boundary {
         public int min, max;
 
+
         // Constructor for boundaries
         public Boundary (JsonNode json, int defaultMin, int defaultMax)
-            throws QueryException {
-            
+                throws QueryException {
+
             // No @type defined
             if (!json.has("@type")) {
-                throw new QueryException(
-                    701,
-                    "JSON-LD group has no @type attribute"
-                );
+                throw new QueryException(701,
+                        "JSON-LD group has no @type attribute");
             };
 
             // Wrong @type defined
@@ -95,27 +94,27 @@
                 throw new QueryException(702, "Boundary definition is invalid");
 
             // Set min boundary
-            this.min = json.has("min") ?
-                json.get("min").asInt(defaultMin) :
-                defaultMin;
+            this.min = json.has("min") ? json.get("min").asInt(defaultMin)
+                    : defaultMin;
 
             // Set max boundary
-            this.max = json.has("max") ?
-                json.get("max").asInt(defaultMax) :
-                defaultMax;
-            
+            this.max = json.has("max") ? json.get("max").asInt(defaultMax)
+                    : defaultMax;
+
             if (DEBUG)
                 log.trace("Found koral:boundary with {}:{}", min, max);
         };
     };
 
+
     /**
      * Constructs a new object for query deserialization
      * and building. Expects the name of an index field
      * to apply the query on (this should normally be
      * a token stream field).
-     *
-     * @param field The specific index field for the query.
+     * 
+     * @param field
+     *            The specific index field for the query.
      */
     public KrillQuery (String field) {
         this.field = field;
@@ -123,24 +122,26 @@
 
 
     /**
-     * <p>Deserialize JSON-LD query to a {@link SpanQueryWrapper} object.</p>
-     *
+     * <p>Deserialize JSON-LD query to a {@link SpanQueryWrapper}
+     * object.</p>
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanQueryWrapper sqw = kq.fromJson(
-     *     "{\"@type\" : \"koral:token\","+
-     *      "\"wrap\" : {" +
-     *        "\"@type\" :   \"koral:term\"," +
-     *        "\"foundry\" : \"opennlp\"," +
-     *        "\"key\" :     \"tree\"," +
-     *        "\"layer\" :   \"orth\"," +
-     *        "\"match\" :   \"match:eq\""+
-     *      "}}"
-     *   );
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanQueryWrapper sqw = kq.fromJson(
+     * "{\"@type\" : \"koral:token\","+
+     * "\"wrap\" : {" +
+     * "\"@type\" :   \"koral:term\"," +
+     * "\"foundry\" : \"opennlp\"," +
+     * "\"key\" :     \"tree\"," +
+     * "\"layer\" :   \"orth\"," +
+     * "\"match\" :   \"match:eq\""+
+     * "}}"
+     * );
      * </pre></blockquote>
-     *
-     * @param json String representing the JSON query string.
-     * @return {@link SpanQueryWrapper} object. 
+     * 
+     * @param json
+     *            String representing the JSON query string.
+     * @return {@link SpanQueryWrapper} object.
      * @throws QueryException
      */
     public SpanQueryWrapper fromJson (String json) throws QueryException {
@@ -169,9 +170,10 @@
     /**
      * <p>Deserialize JSON-LD query as a {@link JsonNode} object
      * to a {@link SpanQueryWrapper} object.</p>
-     *
-     * @param json {@link JsonNode} representing the JSON query string.
-     * @return {@link SpanQueryWrapper} object. 
+     * 
+     * @param json
+     *            {@link JsonNode} representing the JSON query string.
+     * @return {@link SpanQueryWrapper} object.
      * @throws QueryException
      */
     // TODO: Exception messages are horrible!
@@ -184,7 +186,8 @@
         // Only accept @typed objects for the moment
         // TODO: Support @context for cosmas:...
         if (!json.has("@type"))
-            throw new QueryException(701, "JSON-LD group has no @type attribute");
+            throw new QueryException(701,
+                    "JSON-LD group has no @type attribute");
 
         // Set this for reserialization
         // This may be changed later on
@@ -194,92 +197,92 @@
         String type = json.get("@type").asText();
 
         switch (type) {
-        case "koral:group":
-            return this._groupFromJson(json);
+            case "koral:group":
+                return this._groupFromJson(json);
 
-        case "koral:reference":
-            if (json.has("operation") &&
-                !json.get("operation").asText().equals("operation:focus"))
-                throw new QueryException(712, "Unknown reference operation");
+            case "koral:reference":
+                if (json.has("operation")
+                        && !json.get("operation").asText()
+                                .equals("operation:focus"))
+                    throw new QueryException(712, "Unknown reference operation");
 
-            if (!json.has("operands")) {
-                throw new QueryException(
-                    766,
-                    "Peripheral references are currently not supported"
-                );
-            };
+                if (!json.has("operands")) {
+                    throw new QueryException(766,
+                            "Peripheral references are currently not supported");
+                }
+                ;
 
-            JsonNode operands = json.get("operands");
+                JsonNode operands = json.get("operands");
 
-            if (!operands.isArray())
-                throw new QueryException(704, "Operation needs operand list");
+                if (!operands.isArray())
+                    throw new QueryException(704,
+                            "Operation needs operand list");
 
-            if (operands.size() == 0)
-                throw new QueryException(704, "Operation needs operand list");
+                if (operands.size() == 0)
+                    throw new QueryException(704,
+                            "Operation needs operand list");
 
-            if (operands.size() != 1)
-                throw new QueryException(705, "Number of operands is not acceptable");
+                if (operands.size() != 1)
+                    throw new QueryException(705,
+                            "Number of operands is not acceptable");
 
-            // Reference based on classes
-            if (json.has("classRef")) {
-                if (json.has("classRefOp")) {
-                    throw new QueryException(
-                        761,
-                        "Class reference operators are currently not supported"
-                    );
-                };
+                // Reference based on classes
+                if (json.has("classRef")) {
+                    if (json.has("classRefOp")) {
+                        throw new QueryException(761,
+                                "Class reference operators are currently not supported");
+                    };
 
-                number = json.get("classRef").get(0).asInt();
+                    number = json.get("classRef").get(0).asInt();
 
-                if (number > MAX_CLASS_NUM)
-                    throw new QueryException(
-                        709,
-                        "Valid class numbers exceeded"
-                    );
-            }
+                    if (number > MAX_CLASS_NUM)
+                        throw new QueryException(709,
+                                "Valid class numbers exceeded");
+                }
 
-            // Reference based on spans
-            else if (json.has("spanRef")) {
-                JsonNode spanRef = json.get("spanRef");
-                int length = 0;
-                int startOffset = 0;
-                if (!spanRef.isArray() || spanRef.size() == 0) {
-                    throw new QueryException(
-                        714,
-                        "Span references expect a start position" +
-                        " and a length parameter"
-                    );
-                };
-                
-                if (spanRef.size() > 1)
-                    length = spanRef.get(1).asInt(0);
-	            
-                startOffset = spanRef.get(0).asInt(0);
+                // Reference based on spans
+                else if (json.has("spanRef")) {
+                    JsonNode spanRef = json.get("spanRef");
+                    int length = 0;
+                    int startOffset = 0;
+                    if (!spanRef.isArray() || spanRef.size() == 0) {
+                        throw new QueryException(714,
+                                "Span references expect a start position"
+                                        + " and a length parameter");
+                    };
 
-                if (DEBUG) log.trace("Wrap span reference {},{}", startOffset, length);
+                    if (spanRef.size() > 1)
+                        length = spanRef.get(1).asInt(0);
 
-                SpanQueryWrapper sqw = this.fromJson(operands.get(0));
-				SpanSubspanQueryWrapper ssqw = new SpanSubspanQueryWrapper(
-						sqw, startOffset, length);
-				return ssqw;
-            };
+                    startOffset = spanRef.get(0).asInt(0);
 
-            if (DEBUG) log.trace("Wrap class reference {}", number);
+                    if (DEBUG)
+                        log.trace("Wrap span reference {},{}", startOffset,
+                                length);
 
-            return new SpanFocusQueryWrapper(
-                this.fromJson(operands.get(0)), number
-            );
+                    SpanQueryWrapper sqw = this.fromJson(operands.get(0));
+                    SpanSubspanQueryWrapper ssqw = new SpanSubspanQueryWrapper(
+                            sqw, startOffset, length);
+                    return ssqw;
+                }
+                ;
 
-        case "koral:token":
-            // The token is empty and should be treated like []
-            if (!json.has("wrap"))
-                return new SpanRepetitionQueryWrapper();
+                if (DEBUG)
+                    log.trace("Wrap class reference {}", number);
 
-            // Get wrapped token
-            return this._segFromJson(json.get("wrap"));
+                return new SpanFocusQueryWrapper(
+                        this.fromJson(operands.get(0)), number);
 
-        case "koral:span":
-            return this._termFromJson(json);
+            case "koral:token":
+                // The token is empty and should be treated like []
+                if (!json.has("wrap"))
+                    return new SpanRepetitionQueryWrapper();
+
+                // Get wrapped token
+                return this._segFromJson(json.get("wrap"));
+
+            case "koral:span":
+                return this._termFromJson(json);
         };
 
         // Unknown query type
@@ -292,11 +295,12 @@
      * Get the associated {@link QueryBuilder} object
      * for query building.
      * </p>
-     *
+     * 
      * <blockquote><pre>
-     *   SpanQueryWrapper query = new KrillQuery("tokens").builder().re("mate/p=N.*");
+     * SpanQueryWrapper query = new
+     * KrillQuery("tokens").builder().re("mate/p=N.*");
      * </pre></blockquote>
-     *
+     * 
      * @return The {@link QueryBuilder}.
      */
     public QueryBuilder builder () {
@@ -312,7 +316,7 @@
      * if the object was build using a {@link QueryBuilder},
      * therefore it is limited to mirror a deserialized KoralQuery
      * object.
-     *
+     * 
      * @return The {@link JsonNode} representing the query object
      *         of a deserialized KoralQuery object.
      */
@@ -327,7 +331,7 @@
      * if the object was build using a {@link QueryBuilder},
      * therefore it is limited to mirror a deserialized KoralQuery
      * object.
-     *
+     * 
      * @return A JSON string representing the query object
      *         of a deserialized KoralQuery object.
      */
@@ -339,7 +343,8 @@
 
 
     // Deserialize koral:group
-    private SpanQueryWrapper _groupFromJson (JsonNode json) throws QueryException {
+    private SpanQueryWrapper _groupFromJson (JsonNode json)
+            throws QueryException {
 
         // No operation
         if (!json.has("operation"))
@@ -348,7 +353,8 @@
         // Get operation
         String operation = json.get("operation").asText();
 
-        if (DEBUG) log.trace("Found {} group", operation);
+        if (DEBUG)
+            log.trace("Found {} group", operation);
 
         if (!json.has("operands"))
             throw new QueryException(704, "Operation needs operand list");
@@ -359,34 +365,36 @@
         if (operands == null || !operands.isArray())
             throw new QueryException(704, "Operation needs operand list");
 
-        if (DEBUG) log.trace("Operands are {}", operands);
+        if (DEBUG)
+            log.trace("Operands are {}", operands);
 
         // Branch on operation
         switch (operation) {
-        case "operation:junction":
-            return this._operationJunctionFromJson(operands);
-            
-        case "operation:position":
-            return this._operationPositionFromJson(json, operands);
+            case "operation:junction":
+                return this._operationJunctionFromJson(operands);
 
-        case "operation:sequence":
-            return this._operationSequenceFromJson(json, operands);
+            case "operation:position":
+                return this._operationPositionFromJson(json, operands);
 
-        case "operation:class":
-            return this._operationClassFromJson(json, operands);
+            case "operation:sequence":
+                return this._operationSequenceFromJson(json, operands);
 
-        case "operation:repetition":
-            return this._operationRepetitionFromJson(json, operands);
+            case "operation:class":
+                return this._operationClassFromJson(json, operands);
 
-        case "operation:relation":
-            throw new QueryException(765, "Relations are currently not supported");
+            case "operation:repetition":
+                return this._operationRepetitionFromJson(json, operands);
 
-        case "operation:or": // Deprecated in favor of operation:junction
-            return this._operationJunctionFromJson(operands);
-            /*
-        case "operation:submatch": // Deprecated in favor of koral:reference
-            return this._operationSubmatchFromJson(json, operands);
-            */
+            case "operation:relation":
+                throw new QueryException(765,
+                        "Relations are currently not supported");
+
+            case "operation:or": // Deprecated in favor of operation:junction
+                return this._operationJunctionFromJson(operands);
+                /*
+                case "operation:submatch": // Deprecated in favor of koral:reference
+                return this._operationSubmatchFromJson(json, operands);
+                */
         };
 
         // Unknown
@@ -396,7 +404,7 @@
 
     // Deserialize operation:junction
     private SpanQueryWrapper _operationJunctionFromJson (JsonNode operands)
-        throws QueryException {
+            throws QueryException {
         SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
         for (JsonNode operand : operands) {
             ssaq.or(this.fromJson(operand));
@@ -406,10 +414,11 @@
 
 
     // Deserialize operation:position
-    private SpanQueryWrapper _operationPositionFromJson (JsonNode json, JsonNode operands)
-        throws QueryException {
+    private SpanQueryWrapper _operationPositionFromJson (JsonNode json,
+            JsonNode operands) throws QueryException {
         if (operands.size() != 2)
-            throw new QueryException(705, "Number of operands is not acceptable");
+            throw new QueryException(705,
+                    "Number of operands is not acceptable");
 
         String frame = "isAround";
         // Temporary workaround for wrongly set overlaps
@@ -431,86 +440,77 @@
         };
         // </legacyCode>
 
-        if (DEBUG) log.trace("Position frame is '{}'", frame);
+        if (DEBUG)
+            log.trace("Position frame is '{}'", frame);
 
         // Byte flag - should cover all 13 cases, i.e. two bytes long
         byte flag = WITHIN;
         switch (frame) {
-        case "isAround":
-            break;
-        case "strictlyContains":
-            flag = REAL_WITHIN;
-            break;
-        case "isWithin":
-            break;
-        case "startsWith":
-            flag = STARTSWITH;
-            break;
-        case "endsWith":
-            flag = ENDSWITH;
-            break;
-        case "matches":
-            flag = MATCH;
-            break;
-        case "overlaps":
-            flag = OVERLAP;
-            this.addWarning(
-                769,
-                "Overlap variant currently interpreted as overlap"
-            );
-            break;
-        case "overlapsLeft":
-            // Temporary workaround
-            this.addWarning(
-                769,
-                "Overlap variant currently interpreted as overlap"
-            );
-            flag = OVERLAP;
-            break;
-        case "overlapsRight":
-            // Temporary workaround
-            this.addWarning(
-                769,
-                "Overlap variant currently interpreted as overlap"
-            );
-            flag = OVERLAP;
-            break;
-        case "strictlyOverlaps":
-            flag = REAL_OVERLAP;
-            break;
+            case "isAround":
+                break;
+            case "strictlyContains":
+                flag = REAL_WITHIN;
+                break;
+            case "isWithin":
+                break;
+            case "startsWith":
+                flag = STARTSWITH;
+                break;
+            case "endsWith":
+                flag = ENDSWITH;
+                break;
+            case "matches":
+                flag = MATCH;
+                break;
+            case "overlaps":
+                flag = OVERLAP;
+                this.addWarning(769,
+                        "Overlap variant currently interpreted as overlap");
+                break;
+            case "overlapsLeft":
+                // Temporary workaround
+                this.addWarning(769,
+                        "Overlap variant currently interpreted as overlap");
+                flag = OVERLAP;
+                break;
+            case "overlapsRight":
+                // Temporary workaround
+                this.addWarning(769,
+                        "Overlap variant currently interpreted as overlap");
+                flag = OVERLAP;
+                break;
+            case "strictlyOverlaps":
+                flag = REAL_OVERLAP;
+                break;
 
             // alignsLeft
 
-        default:
-            throw new QueryException(706, "Frame type is unknown");
+            default:
+                throw new QueryException(706, "Frame type is unknown");
         };
-        
+
         // The exclusion operator is no longer relevant
         // <legacyCode>
         Boolean exclude;
         if (json.has("exclude") && json.get("exclude").asBoolean()) {
-            throw new QueryException(
-                760,
-                "Exclusion is currently not supported in position operations"
-            );
+            throw new QueryException(760,
+                    "Exclusion is currently not supported in position operations");
         };
         // </legacyCode>
 
         // Create SpanWithin Query
-        return new SpanWithinQueryWrapper(
-            this.fromJson(operands.get(0)),
-            this.fromJson(operands.get(1)),
-            flag
-        );
+        return new SpanWithinQueryWrapper(this.fromJson(operands.get(0)),
+                this.fromJson(operands.get(1)), flag);
     };
 
 
     // Deserialize operation:repetition
-    private SpanQueryWrapper _operationRepetitionFromJson (JsonNode json, JsonNode operands)
-        throws QueryException {
+    private SpanQueryWrapper _operationRepetitionFromJson (JsonNode json,
+            JsonNode operands) throws QueryException {
 
         if (operands.size() != 1)
-            throw new QueryException(705, "Number of operands is not acceptable");
+            throw new QueryException(705,
+                    "Number of operands is not acceptable");
 
         int min = 0, max = 100;
 
@@ -544,13 +544,13 @@
             min = 0;
         else if (min > 100)
             min = 100;
-                
+
         // Check relation between min and max
         if (min > max)
             max = max;
 
         SpanQueryWrapper sqw = this.fromJson(operands.get(0));
-                
+
         if (sqw.maybeExtension())
             return sqw.setMin(min).setMax(max);
 
@@ -560,23 +560,22 @@
 
     // Deserialize operation:submatch
     @Deprecated
-    private SpanQueryWrapper _operationSubmatchFromJson (JsonNode json, JsonNode operands)
-        throws QueryException {
+    private SpanQueryWrapper _operationSubmatchFromJson (JsonNode json,
+            JsonNode operands) throws QueryException {
 
         int number = 1;
 
         this.addMessage(0, "operation:submatch is deprecated");
 
         if (operands.size() != 1)
-            throw new QueryException(705, "Number of operands is not acceptable");
+            throw new QueryException(705,
+                    "Number of operands is not acceptable");
 
         // Use class reference
         if (json.has("classRef")) {
             if (json.has("classRefOp")) {
-                throw new QueryException(
-                    761,
-                    "Class reference operators are currently not supported"
-                );
+                throw new QueryException(761,
+                        "Class reference operators are currently not supported");
             };
 
             number = json.get("classRef").get(0).asInt();
@@ -584,26 +583,23 @@
 
         // Use span reference
         else if (json.has("spanRef")) {
-            throw new QueryException(
-                762,
-                "Span references are currently not supported"
-            );
-        }; 
+            throw new QueryException(762,
+                    "Span references are currently not supported");
+        };
 
-        return new SpanFocusQueryWrapper(
-            this.fromJson(operands.get(0)), number
-        );
+        return new SpanFocusQueryWrapper(this.fromJson(operands.get(0)), number);
     };
 
 
     // Deserialize operation:class
-    private SpanQueryWrapper _operationClassFromJson (JsonNode json, JsonNode operands)
-        throws QueryException {
+    private SpanQueryWrapper _operationClassFromJson (JsonNode json,
+            JsonNode operands) throws QueryException {
         int number = 1;
 
         // Too many operands
         if (operands.size() != 1)
-            throw new QueryException(705, "Number of operands is not acceptable");
+            throw new QueryException(705,
+                    "Number of operands is not acceptable");
 
         // Get class number
         if (json.has("classOut")) {
@@ -618,46 +614,37 @@
 
         // Class reference check
         if (json.has("classRefCheck")) {
-            this.addWarning(
-                764,
-                "Class reference checks are currently " +
-                "not supported - results may not be correct"
-            );
+            this.addWarning(764, "Class reference checks are currently "
+                    + "not supported - results may not be correct");
         };
 
         // Class reference operation
         // This has to be done after class ref check
         if (json.has("classRefOp")) {
-            throw new QueryException(
-                761,
-                "Class reference operators are currently not supported"
-            );
+            throw new QueryException(761,
+                    "Class reference operators are currently not supported");
         };
 
         // Number is set
         if (number > 0) {
             if (operands.size() != 1) {
-                throw new QueryException(
-                    705,
-                    "Number of operands is not acceptable"
-                );
+                throw new QueryException(705,
+                        "Number of operands is not acceptable");
             };
-            
-            if (DEBUG) log.trace("Found Class definition for {}", number);
+
+            if (DEBUG)
+                log.trace("Found Class definition for {}", number);
 
             if (number > MAX_CLASS_NUM) {
-                throw new QueryException(
-                    709,
-                    "Valid class numbers exceeded"
-                );
+                throw new QueryException(709, "Valid class numbers exceeded");
             };
 
             // Serialize operand
             SpanQueryWrapper sqw = this.fromJson(operands.get(0));
 
             // Problematic
-			if (sqw.maybeExtension())
-			return sqw.setClassNumber(number);
+            if (sqw.maybeExtension())
+                return sqw.setClassNumber(number);
 
             return new SpanClassQueryWrapper(sqw, number);
         };
@@ -667,8 +654,8 @@
 
 
     // Deserialize operation:sequence
-    private SpanQueryWrapper _operationSequenceFromJson (JsonNode json, JsonNode operands)
-        throws QueryException {
+    private SpanQueryWrapper _operationSequenceFromJson (JsonNode json,
+            JsonNode operands) throws QueryException {
 
         // Sequence with only one operand
         if (operands.size() == 1)
@@ -686,43 +673,39 @@
 
             // THIS IS NO LONGER NECESSARY, AS IT IS COVERED BY FRAMES
             if (json.has("exclude") && json.get("exclude").asBoolean()) {
-                throw new QueryException(
-                    763,
-                    "Excluding distance constraints are currently not supported"
-                );
+                throw new QueryException(763,
+                        "Excluding distance constraints are currently not supported");
             };
 
             if (!json.get("distances").isArray()) {
-                throw new QueryException(
-                    707,
-                    "Distance Constraints have to be defined as arrays"
-                );
+                throw new QueryException(707,
+                        "Distance Constraints have to be defined as arrays");
             };
 
             // TEMPORARY: Workaround for group distances
             JsonNode firstDistance = json.get("distances").get(0);
-            
+
             if (!firstDistance.has("@type")) {
-                throw new QueryException(
-                    701,
-                    "JSON-LD group has no @type attribute"
-                );
+                throw new QueryException(701,
+                        "JSON-LD group has no @type attribute");
             };
 
             JsonNode distances;
             if (firstDistance.get("@type").asText().equals("koral:group")) {
-                if (!firstDistance.has("operands") ||
-                    !firstDistance.get("operands").isArray())
-                    throw new QueryException(704, "Operation needs operand list");
+                if (!firstDistance.has("operands")
+                        || !firstDistance.get("operands").isArray())
+                    throw new QueryException(704,
+                            "Operation needs operand list");
 
                 distances = firstDistance.get("operands");
             }
 
             // Support korap distances
             // Support cosmas distances
-            else if (firstDistance.get("@type").asText().equals("koral:distance")
-                     ||
-                     firstDistance.get("@type").asText().equals("cosmas:distance")) {
+            else if (firstDistance.get("@type").asText()
+                    .equals("koral:distance")
+                    || firstDistance.get("@type").asText()
+                            .equals("cosmas:distance")) {
                 distances = json.get("distances");
             }
 
@@ -734,11 +717,12 @@
                 String unit = "w";
                 if (constraint.has("key"))
                     unit = constraint.get("key").asText();
-                
+
                 // There is a maximum of 100 fix
                 int min = 0, max = 100;
                 if (constraint.has("boundary")) {
-                    Boundary b = new Boundary(constraint.get("boundary"), 0,100);
+                    Boundary b = new Boundary(constraint.get("boundary"), 0,
+                            100);
                     min = b.min;
                     max = b.max;
                 }
@@ -748,13 +732,12 @@
                     if (constraint.has("max"))
                         max = constraint.get("max").asInt(100);
                 };
-                        
+
                 // Add foundry and layer to the unit for new indices
-                if (constraint.has("foundry") &&
-                    constraint.has("layer") &&
-                    constraint.get("foundry").asText().length() > 0 &&
-                    constraint.get("layer").asText().length() > 0) {
-                            
+                if (constraint.has("foundry") && constraint.has("layer")
+                        && constraint.get("foundry").asText().length() > 0
+                        && constraint.get("layer").asText().length() > 0) {
+
                     StringBuilder value = new StringBuilder();
                     value.append(constraint.get("foundry").asText());
                     value.append('/');
@@ -762,14 +745,15 @@
                     value.append(':').append(unit);
                     unit = value.toString();
                 };
-                
+
                 // Sanitize boundary
-                if (max < min) max = min;
-                        
+                if (max < min)
+                    max = min;
+
                 if (DEBUG)
-                    log.trace("Add distance constraint of '{}': {}-{}",
-                              unit, min, max);
-                        
+                    log.trace("Add distance constraint of '{}': {}-{}", unit,
+                            min, max);
+
                 sseqqw.withConstraint(min, max, unit);
             };
         };
@@ -791,7 +775,8 @@
     // Deserialize koral:token
     private SpanQueryWrapper _segFromJson (JsonNode json) throws QueryException {
         if (!json.has("@type"))
-            throw new QueryException(701, "JSON-LD group has no @type attribute");
+            throw new QueryException(701,
+                    "JSON-LD group has no @type attribute");
 
         String type = json.get("@type").asText();
 
@@ -800,104 +785,108 @@
 
         // Branch on type
         switch (type) {
-        case "koral:term":
-//            String match = "match:eq";
-//            if (json.has("match"))
-//                match = json.get("match").asText();
-//            
-//            switch (match) {
-//
-//            case "match:ne":
-//                if (DEBUG)
-//                    log.trace("Term is negated");
-//
-//                SpanSegmentQueryWrapper ssqw =
-//                    (SpanSegmentQueryWrapper) this._termFromJson(json);
-//
-//                ssqw.makeNegative();
-//
-//                return this.seg().without(ssqw);
-//
-//            case "match:eq":
+            case "koral:term":
+                //            String match = "match:eq";
+                //            if (json.has("match"))
+                //                match = json.get("match").asText();
+                //            
+                //            switch (match) {
+                //
+                //            case "match:ne":
+                //                if (DEBUG)
+                //                    log.trace("Term is negated");
+                //
+                //                SpanSegmentQueryWrapper ssqw =
+                //                    (SpanSegmentQueryWrapper) this._termFromJson(json);
+                //
+                //                ssqw.makeNegative();
+                //
+                //                return this.seg().without(ssqw);
+                //
+                //            case "match:eq":
                 return this._termFromJson(json);
-//            };
-//
-//            throw new QueryException(741, "Match relation unknown");
+                //            };
+                //
+                //            throw new QueryException(741, "Match relation unknown");
 
-        case "koral:termGroup":
+            case "koral:termGroup":
 
-            if (!json.has("operands"))
-                throw new QueryException(742, "Term group needs operand list");
+                if (!json.has("operands"))
+                    throw new QueryException(742,
+                            "Term group needs operand list");
 
-            // Get operands
-            JsonNode operands = json.get("operands");
+                // Get operands
+                JsonNode operands = json.get("operands");
 
-            SpanSegmentQueryWrapper ssegqw = this.builder().seg();
-            
-            if (!json.has("relation"))
-                throw new QueryException(743, "Term group expects a relation");
+                SpanSegmentQueryWrapper ssegqw = this.builder().seg();
 
-            switch (json.get("relation").asText()) {
-            case "relation:and":
+                if (!json.has("relation"))
+                    throw new QueryException(743,
+                            "Term group expects a relation");
 
-                for (JsonNode operand : operands) {
-                    SpanQueryWrapper part = this._segFromJson(operand);
-                    if (part instanceof SpanAlterQueryWrapper) {
-                        ssegqw.with((SpanAlterQueryWrapper) part);			
-                    }
-                    else if (part instanceof SpanRegexQueryWrapper) {
-                        ssegqw.with((SpanRegexQueryWrapper) part);
-                    }
-                    else if (part instanceof SpanSegmentQueryWrapper) {
-                        ssegqw.with((SpanSegmentQueryWrapper) part);
-                    }
-                    else {
-                        throw new QueryException(
-                            744,
-                            "Operand not supported in term group"
-                        );
-                    };
-                };
-                return ssegqw;
+                switch (json.get("relation").asText()) {
+                    case "relation:and":
 
-            case "relation:or":
+                        for (JsonNode operand : operands) {
+                            SpanQueryWrapper part = this._segFromJson(operand);
+                            if (part instanceof SpanAlterQueryWrapper) {
+                                ssegqw.with((SpanAlterQueryWrapper) part);
+                            }
+                            else if (part instanceof SpanRegexQueryWrapper) {
+                                ssegqw.with((SpanRegexQueryWrapper) part);
+                            }
+                            else if (part instanceof SpanSegmentQueryWrapper) {
+                                ssegqw.with((SpanSegmentQueryWrapper) part);
+                            }
+                            else {
+                                throw new QueryException(744,
+                                        "Operand not supported in term group");
+                            };
+                        }
+                        ;
+                        return ssegqw;
 
-                SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
-                for (JsonNode operand : operands) {
-                    ssaq.or(this._segFromJson(operand));
-                };
-                return ssaq;
-            };
+                    case "relation:or":
+
+                        SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(
+                                this.field);
+                        for (JsonNode operand : operands) {
+                            ssaq.or(this._segFromJson(operand));
+                        }
+                        ;
+                        return ssaq;
+                }
+                ;
         };
-        throw new QueryException(745, "Token type is not supported");    
+        throw new QueryException(745, "Token type is not supported");
     };
 
 
     // Deserialize koral:term
     private SpanQueryWrapper _termFromJson (JsonNode json)
-        throws QueryException {
-    	
+            throws QueryException {
+
         if (!json.has("key") || json.get("key").asText().length() < 1) {
-			if (!json.has("attr"))
-				throw new QueryException(740,
-						"Key definition is missing in term or span");
-        };
-	    
-        if (!json.has("@type")) {
-            throw new QueryException(
-                701,
-                "JSON-LD group has no @type attribute"
-            );
+            if (!json.has("attr"))
+                throw new QueryException(740,
+                        "Key definition is missing in term or span");
         };
 
-        Boolean isTerm = json.get("@type").asText().equals("koral:term") ? true : false;
+        if (!json.has("@type")) {
+            throw new QueryException(701,
+                    "JSON-LD group has no @type attribute");
+        };
+
+        Boolean isTerm = json.get("@type").asText().equals("koral:term") ? true
+                : false;
         Boolean isCaseInsensitive = false;
 
-        if (json.has("caseInsensitive") && json.get("caseInsensitive").asBoolean())
+        if (json.has("caseInsensitive")
+                && json.get("caseInsensitive").asBoolean())
             isCaseInsensitive = true;
 
         StringBuilder value = new StringBuilder();
-        
+
         // expect orth? expect lemma? 
         // s:den | i:den | cnx/l:die | mate/m:mood:ind | cnx/syn:@PREMOD |
         // mate/m:number:sg | opennlp/p:ART
@@ -910,36 +899,34 @@
             String layer = json.get("layer").asText();
             switch (layer) {
 
-            case "lemma":
-                layer = "l";
-                break;
+                case "lemma":
+                    layer = "l";
+                    break;
 
-            case "pos":
-                layer = "p";
-                break;
+                case "pos":
+                    layer = "p";
+                    break;
 
-            case "orth":
-                // TODO: THIS IS A BUG! AND SHOULD BE NAMED "SURFACE" or .
-                layer = "s";
-                break;
+                case "orth":
+                    // TODO: THIS IS A BUG! AND SHOULD BE NAMED "SURFACE" or .
+                    layer = "s";
+                    break;
 
-            case "struct":
-                layer = "s";
-                break;
+                case "struct":
+                    layer = "s";
+                    break;
 
-            case "const":
-                layer = "c";
-                break;
+                case "const":
+                    layer = "c";
+                    break;
             };
 
             if (isCaseInsensitive && isTerm) {
                 if (layer.equals("s"))
                     layer = "i";
                 else {
-                    this.addWarning(
-                        767,
-                        "Case insensitivity is currently not supported for this layer"
-                    );
+                    this.addWarning(767,
+                            "Case insensitivity is currently not supported for this layer");
                 };
             };
 
@@ -965,174 +952,176 @@
 
             // Branch on type
             switch (json.get("type").asText()) {
-            case "type:regex":
-                return qb.seg(qb.re(value.toString(), isCaseInsensitive));
+                case "type:regex":
+                    return qb.seg(qb.re(value.toString(), isCaseInsensitive));
 
-            case "type:wildcard":
-                return qb.seq(qb.wc(value.toString(), isCaseInsensitive));
+                case "type:wildcard":
+                    return qb.seq(qb.wc(value.toString(), isCaseInsensitive));
 
-            case "type:string":
-                break;
+                case "type:string":
+                    break;
 
-            default:
-                this.addWarning(746, "Term type is not supported - treated as a string");
+                default:
+                    this.addWarning(746,
+                            "Term type is not supported - treated as a string");
             };
         };
 
-        if (isTerm){
+        if (isTerm) {
 
-        	String match = "match:eq";
-			if (json.has("match")) {
-				match = json.get("match").asText();
-			}
+            String match = "match:eq";
+            if (json.has("match")) {
+                match = json.get("match").asText();
+            }
 
-			SpanSegmentQueryWrapper ssqw = this.builder().seg(value.toString());			
-			if (match.equals("match:ne")) {
-				if (DEBUG) log.trace("Term is negated");
-				ssqw.makeNegative();
-				return this.builder().seg().without(ssqw);
-			} 
-			else if (match.equals("match:eq")) {
-				return ssqw;
-			} 
-			else {
-				throw new QueryException(741, "Match relation unknown");
-			}
+            SpanSegmentQueryWrapper ssqw = this.builder().seg(value.toString());
+            if (match.equals("match:ne")) {
+                if (DEBUG)
+                    log.trace("Term is negated");
+                ssqw.makeNegative();
+                return this.builder().seg().without(ssqw);
+            }
+            else if (match.equals("match:eq")) {
+                return ssqw;
+            }
+            else {
+                throw new QueryException(741, "Match relation unknown");
+            }
         }
 
         if (json.has("attr")) {
-			JsonNode attrNode = json.get("attr");
-			if (!attrNode.has("@type")) {
-				throw new QueryException(701,
-						"JSON-LD group has no @type attribute");
-			}
+            JsonNode attrNode = json.get("attr");
+            if (!attrNode.has("@type")) {
+                throw new QueryException(701,
+                        "JSON-LD group has no @type attribute");
+            }
 
-			if (value.toString().isEmpty()) {
-				return _createElementAttrFromJson(null, json, attrNode);
-				// this.addWarning(771,
-				// "Arbitraty elements with attributes are currently not supported.");
-			}
-			else{
-				SpanQueryWrapper elementWithIdWrapper = this.builder().tag(value.toString());
-				if (elementWithIdWrapper == null){ return null; }
-				return _createElementAttrFromJson(elementWithIdWrapper, json,
-						attrNode);
-			}
+            if (value.toString().isEmpty()) {
+                return _createElementAttrFromJson(null, json, attrNode);
+                // this.addWarning(771,
+                // "Arbitraty elements with attributes are currently not supported.");
+            }
+            else {
+                SpanQueryWrapper elementWithIdWrapper = this.builder().tag(
+                        value.toString());
+                if (elementWithIdWrapper == null) {
+                    return null;
+                }
+                return _createElementAttrFromJson(elementWithIdWrapper, json,
+                        attrNode);
+            }
         };
         return this.builder().tag(value.toString());
     };
 
 
     // Deserialize elements with attributes
-	private SpanQueryWrapper _createElementAttrFromJson (
-                SpanQueryWrapper elementWithIdWrapper,
-                JsonNode json,
-                JsonNode attrNode) throws QueryException {
+    private SpanQueryWrapper _createElementAttrFromJson (
+            SpanQueryWrapper elementWithIdWrapper, JsonNode json,
+            JsonNode attrNode) throws QueryException {
 
-		if (attrNode.get("@type").asText().equals("koral:term")) {
-			SpanQueryWrapper attrWrapper = _attrFromJson(json.get("attr"));
-			if (attrWrapper != null) {
-				if (elementWithIdWrapper != null){
-					return new SpanWithAttributeQueryWrapper(elementWithIdWrapper,
-                                                             attrWrapper);
-				}
-				else {
-					return new SpanWithAttributeQueryWrapper(attrWrapper);
-				}
-			} 
-			else {
-				throw new QueryException(747, "Attribute is null");
-			}
-		} 
+        if (attrNode.get("@type").asText().equals("koral:term")) {
+            SpanQueryWrapper attrWrapper = _attrFromJson(json.get("attr"));
+            if (attrWrapper != null) {
+                if (elementWithIdWrapper != null) {
+                    return new SpanWithAttributeQueryWrapper(
+                            elementWithIdWrapper, attrWrapper);
+                }
+                else {
+                    return new SpanWithAttributeQueryWrapper(attrWrapper);
+                }
+            }
+            else {
+                throw new QueryException(747, "Attribute is null");
+            }
+        }
         else if (attrNode.get("@type").asText().equals("koral:termGroup")) {
-			return _handleAttrGroup(elementWithIdWrapper, attrNode);
-		}
-		else {
-			this.addWarning(715, "Attribute type is not supported");
-		}
-		return elementWithIdWrapper;
-	}
+            return _handleAttrGroup(elementWithIdWrapper, attrNode);
+        }
+        else {
+            this.addWarning(715, "Attribute type is not supported");
+        }
+        return elementWithIdWrapper;
+    }
 
 
     // Deserialize attribute groups
-	private SpanQueryWrapper _handleAttrGroup (
-                SpanQueryWrapper elementWithIdWrapper,
-                JsonNode attrNode) throws QueryException {
-		if (!attrNode.has("relation")) {
-			throw new QueryException(743, "Term group expects a relation");
-		}
-		if (!attrNode.has("operands")) {
-			throw new QueryException(742, "Term group needs operand list");
-		}
+    private SpanQueryWrapper _handleAttrGroup (
+            SpanQueryWrapper elementWithIdWrapper, JsonNode attrNode)
+            throws QueryException {
+        if (!attrNode.has("relation")) {
+            throw new QueryException(743, "Term group expects a relation");
+        }
+        if (!attrNode.has("operands")) {
+            throw new QueryException(742, "Term group needs operand list");
+        }
 
-		String relation = attrNode.get("relation").asText();
-		JsonNode operands = attrNode.get("operands");
+        String relation = attrNode.get("relation").asText();
+        JsonNode operands = attrNode.get("operands");
 
-		SpanQueryWrapper attrWrapper;
-		if ("relation:and".equals(relation)) {
-			List<SpanQueryWrapper> wrapperList = new ArrayList<SpanQueryWrapper>();
-			for (JsonNode operand : operands) {
-				attrWrapper = _termFromJson(operand);
-				if (attrWrapper == null) {
-					throw new QueryException(747, "Attribute is null");
-				}
-				wrapperList.add(attrWrapper);
-			}
+        SpanQueryWrapper attrWrapper;
+        if ("relation:and".equals(relation)) {
+            List<SpanQueryWrapper> wrapperList = new ArrayList<SpanQueryWrapper>();
+            for (JsonNode operand : operands) {
+                attrWrapper = _termFromJson(operand);
+                if (attrWrapper == null) {
+                    throw new QueryException(747, "Attribute is null");
+                }
+                wrapperList.add(attrWrapper);
+            }
 
-			if (elementWithIdWrapper != null){
-				return new SpanWithAttributeQueryWrapper(elementWithIdWrapper,
-                                                         wrapperList);
-			}
-			else {
-				return new SpanWithAttributeQueryWrapper(wrapperList);
-			}
-		} 
-		else if ("relation:or".equals(relation)) {
-			SpanAlterQueryWrapper saq = new SpanAlterQueryWrapper(field);
-			SpanWithAttributeQueryWrapper saqw;
-			for (JsonNode operand : operands) {
-				attrWrapper = _termFromJson(operand);
-				if (attrWrapper == null) {
-					throw new QueryException(747, "Attribute is null");
-				}
-				if (elementWithIdWrapper != null) {
-					saqw = new SpanWithAttributeQueryWrapper(
-                        elementWithIdWrapper,
-                        attrWrapper
-                    );
-				} else {
-					saqw = new SpanWithAttributeQueryWrapper(attrWrapper);
-				}
-				saq.or(saqw);
-			}
-			return saq;
-		}
-		else {
-			throw new QueryException(716, "Unknown relation");
-		}
-	}
+            if (elementWithIdWrapper != null) {
+                return new SpanWithAttributeQueryWrapper(elementWithIdWrapper,
+                        wrapperList);
+            }
+            else {
+                return new SpanWithAttributeQueryWrapper(wrapperList);
+            }
+        }
+        else if ("relation:or".equals(relation)) {
+            SpanAlterQueryWrapper saq = new SpanAlterQueryWrapper(field);
+            SpanWithAttributeQueryWrapper saqw;
+            for (JsonNode operand : operands) {
+                attrWrapper = _termFromJson(operand);
+                if (attrWrapper == null) {
+                    throw new QueryException(747, "Attribute is null");
+                }
+                if (elementWithIdWrapper != null) {
+                    saqw = new SpanWithAttributeQueryWrapper(
+                            elementWithIdWrapper, attrWrapper);
+                }
+                else {
+                    saqw = new SpanWithAttributeQueryWrapper(attrWrapper);
+                }
+                saq.or(saqw);
+            }
+            return saq;
+        }
+        else {
+            throw new QueryException(716, "Unknown relation");
+        }
+    }
+
 
     // Get attributes from a json termgroup
     private SpanQueryWrapper _attrFromJson (JsonNode attrNode)
-        throws QueryException {
+            throws QueryException {
 
-		if (attrNode.has("key")) {
-			return _termFromJson(attrNode);
-		} 
-		else if (attrNode.has("tokenarity") || attrNode.has("arity")) {
-			this.addWarning(770, "Arity attributes are currently not supported"
-					+ " - results may not be correct"
-            );
-		} 
-		else if (attrNode.has("root")) {
-			String rootValue = attrNode.get("root").asText();
-			if (rootValue.equals("true") || rootValue.equals("false")) {
-				return new SpanAttributeQueryWrapper(
-						new SpanSimpleQueryWrapper("tokens", "@root",
-								Boolean.valueOf(rootValue))
-                );
+        if (attrNode.has("key")) {
+            return _termFromJson(attrNode);
+        }
+        else if (attrNode.has("tokenarity") || attrNode.has("arity")) {
+            this.addWarning(770, "Arity attributes are currently not supported"
+                    + " - results may not be correct");
+        }
+        else if (attrNode.has("root")) {
+            String rootValue = attrNode.get("root").asText();
+            if (rootValue.equals("true") || rootValue.equals("false")) {
+                return new SpanAttributeQueryWrapper(
+                        new SpanSimpleQueryWrapper("tokens", "@root",
+                                Boolean.valueOf(rootValue)));
             }
         }
-		return null;
+        return null;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/collection/BooleanFilter.java b/src/main/java/de/ids_mannheim/korap/collection/BooleanFilter.java
index 7393a01..2f6853d 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/BooleanFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/BooleanFilter.java
@@ -26,15 +26,17 @@
 
 /**
  * @author Nils Diewald
- *
- * BooleanFilter implements a simple API for boolean operations
- * on constraints for KorapFilter.
+ * 
+ *         BooleanFilter implements a simple API for boolean
+ *         operations
+ *         on constraints for KorapFilter.
  */
 public class BooleanFilter {
     private String type;
 
     // Logger
-    private final static Logger log = LoggerFactory.getLogger(KrillCollection.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(KrillCollection.class);
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
@@ -42,195 +44,160 @@
     private BooleanQuery bool;
     private String error;
 
+
     public BooleanFilter () {
-	bool = new BooleanQuery();
+        bool = new BooleanQuery();
     };
 
+
     public BooleanFilter or (String type, String ... terms) {
-	for (String term : terms) {
+        for (String term : terms) {
 
-	    if (DEBUG)
-		log.trace("Filter: OR {}={}", type, term);
+            if (DEBUG)
+                log.trace("Filter: OR {}={}", type, term);
 
-	    bool.add(
-	        new TermQuery(new Term(type, term)),
-		BooleanClause.Occur.SHOULD
-	    );
-	};
-	return this;
+            bool.add(new TermQuery(new Term(type, term)),
+                    BooleanClause.Occur.SHOULD);
+        };
+        return this;
     };
 
+
     public BooleanFilter or (String type, RegexFilter value) {
-	bool.add(
-          value.toQuery(type),
-          BooleanClause.Occur.SHOULD
-        );
-	return this;
+        bool.add(value.toQuery(type), BooleanClause.Occur.SHOULD);
+        return this;
     };
 
+
     public BooleanFilter or (BooleanFilter bf) {
-	if (bf.bool.clauses().size() == 1) {
-	    BooleanClause bc = bf.bool.getClauses()[0];
-	    bc.setOccur(BooleanClause.Occur.SHOULD);
-	    bool.add(bc);
-	    return this;
-	}
-	bool.add(
- 	    bf.toQuery(),
-	    BooleanClause.Occur.SHOULD
-        );
-	return this;
+        if (bf.bool.clauses().size() == 1) {
+            BooleanClause bc = bf.bool.getClauses()[0];
+            bc.setOccur(BooleanClause.Occur.SHOULD);
+            bool.add(bc);
+            return this;
+        }
+        bool.add(bf.toQuery(), BooleanClause.Occur.SHOULD);
+        return this;
     };
 
+
     public BooleanFilter or (NumericRangeQuery<Integer> nrq) {
-	bool.add(nrq, BooleanClause.Occur.SHOULD);
-	return this;
+        bool.add(nrq, BooleanClause.Occur.SHOULD);
+        return this;
     };
 
+
     public BooleanFilter and (String type, String ... terms) {
-	for (String term : terms) {
-	    bool.add(
-	        new TermQuery(new Term(type, term)),
-		BooleanClause.Occur.MUST
-	    );
-	};
-	return this;
+        for (String term : terms) {
+            bool.add(new TermQuery(new Term(type, term)),
+                    BooleanClause.Occur.MUST);
+        };
+        return this;
     };
 
+
     public BooleanFilter and (String type, RegexFilter value) {
-	bool.add(
-          value.toQuery(type),
-          BooleanClause.Occur.MUST
-        );
-	return this;
+        bool.add(value.toQuery(type), BooleanClause.Occur.MUST);
+        return this;
     };
 
+
     public BooleanFilter and (BooleanFilter bf) {
-	if (bf.bool.clauses().size() == 1) {
-	    BooleanClause bc = bf.bool.getClauses()[0];
-	    bc.setOccur(BooleanClause.Occur.MUST);
-	    bool.add(bc);
-	    return this;
-	}
-	bool.add(
- 	    bf.toQuery(),
-	    BooleanClause.Occur.MUST
-        );
-	return this;
+        if (bf.bool.clauses().size() == 1) {
+            BooleanClause bc = bf.bool.getClauses()[0];
+            bc.setOccur(BooleanClause.Occur.MUST);
+            bool.add(bc);
+            return this;
+        }
+        bool.add(bf.toQuery(), BooleanClause.Occur.MUST);
+        return this;
     };
 
+
     public BooleanFilter since (String dateStr) {
-	int since = new KrillDate(dateStr).floor();
+        int since = new KrillDate(dateStr).floor();
 
-	if (since == 0 || since == KrillDate.BEGINNING)
-	    return this;
+        if (since == 0 || since == KrillDate.BEGINNING)
+            return this;
 
-	bool.add(
-	    NumericRangeQuery.newIntRange(
-	        "pubDate",
-		since,
-		KrillDate.END,
-		true,
-		true
-	    ),
-	    BooleanClause.Occur.MUST
-	);
+        bool.add(NumericRangeQuery.newIntRange("pubDate", since, KrillDate.END,
+                true, true), BooleanClause.Occur.MUST);
 
-	return this;
+        return this;
     };
 
 
     public BooleanFilter till (String dateStr) {
-	try {
-	    int till =  new KrillDate(dateStr).ceil();
-	    if (till == 0 || till == KrillDate.END)
-		return this;
+        try {
+            int till = new KrillDate(dateStr).ceil();
+            if (till == 0 || till == KrillDate.END)
+                return this;
 
-	    bool.add(
-                NumericRangeQuery.newIntRange(
-  	            "pubDate",
-                    KrillDate.BEGINNING,
-                    till,
-                    true,
-                    true
-                ),
-	        BooleanClause.Occur.MUST
-	    );
-	}
-	catch (NumberFormatException e) {
-	    log.warn("Parameter of till(date) is invalid");
-	};
-	return this;
+            bool.add(NumericRangeQuery.newIntRange("pubDate",
+                    KrillDate.BEGINNING, till, true, true),
+                    BooleanClause.Occur.MUST);
+        }
+        catch (NumberFormatException e) {
+            log.warn("Parameter of till(date) is invalid");
+        };
+        return this;
     };
 
 
     public BooleanFilter between (String beginStr, String endStr) {
-	KrillDate beginDF = new KrillDate(beginStr);
+        KrillDate beginDF = new KrillDate(beginStr);
 
-	int begin = beginDF.floor();
+        int begin = beginDF.floor();
 
-	int end = new KrillDate(endStr).ceil();
+        int end = new KrillDate(endStr).ceil();
 
-	if (end == 0)
-	    return this;
+        if (end == 0)
+            return this;
 
-	if (begin == KrillDate.BEGINNING && end == KrillDate.END)
-	    return this;
+        if (begin == KrillDate.BEGINNING && end == KrillDate.END)
+            return this;
 
-	if (begin == end) {
-	    this.and("pubDate", beginDF.toString());
-	    return this;
-	};
+        if (begin == end) {
+            this.and("pubDate", beginDF.toString());
+            return this;
+        };
 
-	this.bool.add(
-	    NumericRangeQuery.newIntRange(
-	        "pubDate",
-		begin,
-		end,
-		true,
-		true
-	    ),
-	    BooleanClause.Occur.MUST
-        );
-	return this;
+        this.bool.add(NumericRangeQuery.newIntRange("pubDate", begin, end,
+                true, true), BooleanClause.Occur.MUST);
+        return this;
     };
 
 
     public BooleanFilter date (String dateStr) {
-	KrillDate dateDF = new KrillDate(dateStr);
+        KrillDate dateDF = new KrillDate(dateStr);
 
-	if (dateDF.year == 0)
-	    return this;
+        if (dateDF.year == 0)
+            return this;
 
-	if (dateDF.day == 0 || dateDF.month == 0) {
-	    int begin = dateDF.floor();
-	    int end = dateDF.ceil();
+        if (dateDF.day == 0 || dateDF.month == 0) {
+            int begin = dateDF.floor();
+            int end = dateDF.ceil();
 
-	    if (end == 0 || (begin == KrillDate.BEGINNING && end == KrillDate.END))
-		return this;
-	    
-	    this.bool.add(
-	        NumericRangeQuery.newIntRange(
-		    "pubDate",
-		    begin,
-		    end,
-		    true,
-		    true
-		),
-		BooleanClause.Occur.MUST
-	    );
-	    return this;
-	};
-	
-	this.and("pubDate", dateDF.toString());
-	return this;
+            if (end == 0
+                    || (begin == KrillDate.BEGINNING && end == KrillDate.END))
+                return this;
+
+            this.bool.add(NumericRangeQuery.newIntRange("pubDate", begin, end,
+                    true, true), BooleanClause.Occur.MUST);
+            return this;
+        };
+
+        this.and("pubDate", dateDF.toString());
+        return this;
     };
 
+
     public Query toQuery () {
-	return this.bool;
+        return this.bool;
     };
 
+
     public String toString () {
-	return this.bool.toString();
+        return this.bool.toString();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java b/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
index bc5158c..809165f 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/CollectionBuilder.java
@@ -16,9 +16,9 @@
 /**
  * CollectionBuilder implements a simple API for creating queries
  * constituing Virtual Collections.
- *
+ * 
  * <strong>Warning</strong>: The API is likely to change.
- *
+ * 
  * @author diewald
  */
 /*
@@ -31,13 +31,12 @@
     private String field = "tokens";
 
     // Logger
-    private final static Logger log = LoggerFactory.getLogger(
-        CollectionBuilder.class
-    );
+    private final static Logger log = LoggerFactory
+            .getLogger(CollectionBuilder.class);
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
-    
+
 
     /**
      * Construct a new CollectionBuilder object.
@@ -45,71 +44,84 @@
     public CollectionBuilder () {
         filter = new BooleanFilter();
     };
-    
+
+
     public BooleanFilter and (String type, String ... terms) {
         BooleanFilter bf = new BooleanFilter();
         bf.and(type, terms);
         return bf;
     };
 
+
     public BooleanFilter or (String type, String ... terms) {
         BooleanFilter bf = new BooleanFilter();
         bf.or(type, terms);
         return bf;
     };
 
+
     public BooleanFilter and (String type, RegexFilter re) {
         BooleanFilter bf = new BooleanFilter();
         bf.and(type, re);
         return bf;
     };
 
+
     public BooleanFilter or (String type, RegexFilter re) {
         BooleanFilter bf = new BooleanFilter();
         bf.or(type, re);
         return bf;
     };
 
+
     public BooleanFilter since (String date) {
         BooleanFilter bf = new BooleanFilter();
         bf.since(date);
         return bf;
     };
 
+
     public BooleanFilter till (String date) {
         BooleanFilter bf = new BooleanFilter();
         bf.till(date);
         return bf;
     };
 
+
     public BooleanFilter date (String date) {
         BooleanFilter bf = new BooleanFilter();
         bf.date(date);
         return bf;
     };
 
+
     public BooleanFilter between (String date1, String date2) {
         BooleanFilter bf = new BooleanFilter();
         bf.between(date1, date2);
         return bf;
     };
 
+
     public RegexFilter re (String regex) {
         return new RegexFilter(regex);
     };
 
-    public BooleanFilter getBooleanFilter ()  {
+
+    public BooleanFilter getBooleanFilter () {
         return this.filter;
     };
 
+
     public void setBooleanFilter (BooleanFilter bf) {
         this.filter = bf;
     };
 
+
     public Query toQuery () {
         return this.filter.toQuery();
     };
 
+
     public String toString () {
         return this.filter.toQuery().toString();
     };
diff --git a/src/main/java/de/ids_mannheim/korap/collection/FilterOperation.java b/src/main/java/de/ids_mannheim/korap/collection/FilterOperation.java
index 8f8b07b..5d3be07 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/FilterOperation.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/FilterOperation.java
@@ -5,35 +5,40 @@
 public class FilterOperation {
     private boolean extension;
     public Filter filter;
-    
+
+
     public FilterOperation (Filter filter, boolean extension) {
-	this.extension = extension;
-	this.filter = filter;
+        this.extension = extension;
+        this.filter = filter;
     };
 
+
     public boolean isExtension () {
-	return this.extension;
+        return this.extension;
     };
 
+
     public boolean isFilter () {
-	return !(this.extension);
+        return !(this.extension);
     };
 
+
     @Override
     public Object clone () throws CloneNotSupportedException {
-	return (Object) new FilterOperation(this.filter, this.extension);
+        return (Object) new FilterOperation(this.filter, this.extension);
     };
 
+
     @Override
     public String toString () {
-	StringBuilder sb = new StringBuilder();
-	if (this.extension) {
-	    sb.append("extend with ");
-	}
-	else {
-	    sb.append("filter with ");
-	};
-	sb.append(this.filter.toString());
-	return sb.toString();
-    };	
+        StringBuilder sb = new StringBuilder();
+        if (this.extension) {
+            sb.append("extend with ");
+        }
+        else {
+            sb.append("filter with ");
+        };
+        sb.append(this.filter.toString());
+        return sb.toString();
+    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/collection/RegexFilter.java b/src/main/java/de/ids_mannheim/korap/collection/RegexFilter.java
index d86270e..f9d881c 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/RegexFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/RegexFilter.java
@@ -7,22 +7,22 @@
 
 /**
  * @author Nils Diewald
- *
- * RegexFilter implements a helper object for
- * regular expressions used in KorapFilter
- * constraints.
+ * 
+ *         RegexFilter implements a helper object for
+ *         regular expressions used in KorapFilter
+ *         constraints.
  */
 
 public class RegexFilter {
     String regex;
 
+
     public RegexFilter (String regex) {
         this.regex = regex;
     };
 
+
     public RegexpQuery toQuery (String field) {
-        return new RegexpQuery(
-            new Term(field, this.regex)
-        );
+        return new RegexpQuery(new Term(field, this.regex));
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
index f0e9ddc..c140d1e 100644
--- a/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/AbstractDocument.java
@@ -16,12 +16,12 @@
 /**
  * Abstract class representing a document in the
  * Krill index.
- *
+ * 
  * This model is rather specific to DeReKo data and
  * should be considered experimental. It may be replaced
  * by a more agnostic model.
  * string fields, e.g. may be combined with a prefix.
- *
+ * 
  * @author diewald
  */
 @JsonIgnoreProperties(ignoreUnknown = true)
@@ -29,53 +29,47 @@
     private String primaryData;
 
     @JsonIgnore
-    public int
-        internalDocID,
-        localDocID,
-        UID;
+    public int internalDocID, localDocID, UID;
 
-    private KrillDate
-        pubDate,
-        // newly added
-        creationDate;
+    private KrillDate pubDate,
+    // newly added
+            creationDate;
 
     private String
 
-        // No longer supported
-        ID,
-        corpusID,
-        field,
-        layerInfo,
-        tokenization,
+    // No longer supported
+            ID,
+            corpusID,
+            field,
+            layerInfo,
+            tokenization,
 
-        // Still supported
-        foundries,
-        textClass,
-        pubPlace,
+            // Still supported
+            foundries,
+            textClass,
+            pubPlace,
 
-        // Newly added for the corpus/doc/text distinction of DeReKo
-        textSigle, docSigle, corpusSigle,
-        title,       subTitle,       author,       editor,
-        docTitle,    docSubTitle,    docAuthor,    docEditor,
-        corpusTitle, corpusSubTitle, corpusAuthor, corpusEditor,
-        textType, textTypeArt, textTypeRef, textColumn, textDomain,
-        fileEditionStatement, biblEditionStatement,
-        publisher,
-        reference,
-        language,
-        license,
-        pages,
-        keywords,
+            // Newly added for the corpus/doc/text distinction of DeReKo
+            textSigle, docSigle, corpusSigle, title, subTitle, author,
+            editor,
+            docTitle, docSubTitle, docAuthor, docEditor,
+            corpusTitle,
+            corpusSubTitle, corpusAuthor, corpusEditor, textType,
+            textTypeArt,
+            textTypeRef, textColumn, textDomain,
+            fileEditionStatement,
+            biblEditionStatement, publisher, reference, language,
+            license,
+            pages, keywords,
 
-        // Meta information regarding annotations
-        tokenSource,
-        layerInfos;
+            // Meta information regarding annotations
+            tokenSource, layerInfos;
 
 
     /**
      * Get the publication date of the document
      * as a {@link KrillDate} object.
-     *
+     * 
      * @return A {@link KrillDate} object for chaining.
      */
     @JsonIgnore
@@ -87,9 +81,9 @@
     /**
      * Get the publication date of the document
      * as a string.
-     *
+     * 
      * @return A string containing the {@link KrillDate}.
-     */    
+     */
     @JsonProperty("pubDate")
     public String getPubDateString () {
         if (this.pubDate != null)
@@ -100,9 +94,10 @@
 
     /**
      * Set the publication date of the document.
-     *
-     * @param date The date as a {@link KrillDate}
-     * compatible string representation.
+     * 
+     * @param date
+     *            The date as a {@link KrillDate} compatible string
+     *            representation.
      * @return A {@link KrillDate} object for chaining.
      */
     public KrillDate setPubDate (String date) {
@@ -113,8 +108,9 @@
 
     /**
      * Set the publication date of the document.
-     *
-     * @param date The date as a {@link KrillDate} object.
+     * 
+     * @param date
+     *            The date as a {@link KrillDate} object.
      * @return A {@link KrillDate} object for chaining.
      */
     public KrillDate setPubDate (KrillDate date) {
@@ -125,7 +121,7 @@
     /**
      * Get the creation date of the document
      * as a {@link KrillDate} object.
-     *
+     * 
      * @return A {@link KrillDate} object for chaining.
      */
     @JsonIgnore
@@ -137,7 +133,7 @@
     /**
      * Get the creation date of the document
      * as a string.
-     *
+     * 
      * @return A string containing the {@link KrillDate}.
      */
     @JsonProperty("creationDate")
@@ -150,9 +146,10 @@
 
     /**
      * Set the creation date of the document.
-     *
-     * @param date The date as a {@link KrillDate}
-     * compatible string representation.
+     * 
+     * @param date
+     *            The date as a {@link KrillDate} compatible string
+     *            representation.
      * @return A {@link KrillDate} object for chaining.
      */
     public KrillDate setCreationDate (String date) {
@@ -163,38 +160,40 @@
 
     /**
      * Set the creation date of the document.
-     *
-     * @param date The date as a {@link KrillDate} object.
+     * 
+     * @param date
+     *            The date as a {@link KrillDate} object.
      * @return A {@link KrillDate} object for chaining.
      */
     public KrillDate setCreationDate (KrillDate date) {
         return (this.creationDate = date);
-    };    
+    };
 
 
     /**
      * Get the name of the author of the document.
-     *
+     * 
      * @return The name of the author as a string.
      */
     public String getAuthor () {
         return this.author;
     };
-        
+
 
     /**
      * Set the name of the author of the document.
-     *
-     * @param author The name of the author as a string.
+     * 
+     * @param author
+     *            The name of the author as a string.
      */
     public void setAuthor (String author) {
         this.author = author;
     };
-    
+
 
     /**
      * Get the text class of the document.
-     *
+     * 
      * @return The text class of the document as a string.
      */
     public String getTextClass () {
@@ -204,8 +203,9 @@
 
     /**
      * Set the text class of the document.
-     *
-     * @param textClass The text class of the document as a string.
+     * 
+     * @param textClass
+     *            The text class of the document as a string.
      */
     public void setTextClass (String textClass) {
         this.textClass = textClass;
@@ -214,39 +214,41 @@
 
     /**
      * Get the publication place of the document.
-     *
+     * 
      * @return The publication place of the document as a string.
      */
     public String getPubPlace () {
         return this.pubPlace;
     };
-    
-    
+
+
     /**
      * Set the publication place of the document.
-     *
-     * @param pubPlace The publication place of the document as a string.
+     * 
+     * @param pubPlace
+     *            The publication place of the document as a string.
      */
     public void setPubPlace (String pubPlace) {
         this.pubPlace = pubPlace;
-    };    
+    };
 
 
     /**
      * Get the unique identifier of the document.
-     *
+     * 
      * @return The unique identifier of the document as an integer.
      */
     @JsonProperty("UID")
     public int getUID () {
         return this.UID;
     };
-    
+
 
     /**
      * Set the unique identifier of the document.
-     *
-     * @param UID The unique identifier of the document as an integer.
+     * 
+     * @param UID
+     *            The unique identifier of the document as an integer.
      * @return The invocant for chaining.
      */
     public void setUID (int UID) {
@@ -256,9 +258,10 @@
 
     /**
      * Set the unique identifier of the document.
-     *
-     * @param UID The unique identifier of the document as a
-     *        string representing an integer.
+     * 
+     * @param UID
+     *            The unique identifier of the document as a
+     *            string representing an integer.
      * @return The invocant for chaining.
      * @throws NumberFormatException
      */
@@ -270,7 +273,7 @@
 
     /**
      * Get the title of the document.
-     *
+     * 
      * @return The title of the document as a string.
      */
     public String getTitle () {
@@ -280,17 +283,18 @@
 
     /**
      * Set the title of the document.
-     *
-     * @param title The title of the document as a string.
+     * 
+     * @param title
+     *            The title of the document as a string.
      */
     public void setTitle (String title) {
         this.title = title;
     };
-    
-        
+
+
     /**
      * Get the subtitle of the document.
-     *
+     * 
      * @return The subtitle of the document as a string.
      */
     public String getSubTitle () {
@@ -300,8 +304,9 @@
 
     /**
      * Set the subtitle of the document.
-     *
-     * @param subTitle The subtitle of the document as a string.
+     * 
+     * @param subTitle
+     *            The subtitle of the document as a string.
      */
     public void setSubTitle (String subTitle) {
         this.subTitle = subTitle;
@@ -310,7 +315,7 @@
 
     /**
      * Get the primary data of the document.
-     *
+     * 
      * @return The primary data of the document as a string.
      */
     public String getPrimaryData () {
@@ -323,9 +328,11 @@
     /**
      * Get the primary data of the document,
      * starting with a given character offset.
-     *
-     * @param startOffset The starting character offset.
-     * @return The substring of primary data of the document as a string.
+     * 
+     * @param startOffset
+     *            The starting character offset.
+     * @return The substring of primary data of the document as a
+     *         string.
      */
     public String getPrimaryData (int startOffset) {
         return this.primaryData.substring(startOffset);
@@ -336,10 +343,13 @@
      * Get the primary data of the document,
      * starting with a given character offset and ending
      * with a given character offset.
-     *
-     * @param startOffset The starting character offset.
-     * @param endOffset The ending character offset.
-     * @return The substring of the primary data of the document as a string.
+     * 
+     * @param startOffset
+     *            The starting character offset.
+     * @param endOffset
+     *            The ending character offset.
+     * @return The substring of the primary data of the document as a
+     *         string.
      */
     public String getPrimaryData (int startOffset, int endOffset) {
         return this.primaryData.substring(startOffset, endOffset);
@@ -348,19 +358,22 @@
 
     /**
      * Set the primary data of the document.
-     *
-     * @param primary The primary data of the document
-     *        as a string.
+     * 
+     * @param primary
+     *            The primary data of the document
+     *            as a string.
      */
     public void setPrimaryData (String primary) {
         this.primaryData = primary;
     };
 
+
     /**
      * Get the length of the primary data of the document
      * (i.e. the number of characters).
-     *
-     * @return The length of the primary data of the document as an integer.
+     * 
+     * @return The length of the primary data of the document as an
+     *         integer.
      */
     @JsonIgnore
     public int getPrimaryDataLength () {
@@ -370,8 +383,8 @@
 
     /**
      * Get information on the foundries the document
-     * is annotated with as a string. 
-     *
+     * is annotated with as a string.
+     * 
      * @return The foundry information string.
      */
     public String getFoundries () {
@@ -381,9 +394,10 @@
 
     /**
      * Set information on the foundries the document
-     * is annotated with. 
-     *
-     * @param foundries The foundry information string.
+     * is annotated with.
+     * 
+     * @param foundries
+     *            The foundry information string.
      */
     public void setFoundries (String foundries) {
         this.foundries = foundries;
@@ -392,8 +406,8 @@
 
     /**
      * Get information on the layers the document
-     * is annotated with as a string. 
-     *
+     * is annotated with as a string.
+     * 
      * @return The layer information string.
      */
     public String getLayerInfos () {
@@ -403,9 +417,10 @@
 
     /**
      * Set information on the layers the document
-     * is annotated with as a string. 
-     *
-     * @param layerInfos The layer information string.
+     * is annotated with as a string.
+     * 
+     * @param layerInfos
+     *            The layer information string.
      */
     public void setLayerInfos (String layerInfos) {
         this.layerInfos = layerInfos;
@@ -414,8 +429,8 @@
 
     // This is the new text id
     /**
-     * Get the text sigle as a string. 
-     *
+     * Get the text sigle as a string.
+     * 
      * @return The text sigle as a string.
      */
     public String getTextSigle () {
@@ -425,9 +440,10 @@
 
     // This is the new text id
     /**
-     * Set the text sigle as a string. 
-     *
-     * @param textSigle The text sigle as a string.
+     * Set the text sigle as a string.
+     * 
+     * @param textSigle
+     *            The text sigle as a string.
      */
     public void setTextSigle (String textSigle) {
         this.textSigle = textSigle;
@@ -436,8 +452,8 @@
 
     // This is the new corpus id
     /**
-     * Get the corpus sigle as a string. 
-     *
+     * Get the corpus sigle as a string.
+     * 
      * @return The corpus sigle as a string.
      */
     public String getCorpusSigle () {
@@ -447,9 +463,10 @@
 
     // This is the new corpus id
     /**
-     * Set the corpus sigle as a string. 
-     *
-     * @param corpusSigle The corpus sigle as a string.
+     * Set the corpus sigle as a string.
+     * 
+     * @param corpusSigle
+     *            The corpus sigle as a string.
      */
     public void setCorpusSigle (String corpusSigle) {
         this.corpusSigle = corpusSigle;
@@ -457,8 +474,8 @@
 
 
     /**
-     * Get the document sigle as a string. 
-     *
+     * Get the document sigle as a string.
+     * 
      * @return The document sigle as a string.
      */
     public String getDocSigle () {
@@ -467,9 +484,10 @@
 
 
     /**
-     * Set the document sigle as a string. 
-     *
-     * @param docSigle The document sigle as a string.
+     * Set the document sigle as a string.
+     * 
+     * @param docSigle
+     *            The document sigle as a string.
      */
     public void setDocSigle (String docSigle) {
         this.docSigle = docSigle;
@@ -477,8 +495,8 @@
 
 
     /**
-     * Get the name of the publisher as a string. 
-     *
+     * Get the name of the publisher as a string.
+     * 
      * @return The name of the publisher as a string.
      */
     public String getPublisher () {
@@ -487,9 +505,10 @@
 
 
     /**
-     * Set the name of the publisher as a string. 
-     *
-     * @param publisher The name of the publisher as a string.
+     * Set the name of the publisher as a string.
+     * 
+     * @param publisher
+     *            The name of the publisher as a string.
      */
     public void setPublisher (String publisher) {
         this.publisher = publisher;
@@ -497,8 +516,8 @@
 
 
     /**
-     * Get the name of the editor as a string. 
-     *
+     * Get the name of the editor as a string.
+     * 
      * @return The name of the editor as a string.
      */
     public String getEditor () {
@@ -507,9 +526,10 @@
 
 
     /**
-     * Set the name of the editor as a string. 
-     *
-     * @param editor The name of the editor as a string.
+     * Set the name of the editor as a string.
+     * 
+     * @param editor
+     *            The name of the editor as a string.
      */
     public void setEditor (String editor) {
         this.editor = editor;
@@ -517,8 +537,8 @@
 
 
     /**
-     * Get the type of the text as a string. 
-     *
+     * Get the type of the text as a string.
+     * 
      * @return The type of the text as a string.
      */
     public String getTextType () {
@@ -527,9 +547,10 @@
 
 
     /**
-     * Set the type of the text as a string. 
-     *
-     * @param textType The type of the text as a string.
+     * Set the type of the text as a string.
+     * 
+     * @param textType
+     *            The type of the text as a string.
      */
     public void setTextType (String textType) {
         this.textType = textType;
@@ -537,8 +558,8 @@
 
 
     /**
-     * Get the type art of the text as a string. 
-     *
+     * Get the type art of the text as a string.
+     * 
      * @return The type art of the text as a string.
      */
     public String getTextTypeArt () {
@@ -547,9 +568,10 @@
 
 
     /**
-     * Set the type art of the text as a string. 
-     *
-     * @param textTypeArt The type art of the text as a string.
+     * Set the type art of the text as a string.
+     * 
+     * @param textTypeArt
+     *            The type art of the text as a string.
      */
     public void setTextTypeArt (String textTypeArt) {
         this.textTypeArt = textTypeArt;
@@ -557,9 +579,10 @@
 
 
     /**
-     * Set the type reference of the text as a string. 
-     *
-     * @param textTypeRef The type reference of the text as a string.
+     * Set the type reference of the text as a string.
+     * 
+     * @param textTypeRef
+     *            The type reference of the text as a string.
      */
     public void setTextTypeRef (String textTypeRef) {
         this.textTypeRef = textTypeRef;
@@ -567,8 +590,8 @@
 
 
     /**
-     * Get the type reference of the text as a string. 
-     *
+     * Get the type reference of the text as a string.
+     * 
      * @return The type reference of the text as a string.
      */
     public String getTextTypeRef () {
@@ -577,8 +600,8 @@
 
 
     /**
-     * Get the column of the text as a string. 
-     *
+     * Get the column of the text as a string.
+     * 
      * @return The column of the text as a string.
      */
     public String getTextColumn () {
@@ -587,9 +610,10 @@
 
 
     /**
-     * Set the column of the text as a string. 
-     *
-     * @param textColumn The column of the text as a string.
+     * Set the column of the text as a string.
+     * 
+     * @param textColumn
+     *            The column of the text as a string.
      */
     public void setTextColumn (String textColumn) {
         this.textColumn = textColumn;
@@ -597,8 +621,8 @@
 
 
     /**
-     * Get the domain of the text as a string. 
-     *
+     * Get the domain of the text as a string.
+     * 
      * @return The domain of the text as a string.
      */
     public String getTextDomain () {
@@ -607,9 +631,10 @@
 
 
     /**
-     * Set the domain of the text as a string. 
-     *
-     * @param textDomain The domain of the text as a string.
+     * Set the domain of the text as a string.
+     * 
+     * @param textDomain
+     *            The domain of the text as a string.
      */
     public void setTextDomain (String textDomain) {
         this.textDomain = textDomain;
@@ -617,8 +642,8 @@
 
 
     /**
-     * Get the license of the text as a string. 
-     *
+     * Get the license of the text as a string.
+     * 
      * @return The license of the text as a string.
      */
     public String getLicense () {
@@ -627,9 +652,10 @@
 
 
     /**
-     * Set the license of the text as a string. 
-     *
-     * @param license The license of the text as a string.
+     * Set the license of the text as a string.
+     * 
+     * @param license
+     *            The license of the text as a string.
      */
     public void setLicense (String license) {
         this.license = license;
@@ -637,8 +663,8 @@
 
 
     /**
-     * Get the page numbers of the text as a string. 
-     *
+     * Get the page numbers of the text as a string.
+     * 
      * @return The page numbers of the text as a string.
      */
     public String getPages () {
@@ -647,9 +673,10 @@
 
 
     /**
-     * Set the page numbers of the text as a string. 
-     *
-     * @param pages The page numbers of the text as a string.
+     * Set the page numbers of the text as a string.
+     * 
+     * @param pages
+     *            The page numbers of the text as a string.
      */
     public void setPages (String pages) {
         this.pages = pages;
@@ -657,8 +684,8 @@
 
 
     /**
-     * Get the file edition statement of the text as a string. 
-     *
+     * Get the file edition statement of the text as a string.
+     * 
      * @return The file edition statement of the text as a string.
      */
     public String getFileEditionStatement () {
@@ -667,10 +694,11 @@
 
 
     /**
-     * Set the file edition statement of the text as a string. 
-     *
-     * @param fileEditionStatement The file edition statement
-     *        of the text as a string.
+     * Set the file edition statement of the text as a string.
+     * 
+     * @param fileEditionStatement
+     *            The file edition statement
+     *            of the text as a string.
      */
     public void setFileEditionStatement (String fileEditionStatement) {
         this.fileEditionStatement = fileEditionStatement;
@@ -678,9 +706,10 @@
 
 
     /**
-     * Get the bibliograhic edition statement of the text as a string. 
-     *
-     * @return The bibliograhic edition statement of the text as a string.
+     * Get the bibliograhic edition statement of the text as a string.
+     * 
+     * @return The bibliograhic edition statement of the text as a
+     *         string.
      */
     public String getBiblEditionStatement () {
         return this.biblEditionStatement;
@@ -688,10 +717,11 @@
 
 
     /**
-     * Set the bibliograhic edition statement of the text as a string. 
-     *
-     * @param biblEditionStatement The bibliograhic edition statement
-     *        of the text as a string.
+     * Set the bibliograhic edition statement of the text as a string.
+     * 
+     * @param biblEditionStatement
+     *            The bibliograhic edition statement
+     *            of the text as a string.
      */
     public void setBiblEditionStatement (String biblEditionStatement) {
         this.biblEditionStatement = biblEditionStatement;
@@ -699,8 +729,8 @@
 
 
     /**
-     * Get the reference of the text as a string. 
-     *
+     * Get the reference of the text as a string.
+     * 
      * @return The reference of the text as a string.
      */
     public String getReference () {
@@ -709,9 +739,10 @@
 
 
     /**
-     * Set the reference of the text as a string. 
-     *
-     * @param reference The reference of the text as a string.
+     * Set the reference of the text as a string.
+     * 
+     * @param reference
+     *            The reference of the text as a string.
      */
     public void setReference (String reference) {
         this.reference = reference;
@@ -719,8 +750,8 @@
 
 
     /**
-     * Get the language of the text as a string. 
-     *
+     * Get the language of the text as a string.
+     * 
      * @return The language of the text as a string.
      */
     public String getLanguage () {
@@ -729,9 +760,10 @@
 
 
     /**
-     * Set the language of the text as a string. 
-     *
-     * @param language The language of the text as a string.
+     * Set the language of the text as a string.
+     * 
+     * @param language
+     *            The language of the text as a string.
      */
     public void setLanguage (String language) {
         this.language = language;
@@ -739,8 +771,8 @@
 
 
     /**
-     * Get the corpus title of the text as a string. 
-     *
+     * Get the corpus title of the text as a string.
+     * 
      * @return The corpus title of the text as a string.
      */
     public String getCorpusTitle () {
@@ -749,9 +781,10 @@
 
 
     /**
-     * Set the corpus title of the text as a string. 
-     *
-     * @param corpusTitle The corpus title of the text as a string.
+     * Set the corpus title of the text as a string.
+     * 
+     * @param corpusTitle
+     *            The corpus title of the text as a string.
      */
     public void setCorpusTitle (String corpusTitle) {
         this.corpusTitle = corpusTitle;
@@ -759,8 +792,8 @@
 
 
     /**
-     * Get the corpus subtitle of the text as a string. 
-     *
+     * Get the corpus subtitle of the text as a string.
+     * 
      * @return The corpus subtitle of the text as a string.
      */
     public String getCorpusSubTitle () {
@@ -769,10 +802,11 @@
 
 
     /**
-     * Set the corpus subtitle of the text as a string. 
-     *
-     * @param corpusSubTitle The corpus subtitle of the
-     *        text as a string.
+     * Set the corpus subtitle of the text as a string.
+     * 
+     * @param corpusSubTitle
+     *            The corpus subtitle of the
+     *            text as a string.
      */
     public void setCorpusSubTitle (String corpusSubTitle) {
         this.corpusSubTitle = corpusSubTitle;
@@ -780,8 +814,8 @@
 
 
     /**
-     * Get the corpus author of the text as a string. 
-     *
+     * Get the corpus author of the text as a string.
+     * 
      * @return The corpus author of the text as a string.
      */
     public String getCorpusAuthor () {
@@ -790,8 +824,8 @@
 
 
     /**
-     * Set the corpus author of the text as a string. 
-     *
+     * Set the corpus author of the text as a string.
+     * 
      * @return The corpus author of the text as a string.
      */
     public void setCorpusAuthor (String corpusAuthor) {
@@ -800,8 +834,8 @@
 
 
     /**
-     * Get the corpus editor of the text as a string. 
-     *
+     * Get the corpus editor of the text as a string.
+     * 
      * @return The corpus editor of the text as a string.
      */
     public String getCorpusEditor () {
@@ -810,9 +844,10 @@
 
 
     /**
-     * Set the corpus editor of the text as a string. 
-     *
-     * @param corpusEditor The corpus editor of the text as a string.
+     * Set the corpus editor of the text as a string.
+     * 
+     * @param corpusEditor
+     *            The corpus editor of the text as a string.
      */
     public void setCorpusEditor (String corpusEditor) {
         this.corpusEditor = corpusEditor;
@@ -820,18 +855,20 @@
 
 
     /**
-     * Get the document title of the text as a string. 
-     *
+     * Get the document title of the text as a string.
+     * 
      * @return The document title of the text as a string.
      */
     public String getDocTitle () {
         return this.docTitle;
     };
 
+
     /**
-     * Set the document title of the text as a string. 
-     *
-     * @param docTitle The document title of the text as a string.
+     * Set the document title of the text as a string.
+     * 
+     * @param docTitle
+     *            The document title of the text as a string.
      */
     public void setDocTitle (String docTitle) {
         this.docTitle = docTitle;
@@ -839,8 +876,8 @@
 
 
     /**
-     * Get the subtitle of the document of the text as a string. 
-     *
+     * Get the subtitle of the document of the text as a string.
+     * 
      * @return The subtitle of the document of the text as a string.
      */
     public String getDocSubTitle () {
@@ -849,10 +886,11 @@
 
 
     /**
-     * Set the subtitle of the document of the text as a string. 
-     *
-     * @param docSubTitle The subtitle of the document of the
-     *        text as a string.
+     * Set the subtitle of the document of the text as a string.
+     * 
+     * @param docSubTitle
+     *            The subtitle of the document of the
+     *            text as a string.
      */
     public void setDocSubTitle (String docSubTitle) {
         this.docSubTitle = docSubTitle;
@@ -860,8 +898,8 @@
 
 
     /**
-     * Get the author of the document of the text as a string. 
-     *
+     * Get the author of the document of the text as a string.
+     * 
      * @return The author of the document of the text as a string.
      */
     public String getDocAuthor () {
@@ -870,9 +908,10 @@
 
 
     /**
-     * Set the author of the document of the text as a string. 
-     *
-     * @param docAuthor The author of the document of the text as a string.
+     * Set the author of the document of the text as a string.
+     * 
+     * @param docAuthor
+     *            The author of the document of the text as a string.
      */
     public void setDocAuthor (String docAuthor) {
         this.docAuthor = docAuthor;
@@ -880,8 +919,8 @@
 
 
     /**
-     * Get the editor of the document of the text as a string. 
-     *
+     * Get the editor of the document of the text as a string.
+     * 
      * @return The editor of the document of the text as a string.
      */
     public String getDocEditor () {
@@ -890,9 +929,10 @@
 
 
     /**
-     * Set the editor of the document of the text as a string. 
-     *
-     * @param docEditor The editor of the document of the text as a string.
+     * Set the editor of the document of the text as a string.
+     * 
+     * @param docEditor
+     *            The editor of the document of the text as a string.
      */
     public void setDocEditor (String docEditor) {
         this.docEditor = docEditor;
@@ -900,8 +940,8 @@
 
 
     /**
-     * Get the keywords of the text as a string. 
-     *
+     * Get the keywords of the text as a string.
+     * 
      * @return The keywords of the text as a string.
      */
     public String getKeywords () {
@@ -910,9 +950,10 @@
 
 
     /**
-     * Set the keywords of the text as a string. 
-     *
-     * @param keywords The keywords of the text as a string.
+     * Set the keywords of the text as a string.
+     * 
+     * @param keywords
+     *            The keywords of the text as a string.
      */
     public void setKeywords (String keywords) {
         this.keywords = keywords;
@@ -921,8 +962,8 @@
 
     /**
      * Get information about the source of tokenization
-     * as a string. 
-     *
+     * as a string.
+     * 
      * @return The tokenization information as a string.
      */
     public String getTokenSource () {
@@ -932,9 +973,10 @@
 
     /**
      * Set information about the source of tokenization
-     * as a string. 
-     *
-     * @param tokenSource The tokenization information as a string.
+     * as a string.
+     * 
+     * @param tokenSource
+     *            The tokenization information as a string.
      */
     public void setTokenSource (String tokenSource) {
         this.tokenSource = tokenSource;
diff --git a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
index 70d183f..dc16ccf 100644
--- a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
@@ -30,7 +30,7 @@
  * FieldDocument represents a simple API to create documents
  * for storing with KrillIndex. <i>Field</i> in the name resembles
  * the meaning of Lucene index fields.
- *
+ * 
  * @author diewald
  */
 @JsonIgnoreProperties(ignoreUnknown = true)
@@ -40,9 +40,9 @@
 
     public Document doc = new Document();
 
-    private FieldType tvField   = new FieldType(TextField.TYPE_STORED);
+    private FieldType tvField = new FieldType(TextField.TYPE_STORED);
     private FieldType tvNoField = new FieldType(TextField.TYPE_NOT_STORED);
-    private FieldType keywords  = new FieldType(TextField.TYPE_STORED);
+    private FieldType keywords = new FieldType(TextField.TYPE_STORED);
 
     {
         tvField.setStoreTermVectors(true);
@@ -62,71 +62,86 @@
         keywords.setIndexOptions(IndexOptions.DOCS_ONLY);
     };
 
+
     // see http://www.cowtowncoder.com/blog/archives/2011/07/entry_457.html
 
     public void addInt (String key, int value) {
         doc.add(new IntField(key, value, Field.Store.YES));
     };
 
+
     public void addInt (String key, String value) {
         this.addInt(key, Integer.parseInt(value));
     };
 
+
     public void addText (String key, String value) {
         doc.add(new TextField(key, value, Field.Store.YES));
     };
 
+
     public void addKeyword (String key, String value) {
         doc.add(new Field(key, value, keywords));
     };
 
+
     public void addString (String key, String value) {
         doc.add(new StringField(key, value, Field.Store.YES));
     };
 
+
     public void addStored (String key, String value) {
         doc.add(new StoredField(key, value));
     };
 
+
     public void addStored (String key, int value) {
         doc.add(new StoredField(key, value));
     };
 
+
     public void addTV (String key, String value, String tsString) {
         this.addTV(key, value, new MultiTermTokenStream(tsString));
     };
 
+
     public void addTV (String key, String tsString) {
         this.addTV(key, new MultiTermTokenStream(tsString));
     };
 
+
     public void addTV (String key, String value, MultiTermTokenStream ts) {
-        Field textField = new Field( key, value, tvField );
-        textField.setTokenStream( ts );
+        Field textField = new Field(key, value, tvField);
+        textField.setTokenStream(ts);
         doc.add(textField);
     };
 
+
     public void addTV (String key, MultiTermTokenStream ts) {
-        Field textField = new Field( key, ts, tvNoField );
+        Field textField = new Field(key, ts, tvNoField);
         doc.add(textField);
     };
 
+
     public String toString () {
         return doc.toString();
     };
 
+
     public MultiTermTokenStream newMultiTermTokenStream (String ts) {
         return new MultiTermTokenStream(ts);
     };
 
+
     public MultiTermTokenStream newMultiTermTokenStream () {
         return new MultiTermTokenStream();
     };
 
+
     /**
      * Deserialize token stream data.
      */
-    public void setData (Map<String,Object> node) {
+    public void setData (Map<String, Object> node) {
         this.setPrimaryData((String) node.get("text"));
 
         String fieldName = (String) node.get("name");
@@ -134,7 +149,8 @@
         MultiTermTokenStream mtts = this.newMultiTermTokenStream();
 
         // Iterate over all tokens in stream
-        for (ArrayList<String> token : (ArrayList<ArrayList<String>>) node.get("stream")) {
+        for (ArrayList<String> token : (ArrayList<ArrayList<String>>) node
+                .get("stream")) {
 
             try {
                 // Initialize MultiTermToken
@@ -143,7 +159,7 @@
                 // Add rest of the list
                 for (String term : token) {
                     mtt.add(term);
-                 };
+                };
 
                 // Add MultiTermToken to stream
                 mtts.addMultiTermToken(mtt);
@@ -170,20 +186,22 @@
             this.setTokenSource((String) node.get("tokenSource"));
     };
 
+
     /**
      * Deserialize token stream data (LEGACY).
      */
     public void setFields (ArrayList<Map<String, Object>> fields) {
-        
-        Map<String,Object> primary = fields.remove(0);
+
+        Map<String, Object> primary = fields.remove(0);
         this.setPrimaryData((String) primary.get("primaryData"));
 
-        for (Map<String,Object> field : fields) {
+        for (Map<String, Object> field : fields) {
 
             String fieldName = (String) field.get("name");
             MultiTermTokenStream mtts = this.newMultiTermTokenStream();
 
-            for (ArrayList<String> token : (ArrayList<ArrayList<String>>) field.get("data")) {
+            for (ArrayList<String> token : (ArrayList<ArrayList<String>>) field
+                    .get("data")) {
 
                 try {
                     MultiTermToken mtt = new MultiTermToken(token.remove(0));
@@ -219,36 +237,42 @@
         };
     };
 
+
     @Override
     public void setTextClass (String textClass) {
         super.setTextClass(textClass);
         this.addKeyword("textClass", textClass);
     };
 
+
     @Override
     public void setTitle (String title) {
         super.setTitle(title);
         this.addText("title", title);
     };
 
+
     @Override
     public void setSubTitle (String subTitle) {
         super.setSubTitle(subTitle);
         this.addText("subTitle", subTitle);
     };
 
+
     @Override
     public void setAuthor (String author) {
         super.setAuthor(author);
         this.addText("author", author);
     };
 
+
     @Override
     public void setPubPlace (String pubPlace) {
         super.setPubPlace(pubPlace);
         this.addString("pubPlace", pubPlace);
     };
 
+
     @JsonProperty("pubDate")
     @Override
     public KrillDate setPubDate (String pubDate) {
@@ -257,6 +281,7 @@
         return date;
     };
 
+
     @JsonProperty("creationDate")
     @Override
     public KrillDate setCreationDate (String creationDate) {
@@ -265,6 +290,7 @@
         return date;
     };
 
+
     // No longer supported
     @Override
     public void setCorpusID (String corpusID) {
@@ -272,6 +298,7 @@
         this.addString("corpusID", corpusID);
     };
 
+
     // No longer supported
     @Override
     public void setID (String ID) {
@@ -279,12 +306,14 @@
         this.addString("ID", ID);
     };
 
+
     @Override
     public void setUID (int ID) {
         super.setUID(ID);
         this.addString("UID", new Integer(ID).toString());
     };
 
+
     // No longer supported
     @Override
     public void setLayerInfo (String layerInfo) {
@@ -292,168 +321,196 @@
         this.addStored("layerInfo", layerInfo);
     };
 
+
     @Override
     public void setLayerInfos (String layerInfos) {
         super.setLayerInfos(layerInfos);
         this.addStored("layerInfos", layerInfos);
     };
 
+
     @Override
     public void setTextSigle (String textSigle) {
         super.setTextSigle(textSigle);
         this.addString("textSigle", textSigle);
     };
 
+
     @Override
     public void setDocSigle (String docSigle) {
         super.setDocSigle(docSigle);
         this.addString("docSigle", docSigle);
     };
 
+
     @Override
     public void setCorpusSigle (String corpusSigle) {
         super.setCorpusSigle(corpusSigle);
         this.addString("corpusSigle", corpusSigle);
     };
 
+
     @Override
     public void setPublisher (String publisher) {
         super.setPublisher(publisher);
         this.addStored("publisher", publisher);
     };
 
+
     @Override
     public void setEditor (String editor) {
         super.setEditor(editor);
         this.addStored("editor", editor);
     };
 
+
     @Override
     public void setTextType (String textType) {
         super.setTextType(textType);
         this.addString("textType", textType);
     };
 
+
     @Override
     public void setTextTypeArt (String textTypeArt) {
         super.setTextTypeArt(textTypeArt);
         this.addString("textTypeArt", textTypeArt);
     };
 
+
     @Override
     public void setTextTypeRef (String textTypeRef) {
         super.setTextTypeRef(textTypeRef);
         this.addString("textTypeRef", textTypeRef);
     };
 
+
     @Override
     public void setTextColumn (String textColumn) {
         super.setTextColumn(textColumn);
         this.addString("textColumn", textColumn);
     };
 
+
     @Override
     public void setTextDomain (String textDomain) {
         super.setTextDomain(textDomain);
         this.addString("textDomain", textDomain);
     };
 
+
     @Override
     public void setLicense (String license) {
         super.setLicense(license);
         this.addString("license", license);
     };
 
+
     @Override
     public void setPages (String pages) {
         super.setPages(pages);
         this.addStored("pages", pages);
     };
 
+
     @Override
     public void setFileEditionStatement (String fileEditionStatement) {
         super.setFileEditionStatement(fileEditionStatement);
         this.addStored("fileEditionStatement", fileEditionStatement);
     };
 
+
     @Override
     public void setBiblEditionStatement (String biblEditionStatement) {
         super.setBiblEditionStatement(biblEditionStatement);
         this.addStored("biblEditionStatement", biblEditionStatement);
     };
 
+
     @Override
     public void setReference (String reference) {
         super.setReference(reference);
         this.addStored("reference", reference);
     };
 
+
     @Override
     public void setLanguage (String language) {
         super.setLanguage(language);
         this.addString("language", language);
     };
 
+
     @Override
     public void setDocTitle (String docTitle) {
         super.setDocTitle(docTitle);
         this.addText("docTitle", docTitle);
     };
 
+
     @Override
     public void setDocSubTitle (String docSubTitle) {
         super.setDocSubTitle(docSubTitle);
         this.addText("docSubTitle", docSubTitle);
     };
 
+
     @Override
     public void setDocAuthor (String docAuthor) {
         super.setDocAuthor(docAuthor);
         this.addText("docAuthor", docAuthor);
     };
 
+
     @Override
     public void setDocEditor (String docEditor) {
         super.setDocEditor(docEditor);
         this.addStored("docEditor", docEditor);
     };
 
+
     @Override
     public void setCorpusTitle (String corpusTitle) {
         super.setCorpusTitle(corpusTitle);
         this.addText("corpusTitle", corpusTitle);
     };
 
+
     @Override
     public void setCorpusSubTitle (String corpusSubTitle) {
         super.setCorpusSubTitle(corpusSubTitle);
         this.addText("corpusSubTitle", corpusSubTitle);
     };
 
+
     @Override
     public void setCorpusAuthor (String corpusAuthor) {
         super.setCorpusAuthor(corpusAuthor);
         this.addText("corpusAuthor", corpusAuthor);
     };
 
+
     @Override
     public void setCorpusEditor (String corpusEditor) {
         super.setCorpusEditor(corpusEditor);
         this.addStored("corpusEditor", corpusEditor);
     };
 
+
     @Override
     public void setKeywords (String keywords) {
         super.setKeywords(keywords);
         this.addKeyword("keywords", keywords);
     };
 
+
     @Override
     public void setTokenSource (String tokenSource) {
         super.setTokenSource(tokenSource);
         this.addStored("tokenSource", tokenSource);
     };
 
+
     @Override
     public void setFoundries (String foundries) {
         super.setFoundries(foundries);
diff --git a/src/main/java/de/ids_mannheim/korap/index/Indexer.java b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
index 5af92e5..6eb8099 100644
--- a/src/main/java/de/ids_mannheim/korap/index/Indexer.java
+++ b/src/main/java/de/ids_mannheim/korap/index/Indexer.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.index;
+
 import java.util.*;
 import java.io.*;
 import org.apache.lucene.store.MMapDirectory;
@@ -12,7 +13,7 @@
  * is using the standalone server system,
  * this tool may be more suitable for your needs
  * (especially as it is way faster).
- *
+ * 
  * Usage: java -jar Krill-X.XX.jar [propfile] [directories]*
  */
 public class Indexer {
@@ -22,25 +23,26 @@
     int commitCount;
 
     // Init logger
-    private final static Logger log =
-        LoggerFactory.getLogger(KrillIndex.class);
+    private final static Logger log = LoggerFactory.getLogger(KrillIndex.class);
 
 
     /**
      * Construct a new indexer object.
-     *
-     * @param prop A {@link Properties} object with
-     *        at least the following information:
-     *        <tt>krill.indexDir</tt>.
+     * 
+     * @param prop
+     *            A {@link Properties} object with
+     *            at least the following information:
+     *            <tt>krill.indexDir</tt>.
      * @throws IOException
      */
     public Indexer (Properties prop) throws IOException {
         this.indexDir = prop.getProperty("krill.indexDir");
 
         System.out.println("Index to " + this.indexDir);
-	
+
         // Default to 1000 documents till the next commit
-        String commitCount = prop.getProperty("krill.index.commit.count", "1000");
+        String commitCount = prop.getProperty("krill.index.commit.count",
+                "1000");
 
         // Create a new index object based on the directory
         this.index = new KrillIndex(new MMapDirectory(new File(indexDir)));
@@ -48,11 +50,13 @@
         this.commitCount = Integer.parseInt(commitCount);
     };
 
+
     /**
      * Parse a directory for document files.
-     *
-     * @param dir The {@link File} directory containing
-     * documents to index.
+     * 
+     * @param dir
+     *            The {@link File} directory containing
+     *            documents to index.
      */
     public void parse (File dir) {
         for (String file : dir.list()) {
@@ -80,6 +84,7 @@
         };
     };
 
+
     /**
      * Commit changes to the index.
      */
@@ -95,12 +100,14 @@
         System.out.println("done.");
     };
 
+
     /**
      * Main method.
-     *
-     * @param argv Argument list,
-     *        expecting the properties file
-     *        and a list of directories
+     * 
+     * @param argv
+     *            Argument list,
+     *            expecting the properties file
+     *            and a list of directories
      * @throws IOException
      */
     public static void main (String[] argv) throws IOException {
@@ -110,11 +117,9 @@
         if (argv.length < 2) {
 
             String jar = new File(Indexer.class.getProtectionDomain()
-                                  .getCodeSource()
-                                  .getLocation()
-                                  .getPath()).getName();
-            System.out.println("Usage: java -jar " + jar +
-                               " [propfile] [directories]*");
+                    .getCodeSource().getLocation().getPath()).getName();
+            System.out.println("Usage: java -jar " + jar
+                    + " [propfile] [directories]*");
             return;
         };
 
@@ -129,7 +134,7 @@
         System.out.println();
 
         // Iterate over list of directories
-        for (String arg :  Arrays.copyOfRange(argv, 1, argv.length)) {
+        for (String arg : Arrays.copyOfRange(argv, 1, argv.length)) {
             File f = new File(arg);
             if (f.isDirectory())
                 ki.parse(f);
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
index 33a81cf..1f74f93 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTerm.java
@@ -13,30 +13,36 @@
  * Don't use ByteBuffer!
  */
 /**
- * A MultiTerm represents a single term (e.g. a word, an annotation, a relation)
+ * A MultiTerm represents a single term (e.g. a word, an annotation, a
+ * relation)
  * that can be part of a MultiTermToken.
- *
- * A MultiTerm consists of a term representation string, optional character offset
- * information that matches the term to the character stream of the input text,
+ * 
+ * A MultiTerm consists of a term representation string, optional
+ * character offset
+ * information that matches the term to the character stream of the
+ * input text,
  * and an arbitrary payload.
- *
+ * 
  * There is a simple string representation of MultiTerms supported:
  * The string is the first sequence of characters.
- * Offsets are written as an appended and dash separated pair of integers.
+ * Offsets are written as an appended and dash separated pair of
+ * integers.
  * Payloads are written following a dollar sign.
- * Payload segments can be typed as being a short (s), an integer (i), or a long (l)
+ * Payload segments can be typed as being a short (s), an integer (i),
+ * or a long (l)
  * value in leading angular brackets.
- * All other (untyped) payloads are treated as being UTF-8 characer sequences.
- *
+ * All other (untyped) payloads are treated as being UTF-8 characer
+ * sequences.
+ * 
  * <blockquote><pre>
- *   MultiTerm test1 = new MultiTerm("test");
- *   MultiTerm test2 = new MultiTerm("test#0-4");
- *   MultiTerm test3 = new MultiTerm("test#0-4$Example");
- *   MultiTerm test4 = new MultiTerm("test#0-4$&lt;i&gt;1278");
+ * MultiTerm test1 = new MultiTerm("test");
+ * MultiTerm test2 = new MultiTerm("test#0-4");
+ * MultiTerm test3 = new MultiTerm("test#0-4$Example");
+ * MultiTerm test4 = new MultiTerm("test#0-4$&lt;i&gt;1278");
  * </pre></blockquote>
- *
+ * 
  * <strong>Warning</strong>: Strings that are malformed fail silently!
- *
+ * 
  * @author diewald
  */
 public class MultiTerm implements Comparable<MultiTerm> {
@@ -52,7 +58,8 @@
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
-    private final Logger log = LoggerFactory.getLogger(MultiTermTokenStream.class);
+    private final Logger log = LoggerFactory
+            .getLogger(MultiTermTokenStream.class);
 
 
     /**
@@ -65,28 +72,31 @@
 
     /**
      * Construct a new MultiTerm object.
-     *
-     * @param term The term surface (see synopsis).
+     * 
+     * @param term
+     *            The term surface (see synopsis).
      */
     public MultiTerm (String term) throws CorpusDataException {
         _fromString(term);
     };
 
-    
+
     /**
      * Construct a new MultiTerm object.
-     *
+     * 
      * In addition to the normal surface representation,
      * this supports a prefix notation.
      * The following expressions are equal:
-     *
+     * 
      * <blockquote><pre>
-     *   MultiTerm test1 = new MultiTerm('a', "bcd");
-     *   MultiTerm test2 = new MultiTerm("a:bcd");
+     * MultiTerm test1 = new MultiTerm('a', "bcd");
+     * MultiTerm test2 = new MultiTerm("a:bcd");
      * </pre></blockquote>
-     *
-     * @param prefix A special prefix for the term.
-     * @param term The term surface (see synopsis).
+     * 
+     * @param prefix
+     *            A special prefix for the term.
+     * @param term
+     *            The term surface (see synopsis).
      */
     public MultiTerm (char prefix, String term) throws CorpusDataException {
         StringBuilder sb = new StringBuilder();
@@ -96,18 +106,19 @@
 
     /**
      * Get the term value of the MultiTerm.
-     *
+     * 
      * @return The term as a string.
      */
     public String getTerm () {
         return this.term;
     };
-    
-    
+
+
     /**
      * Set the term value of the MultiTerm.
-     *
-     * @param term The term as a string.
+     * 
+     * @param term
+     *            The term as a string.
      * @return The {@link MultIterm} object for chaining.
      */
     public MultiTerm setTerm (String term) {
@@ -118,66 +129,71 @@
 
     /**
      * Get the payload.
-     *
+     * 
      * @return The payload as a BytesRef.
      */
     public BytesRef getPayload () {
         return this.payload;
     };
 
-    
+
     /**
      * Set the payload as a {@link Byte} value.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (Byte pl) {
-        this.payload = new BytesRef( ByteBuffer.allocate(1).put(pl).array());
+        this.payload = new BytesRef(ByteBuffer.allocate(1).put(pl).array());
         return this;
     };
 
-    
+
     /**
      * Set the payload as a short value.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (short pl) {
-        this.payload = new BytesRef( ByteBuffer.allocate(2).putShort(pl).array());
+        this.payload = new BytesRef(ByteBuffer.allocate(2).putShort(pl).array());
         return this;
     };
 
 
     /**
      * Set the payload as an integer value.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (int pl) {
-        this.payload = new BytesRef( ByteBuffer.allocate(4).putInt(pl).array());
+        this.payload = new BytesRef(ByteBuffer.allocate(4).putInt(pl).array());
         return this;
     };
 
-    
+
     /**
      * Set the payload as a long value.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (long pl) {
-        this.payload = new BytesRef( ByteBuffer.allocate(8).putLong(pl).array());
+        this.payload = new BytesRef(ByteBuffer.allocate(8).putLong(pl).array());
         return this;
     };
 
 
     /**
      * Set the payload as a string value.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (String pl) {
@@ -188,8 +204,9 @@
 
     /**
      * Set the payload as a byte array.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (byte[] pl) {
@@ -200,8 +217,9 @@
 
     /**
      * Set the payload as a {@link BytesRef} object.
-     *
-     * @param pl The payload.
+     * 
+     * @param pl
+     *            The payload.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setPayload (BytesRef pl) {
@@ -212,7 +230,7 @@
 
     /**
      * Get the start position.
-     *
+     * 
      * @return The start position.
      */
     public int getStart () {
@@ -222,8 +240,9 @@
 
     /**
      * Set the start position.
-     *
-     * @param start The start position.
+     * 
+     * @param start
+     *            The start position.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setStart (int start) {
@@ -234,7 +253,7 @@
 
     /**
      * Get the end position.
-     *
+     * 
      * @return The end position.
      */
     public int getEnd () {
@@ -244,8 +263,9 @@
 
     /**
      * Set the end position.
-     *
-     * @param end The end position.
+     * 
+     * @param end
+     *            The end position.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm setEnd (int end) {
@@ -256,7 +276,7 @@
 
     /**
      * Check if there are offsets stored.
-     *
+     * 
      * @return Boolean value indicating that the term
      *         contains stored offsets.
      */
@@ -267,9 +287,10 @@
 
     /**
      * Set the flag for stored offsets, in case they are relevant.
-     *
-     * @param value Boolean value indicating that the term
-     *        contains stored offsets.
+     * 
+     * @param value
+     *            Boolean value indicating that the term
+     *            contains stored offsets.
      * @return The {@link MultiTerm} object for chaining.
      */
     public MultiTerm hasStoredOffsets (boolean value) {
@@ -283,16 +304,13 @@
      * Offsets are attached following a hash sign,
      * payloads are attached following a dollar sign.
      * All payloads are written as UTF-8 character sequences.
-     *
+     * 
      * @see #toStringShort().
      */
     public String toString () {
         StringBuilder sb = new StringBuilder(this.term);
         if (this.start != this.end) {
-            sb.append('#')
-                .append(this.start)
-                .append('-')
-                .append(this.end);
+            sb.append('#').append(this.start).append('-').append(this.end);
         };
 
         if (this.payload != null) {
@@ -301,14 +319,15 @@
                 sb.append(this.payload.utf8ToString());
             }
             catch (AssertionError e) {
-                sb.append("<?>")
-                    .append(this.payload.toString().replace(' ', ','));
+                sb.append("<?>").append(
+                        this.payload.toString().replace(' ', ','));
             };
         };
 
         return sb.toString();
     };
 
+
     @Override
     public int compareTo (MultiTerm o) {
         if (this.payload == null || o.payload == null)
@@ -330,7 +349,7 @@
      * Payloads are attached following a dollar sign.
      * All payloads are written as UTF-8 character sequences.
      * Offsets are neglected.
-     *
+     * 
      * Offsets are ignored.
      * 
      * @see #toString().
@@ -343,8 +362,8 @@
                 sb.append(this.payload.utf8ToString());
             }
             catch (AssertionError e) {
-                sb.append("<?>")
-                    .append(this.payload.toString().replace(' ', ','));
+                sb.append("<?>").append(
+                        this.payload.toString().replace(' ', ','));
             };
         };
         return sb.toString();
@@ -377,32 +396,32 @@
 
                         // Resize the bytebuffer
                         if ((bb.capacity() - l) < 8) {
-                            bb = ByteBuffer.allocate(bb.capacity() + 8).
-                                put(bb.array());
+                            bb = ByteBuffer.allocate(bb.capacity() + 8).put(
+                                    bb.array());
                             bb.position(l);
                         };
 
                         switch (pls[i]) {
-                        case "<b>": // byte
-                            bb.put(Byte.parseByte(pls[i+1]));
-                            l++;
-                            break;
-                        case "<s>": // short
-                            bb.putShort(Short.parseShort(pls[i+1]));
-                            l+=2;
-                            break;
-                        case "<i>": // integer
-                            bb.putInt(Integer.parseInt(pls[i+1]));
-                            l+=4;
-                            break;
-                        case "<l>": // long
-                            bb.putLong(Long.parseLong(pls[i+1]));
-                            l+=8;
-                            break;
+                            case "<b>": // byte
+                                bb.put(Byte.parseByte(pls[i + 1]));
+                                l++;
+                                break;
+                            case "<s>": // short
+                                bb.putShort(Short.parseShort(pls[i + 1]));
+                                l += 2;
+                                break;
+                            case "<i>": // integer
+                                bb.putInt(Integer.parseInt(pls[i + 1]));
+                                l += 4;
+                                break;
+                            case "<l>": // long
+                                bb.putLong(Long.parseLong(pls[i + 1]));
+                                l += 8;
+                                break;
                         };
-                        i+=2;
+                        i += 2;
                     };
-		
+
                     byte[] bytes = new byte[l];
                     System.arraycopy(bb.array(), 0, bytes, 0, l);
                     this.payload = new BytesRef(bytes);
@@ -418,7 +437,7 @@
                 this.payload = new BytesRef(payloadStr);
             };
         };
-	
+
         // Parse offset information
         stringOffset = termSurface[0].split("\\#", 2);
 
@@ -426,26 +445,22 @@
 
             // Split start and end position of the offset
             String[] offset = stringOffset[1].split("\\-", 2);
-   
+
             // Start and end is given
             if (offset.length == 2 && offset[0].length() > 0) {
                 try {
                     this.start = Integer.parseInt(offset[0]);
-                    this.end   = Integer.parseInt(offset[1]);
-                    
+                    this.end = Integer.parseInt(offset[1]);
+
                 }
                 catch (NumberFormatException e) {
-                    throw new CorpusDataException(
-                        952,
-                        "Given offset information is not numeric"
-                    );
+                    throw new CorpusDataException(952,
+                            "Given offset information is not numeric");
                 };
             }
             else {
-                throw new CorpusDataException(
-                    953,
-                    "Given offset information is incomplete"
-                );
+                throw new CorpusDataException(953,
+                        "Given offset information is incomplete");
             };
         };
         this.term = stringOffset[0];
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTermToken.java b/src/main/java/de/ids_mannheim/korap/index/MultiTermToken.java
index c3ef720..68ba827 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTermToken.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTermToken.java
@@ -10,18 +10,18 @@
 
 
 /**
- *
+ * 
  * A MultiTermToken represents a set of {@link MultiTerm MultiTerms}
  * starting at the same position, i.e. represents a segment
  * in a {@link MultiTermTokenStream}.
- *
+ * 
  * <blockquote><pre>
- *  MultiTermToken mtt = new MultiTermToken("t:test", "a:abbruch");
- *  mtt.add("b:banane");
- *  System.err.println(mtt.toString());
- *  // [t:test|a:abbruch|b:banane]
+ * MultiTermToken mtt = new MultiTermToken("t:test", "a:abbruch");
+ * mtt.add("b:banane");
+ * System.err.println(mtt.toString());
+ * // [t:test|a:abbruch|b:banane]
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  */
 public class MultiTermToken {
@@ -31,18 +31,22 @@
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
-    private final Logger log = LoggerFactory.getLogger(MultiTermTokenStream.class);
+    private final Logger log = LoggerFactory
+            .getLogger(MultiTermTokenStream.class);
+
 
     /**
      * Construct a new MultiTermToken by passing a stream of
      * {@link MultiTerm MultiTerms}.
-     *
-     * @param terms Take at least one {@link MultiTerm} object for a token.
+     * 
+     * @param terms
+     *            Take at least one {@link MultiTerm} object for a
+     *            token.
      */
     public MultiTermToken (MultiTerm terms, MultiTerm ... moreTerms) {
         this.terms = new ArrayList<MultiTerm>(16);
-        
-        this.terms.add( terms );
+
+        this.terms.add(terms);
 
         // Further elements on same position
         for (i = 0; i < moreTerms.length; i++) {
@@ -54,9 +58,11 @@
     /**
      * Construct a new MultiTermToken by passing a {@link MultiTerm}
      * represented as a prefixed string.
-     *
-     * @param prefix The term prefix.
-     * @param surface The term surface.
+     * 
+     * @param prefix
+     *            The term prefix.
+     * @param surface
+     *            The term surface.
      * @see MultiTerm
      */
     public MultiTermToken (char prefix, String surface) {
@@ -67,32 +73,35 @@
             MultiTerm term = new MultiTerm(prefix, surface);
 
             // First word element
-            terms.add( term );
+            terms.add(term);
         }
         catch (CorpusDataException cde) {
             log.error("{}: {}", cde.getErrorCode(), cde.getMessage());
         };
     };
-    
+
 
     /**
      * Construct a new MultiTermToken by passing a stream of
      * {@link MultiTerm MultiTerms} represented as strings.
-     *
-     * @param terms Take at least one {@link MultiTerm} string for a token.
+     * 
+     * @param terms
+     *            Take at least one {@link MultiTerm} string for a
+     *            token.
      */
-    public MultiTermToken (String terms, String ... moreTerms) throws CorpusDataException {
+    public MultiTermToken (String terms, String ... moreTerms)
+            throws CorpusDataException {
         this.terms = new ArrayList<MultiTerm>(16);
 
         MultiTerm term = new MultiTerm(terms);
 
         try {
             // First word element
-            this.terms.add( term );
+            this.terms.add(term);
 
             // Further elements on same position
             for (i = 0; i < moreTerms.length; i++) {
-                term = new MultiTerm( moreTerms[i] );
+                term = new MultiTerm(moreTerms[i]);
                 this.terms.add(term);
             };
         }
@@ -101,11 +110,12 @@
         };
     };
 
-    
+
     /**
      * Add a new {@link MultiTerm} to the MultiTermToken.
-     *
-     * @param term A {@link MultiTerm} object.
+     * 
+     * @param term
+     *            A {@link MultiTerm} object.
      * @return The {@link MultiTermToken} object for chaining.
      */
     public MultiTermToken add (MultiTerm term) {
@@ -117,8 +127,9 @@
 
     /**
      * Add a new {@link MultiTerm} to the MultiTermToken.
-     *
-     * @param term A MultiTerm represented as a surface string.
+     * 
+     * @param term
+     *            A MultiTerm represented as a surface string.
      * @return The {@link MultiTermToken} object for chaining.
      */
     public MultiTermToken add (String term) throws CorpusDataException {
@@ -138,9 +149,11 @@
 
     /**
      * Add a new {@link MultiTerm} to the MultiTermToken.
-     *
-     * @param prefix A MultiTerm prefix.
-     * @param term A MultiTerm represented as a surface string.
+     * 
+     * @param prefix
+     *            A MultiTerm prefix.
+     * @param term
+     *            A MultiTerm represented as a surface string.
      * @return The {@link MultiTermToken} object for chaining.
      */
     public MultiTermToken add (char prefix, String term) {
@@ -160,9 +173,10 @@
 
     /**
      * Get a {@link MultiTerm} by index.
-     *
-     * @param index The index position of a {@link MultiTerm}
-     *        in the {@link MultiTermToken}.
+     * 
+     * @param index
+     *            The index position of a {@link MultiTerm} in the
+     *            {@link MultiTermToken}.
      * @return A {@link MultiTerm}.
      */
     public MultiTerm get (int index) {
@@ -171,11 +185,11 @@
 
 
     /**
-     * Get the number of {@link MultiTerm MultiTerms}
-     * in the MultiTermToken.
-     *
-     * @return The number of {@link MultiTerm MultiTerms}
-     *         in the MultiTermToken.
+     * Get the number of {@link MultiTerm MultiTerms} in the
+     * MultiTermToken.
+     * 
+     * @return The number of {@link MultiTerm MultiTerms} in the
+     *         MultiTermToken.
      */
     public int getSize () {
         return this.terms.size();
@@ -184,7 +198,7 @@
 
     /**
      * Sort the {@link MultiTerm MultiTerms} in the correct order.
-     *
+     * 
      * @return The {@link MultiTermToken} object for chaining.
      */
     public MultiTermToken sort () {
@@ -199,7 +213,7 @@
 
     /**
      * Serialize the MultiTermToken to a string.
-     *
+     * 
      * @return A string representation of the MultiTermToken,
      *         with leading offset information.
      */
@@ -211,7 +225,7 @@
             sb.append(this.terms.get(i).toString()).append('|');
         };
         sb.append(this.terms.get(i).toString()).append(']');
-        
+
         return sb.toString();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java b/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
index bae942a..de974c3 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
@@ -26,15 +26,15 @@
  */
 
 /**
- * MultiTermTokenStream extends Lucenes {@link TokenStream}
- * to work with {@link MultiTermToken MultiTermTokens}.
- *
+ * MultiTermTokenStream extends Lucenes {@link TokenStream} to work
+ * with {@link MultiTermToken MultiTermTokens}.
+ * 
  * <blockquote><pre>
- *   MultiTermTokenStream mtts = new MultiTermTokenStream(
- *       "[s:den#0-3|i:den|p:DET|l:der|m:c:acc|m:n:sg|m:masc]"
- *   );
+ * MultiTermTokenStream mtts = new MultiTermTokenStream(
+ * "[s:den#0-3|i:den|p:DET|l:der|m:c:acc|m:n:sg|m:masc]"
+ * );
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  * @see TokenStream
  */
@@ -43,33 +43,35 @@
     private PositionIncrementAttribute posIncrAttr;
     private PayloadAttribute payloadAttr;
 
-    private static final Pattern pattern =
-        Pattern.compile("\\[(?:\\([0-9]+-[0-9]+\\))?([^\\]]+?)\\]");
+    private static final Pattern pattern = Pattern
+            .compile("\\[(?:\\([0-9]+-[0-9]+\\))?([^\\]]+?)\\]");
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
-    private final Logger log = LoggerFactory.getLogger(MultiTermTokenStream.class);
+    private final Logger log = LoggerFactory
+            .getLogger(MultiTermTokenStream.class);
 
     private List<MultiTermToken> multiTermTokens;
-    private int mttIndex   = 0,
-                mtIndex    = 0;
+    private int mttIndex = 0, mtIndex = 0;
     private short i = 0;
 
+
     /**
      * Construct a new MultiTermTokenStream object.
      */
     public MultiTermTokenStream () {
-        this.charTermAttr    = this.addAttribute(CharTermAttribute.class);
-        this.posIncrAttr     = this.addAttribute(PositionIncrementAttribute.class);
-        this.payloadAttr     = this.addAttribute(PayloadAttribute.class);
+        this.charTermAttr = this.addAttribute(CharTermAttribute.class);
+        this.posIncrAttr = this.addAttribute(PositionIncrementAttribute.class);
+        this.payloadAttr = this.addAttribute(PayloadAttribute.class);
         this.multiTermTokens = new ArrayList<MultiTermToken>(100);
     };
 
 
     /**
      * Construct a new MultiTermTokenStream object
-     *
-     * @param stream The stream as a string representation.
+     * 
+     * @param stream
+     *            The stream as a string representation.
      */
     public MultiTermTokenStream (String stream) {
         this();
@@ -85,13 +87,14 @@
 
     /**
      * Construct a new MultiTermTokenStream object
-     *
-     * @param stream The stream as a {@link Reader} object.
+     * 
+     * @param stream
+     *            The stream as a {@link Reader} object.
      * @throws IOException
      */
     public MultiTermTokenStream (Reader stream) throws IOException {
         this();
-	
+
         StringBuilder sb = new StringBuilder(4096);
         char[] buf = new char[128];
 
@@ -111,8 +114,9 @@
 
     /**
      * Append a {@link MultiTermToken} to the MultiTermTokenStream.
-     *
-     * @param mtt A {@link MultiTermToken}.
+     * 
+     * @param mtt
+     *            A {@link MultiTermToken}.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMultiTermToken (MultiTermToken mtt) {
@@ -124,12 +128,13 @@
     /**
      * Append a {@link MultiTermToken} to the MultiTermTokenStream
      * by means of a set of {@link MultiTerm MultiTerms}.
-     *
-     * @param mts A list of {@link MultiTerm} objects.
+     * 
+     * @param mts
+     *            A list of {@link MultiTerm} objects.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public MultiTermTokenStream addMultiTermToken
-        (MultiTerm mts, MultiTerm ... moreTerms) {
+    public MultiTermTokenStream addMultiTermToken (MultiTerm mts,
+            MultiTerm ... moreTerms) {
         return this.addMultiTermToken(new MultiTermToken(mts, moreTerms));
     };
 
@@ -137,9 +142,12 @@
     /**
      * Append a {@link MultiTermToken} to the MultiTermTokenStream
      * by means of a single {@link MultiTerm} as a prefixed term.
-     *
-     * @param prefix A prefix character of a surface form of a {@link MultiTerm}.
-     * @param surface A surface string of a {@link MultiTerm}.
+     * 
+     * @param prefix
+     *            A prefix character of a surface form of a
+     *            {@link MultiTerm}.
+     * @param surface
+     *            A surface string of a {@link MultiTerm}.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMultiTermToken (char prefix, String surface) {
@@ -151,12 +159,13 @@
      * Append a {@link MultiTermToken} to the MultiTermTokenStream
      * by means of {@link MultiTerm MultiTerm} represented as a set
      * of terms represented as strings.
-     *
-     * @param surface At least one surface string of a {@link MultiTerm}.
+     * 
+     * @param surface
+     *            At least one surface string of a {@link MultiTerm}.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public MultiTermTokenStream addMultiTermToken
-        (String surface, String ... moreTerms) {
+    public MultiTermTokenStream addMultiTermToken (String surface,
+            String ... moreTerms) {
         try {
             this.addMultiTermToken(new MultiTermToken(surface, moreTerms));
         }
@@ -168,14 +177,15 @@
 
 
 
-
     /**
      * Add meta information to the MultiTermTokenStream.
-     *
+     * 
      * <strong>This is experimental!</strong>
-     *
-     * @param key A string for denoting the meta information.
-     * @param value The value of the meta key as a string.
+     * 
+     * @param key
+     *            A string for denoting the meta information.
+     * @param value
+     *            The value of the meta key as a string.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMeta (String key, String value) {
@@ -193,11 +203,13 @@
 
     /**
      * Add meta information to the MultiTermTokenStream.
-     *
+     * 
      * <strong>This is experimental!</strong>
-     *
-     * @param key A string for denoting the meta information.
-     * @param value The value of the meta key as a byte array.
+     * 
+     * @param key
+     *            A string for denoting the meta information.
+     * @param value
+     *            The value of the meta key as a byte array.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMeta (String key, byte[] value) {
@@ -215,11 +227,13 @@
 
     /**
      * Add meta information to the MultiTermTokenStream.
-     *
+     * 
      * <strong>This is experimental!</strong>
-     *
-     * @param key A string for denoting the meta information.
-     * @param value The value of the meta key as a short value.
+     * 
+     * @param key
+     *            A string for denoting the meta information.
+     * @param value
+     *            The value of the meta key as a short value.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMeta (String key, short value) {
@@ -237,11 +251,13 @@
 
     /**
      * Add meta information to the MultiTermTokenStream.
-     *
+     * 
      * <strong>This is experimental!</strong>
-     *
-     * @param key A string for denoting the meta information.
-     * @param value The value of the meta key as a long value.
+     * 
+     * @param key
+     *            A string for denoting the meta information.
+     * @param value
+     *            The value of the meta key as a long value.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMeta (String key, long value) {
@@ -259,11 +275,13 @@
 
     /**
      * Add meta information to the MultiTermTokenStream.
-     *
+     * 
      * <strong>This is experimental!</strong>
-     *
-     * @param key A string for denoting the meta information.
-     * @param value The value of the meta key as a integer value.
+     * 
+     * @param key
+     *            A string for denoting the meta information.
+     * @param value
+     *            The value of the meta key as a integer value.
      * @return The {@link MultiTermTokenStream} object for chaining.
      */
     public MultiTermTokenStream addMeta (String key, int value) {
@@ -282,9 +300,10 @@
 
     /**
      * Get a {@link MultiTermToken} by index.
-     *
-     * @param index The index position of a {@link MultiTermToken}
-     *        in the {@link MultiTermTokenStream}.
+     * 
+     * @param index
+     *            The index position of a {@link MultiTermToken} in
+     *            the {@link MultiTermTokenStream}.
      * @return A {@link MultiTermToken}.
      */
     public MultiTermToken get (int index) {
@@ -293,11 +312,11 @@
 
 
     /**
-     * Get the number of {@link MultiTermToken MultiTermTokens}
-     * in the stream.
-     *
-     * @return The number of {@link MultiTermToken MultiTermTokens}
-     *         in the stream.
+     * Get the number of {@link MultiTermToken MultiTermTokens} in the
+     * stream.
+     * 
+     * @return The number of {@link MultiTermToken MultiTermTokens} in
+     *         the stream.
      */
     public int getSize () {
         return this.multiTermTokens.size();
@@ -306,13 +325,13 @@
 
     /**
      * Serialize the MultiTermTokenStream to a string.
-     *
+     * 
      * @return The MultiTermTokenStream as a string.
      */
     public String toString () {
         StringBuffer sb = new StringBuffer();
         for (MultiTermToken mtt : this.multiTermTokens) {
-            sb.append( mtt.toString() );
+            sb.append(mtt.toString());
         };
         return sb.toString();
     };
@@ -324,7 +343,7 @@
 
         while (matcher.find()) {
             String[] seg = matcher.group(1).split("\\|");
-            MultiTermToken mtt = new MultiTermToken( seg[0] );
+            MultiTermToken mtt = new MultiTermToken(seg[0]);
 
             for (i = 1; i < seg.length; i++)
                 mtt.add(seg[i]);
@@ -349,7 +368,7 @@
         };
 
         // Get current token
-        MultiTermToken mtt = this.multiTermTokens.get( this.mttIndex );
+        MultiTermToken mtt = this.multiTermTokens.get(this.mttIndex);
 
         // Sort the MultiTermToken
         mtt.sort();
@@ -367,7 +386,7 @@
 
             // Get last token
             else {
-                mtt = this.multiTermTokens.get( this.mttIndex );
+                mtt = this.multiTermTokens.get(this.mttIndex);
             };
         };
 
@@ -375,16 +394,17 @@
         MultiTerm mt = mtt.terms.get(this.mtIndex);
 
         // Set the relative position to the former term
-        posIncrAttr.setPositionIncrement( this.mtIndex == 0 ? 1 : 0 );
+        posIncrAttr.setPositionIncrement(this.mtIndex == 0 ? 1 : 0);
         charTermAttr.setEmpty();
-        charTermAttr.append( mt.term );
+        charTermAttr.append(mt.term);
 
         BytesRef payload = new BytesRef();
 
         // There is offset information
         if (mt.start != mt.end) {
             if (DEBUG)
-                log.trace("MultiTerm with payload offset: {}-{}", mt.start, mt.end);
+                log.trace("MultiTerm with payload offset: {}-{}", mt.start,
+                        mt.end);
 
             // Add offsets to BytesRef payload
             payload.append(new BytesRef(int2byte(mt.start)));
@@ -397,7 +417,7 @@
             if (DEBUG)
                 log.trace("Create payload[1] {}", payload.toString());
         };
-        
+
         // There is payload in the current token to index
         if (payload.length > 0) {
             payloadAttr.setPayload(payload);
@@ -413,7 +433,7 @@
                 sb.append('$').append(payload.toString());
             sb.append(']');
             sb.append(" with increment ").append(this.mtIndex == 0 ? 1 : 0);
-            
+
             log.trace(sb.toString());
         };
 
@@ -421,9 +441,10 @@
         return true;
     };
 
+
     @Override
     public void reset () {
         this.mttIndex = 0;
-        this.mtIndex  = 0;
+        this.mtIndex = 0;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
index 3bd0d74..0440286 100644
--- a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
+++ b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
@@ -20,235 +20,239 @@
     private AtomicReaderContext atomic;
     private boolean processed = false;
     private Integer[] pair;
-    private static ByteBuffer bbOffset =
-	ByteBuffer.allocate(8);
+    private static ByteBuffer bbOffset = ByteBuffer.allocate(8);
 
     HashSet<PositionsToOffsetArray> positions;
     HashMap<PositionsToOffsetArray, Integer[]> offsets;
 
-    private final static Logger log =
-	LoggerFactory.getLogger(PositionsToOffset.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(PositionsToOffset.class);
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
 
     private class PositionsToOffsetArray {
-	public int docID;
-	public int pos;
-   
-	public PositionsToOffsetArray (int docID, int pos) {
-	    this.docID = docID;
-	    this.pos = pos;
-	};
+        public int docID;
+        public int pos;
 
-	public int hashCode(){
-	    long hashCode;
-	    hashCode = (docID * Integer.MAX_VALUE) - Integer.MAX_VALUE + pos;
-	    return new Long(hashCode).hashCode();
-	};
-     
-	public boolean equals(Object obj){
-	    if (obj instanceof PositionsToOffsetArray) {
-		PositionsToOffsetArray ptoa = (PositionsToOffsetArray) obj;
-		return (ptoa.docID == this.docID && ptoa.pos == this.pos);
-	    };
-	    return false;
-	};
+
+        public PositionsToOffsetArray (int docID, int pos) {
+            this.docID = docID;
+            this.pos = pos;
+        };
+
+
+        public int hashCode () {
+            long hashCode;
+            hashCode = (docID * Integer.MAX_VALUE) - Integer.MAX_VALUE + pos;
+            return new Long(hashCode).hashCode();
+        };
+
+
+        public boolean equals (Object obj) {
+            if (obj instanceof PositionsToOffsetArray) {
+                PositionsToOffsetArray ptoa = (PositionsToOffsetArray) obj;
+                return (ptoa.docID == this.docID && ptoa.pos == this.pos);
+            };
+            return false;
+        };
     };
 
+
     public PositionsToOffset (AtomicReaderContext atomic, String field) {
-	this.field = field;
-	this.atomic = atomic;
-	this.positions = new HashSet<>(64);
-	this.offsets = new HashMap<>(64);
+        this.field = field;
+        this.atomic = atomic;
+        this.positions = new HashSet<>(64);
+        this.offsets = new HashMap<>(64);
     };
 
+
     public void clear () {
-	this.positions.clear();
-	this.offsets.clear();
-	this.bbOffset.clear();
-	this.processed = false;
+        this.positions.clear();
+        this.offsets.clear();
+        this.bbOffset.clear();
+        this.processed = false;
     };
 
+
     public void add (int docID, int pos) {
-	this.add(new PositionsToOffsetArray(docID, pos));
+        this.add(new PositionsToOffsetArray(docID, pos));
     };
 
+
     public void add (PositionsToOffsetArray ptoa) {
-	if (DEBUG)
-	    log.trace("Add positionsToOffsetArray {}/{}", ptoa.docID, ptoa.pos);
-	if (ptoa.pos < 0)
-	    return;
+        if (DEBUG)
+            log.trace("Add positionsToOffsetArray {}/{}", ptoa.docID, ptoa.pos);
+        if (ptoa.pos < 0)
+            return;
 
-	if (this.processed && this.exists(ptoa))
-	    return;
+        if (this.processed && this.exists(ptoa))
+            return;
 
-	if (DEBUG)
-	    log.trace("Reopen processing");
+        if (DEBUG)
+            log.trace("Reopen processing");
 
-	this.positions.add(ptoa);
-	this.processed = false;
+        this.positions.add(ptoa);
+        this.processed = false;
     };
 
+
     public boolean exists (int docID, int pos) {
-	return this.offsets.containsKey(new PositionsToOffsetArray(docID, pos));
+        return this.offsets.containsKey(new PositionsToOffsetArray(docID, pos));
     };
 
+
     public boolean exists (PositionsToOffsetArray ptoa) {
-	return this.offsets.containsKey(ptoa);
+        return this.offsets.containsKey(ptoa);
     };
 
+
     public int start (int docID, int pos) {
-	return this.start(new PositionsToOffsetArray(docID, pos));
+        return this.start(new PositionsToOffsetArray(docID, pos));
     };
 
+
     public int start (PositionsToOffsetArray ptoa) {
-	if (ptoa.pos < 0)
-	    return 0;
+        if (ptoa.pos < 0)
+            return 0;
 
-	if (!processed)
-	    this.offsets();
+        if (!processed)
+            this.offsets();
 
-	Integer[] pair = this.offsets.get(ptoa);
+        Integer[] pair = this.offsets.get(ptoa);
 
-	if (pair == null)
-	    return 0;
+        if (pair == null)
+            return 0;
 
-	return pair[0];
+        return pair[0];
     };
 
+
     public int end (int docID, int pos) {
-	return this.end(new PositionsToOffsetArray(docID, pos));
+        return this.end(new PositionsToOffsetArray(docID, pos));
     };
 
+
     public int end (PositionsToOffsetArray ptoa) {
-	if (ptoa.pos < 0)
-	    return -1;
+        if (ptoa.pos < 0)
+            return -1;
 
-	if (!processed)
-	    this.offsets();
+        if (!processed)
+            this.offsets();
 
-	Integer[] pair = this.offsets.get(ptoa);
-	if (pair == null)
-	    return -1;
+        Integer[] pair = this.offsets.get(ptoa);
+        if (pair == null)
+            return -1;
 
-	return  pair[1];
+        return pair[1];
     };
 
+
     public Integer[] span (int docID, int pos) {
-	return this.span(new PositionsToOffsetArray(docID, pos));
+        return this.span(new PositionsToOffsetArray(docID, pos));
     };
 
+
     public Integer[] span (PositionsToOffsetArray ptoa) {
-	if (!processed)
-	    this.offsets();
-	return this.offsets.get(ptoa);
+        if (!processed)
+            this.offsets();
+        return this.offsets.get(ptoa);
     };
 
-    public void addOffset (int docID,
-			   int pos,
-			   int startOffset,
-			   int endOffset) {
-	offsets.put(
-	    new PositionsToOffsetArray(docID, pos),
-            new Integer[]{startOffset, endOffset}
-	);
+
+    public void addOffset (int docID, int pos, int startOffset, int endOffset) {
+        offsets.put(new PositionsToOffsetArray(docID, pos), new Integer[] {
+                startOffset, endOffset });
     };
 
+
     public HashMap<PositionsToOffsetArray, Integer[]> offsets () {
-	if (processed)
-	    return offsets;
+        if (processed)
+            return offsets;
 
-	if (DEBUG)
-	    log.trace("Process offsets");
+        if (DEBUG)
+            log.trace("Process offsets");
 
-	StringBuilder sb = new StringBuilder().append('_');
+        StringBuilder sb = new StringBuilder().append('_');
 
-	try {
-	    Terms terms = atomic.reader().fields().terms(field);
+        try {
+            Terms terms = atomic.reader().fields().terms(field);
 
-	    if (terms != null) {
-		// TODO: Maybe reuse a termsEnum!
+            if (terms != null) {
+                // TODO: Maybe reuse a termsEnum!
 
-		final TermsEnum termsEnum = terms.iterator(null);
+                final TermsEnum termsEnum = terms.iterator(null);
 
-		for (PositionsToOffsetArray posDoc : positions) {
-		    if (this.exists(posDoc))
-			continue;
+                for (PositionsToOffsetArray posDoc : positions) {
+                    if (this.exists(posDoc))
+                        continue;
 
-		    int docID = posDoc.docID;
+                    int docID = posDoc.docID;
 
-		    /*
-		    int pos = posDoc[1];
-		    Integer[] posDoc2 = new Integer[2];
-		    posDoc2[0] = docID;
-		    posDoc2[1] = pos;
-		    */
+                    /*
+                    int pos = posDoc[1];
+                    Integer[] posDoc2 = new Integer[2];
+                    posDoc2[0] = docID;
+                    posDoc2[1] = pos;
+                    */
 
-		    sb.append(posDoc.pos);
+                    sb.append(posDoc.pos);
 
-		    Term term = new Term(field, sb.toString());
-		    sb.setLength(1);
-		    
-		    // Set the position in the iterator to the term that is seeked
-		    if (termsEnum.seekExact(term.bytes())) {
-			
-			if (DEBUG)
-			    log.trace("Search for {} in doc {} with pos {}",
-				      term.toString(),
-				      posDoc.docID,
-				      posDoc.pos);
+                    Term term = new Term(field, sb.toString());
+                    sb.setLength(1);
 
-			// Start an iterator to fetch all payloads of the term
-			DocsAndPositionsEnum docs = termsEnum.docsAndPositions(
-                            null,
-			    null,
-			    DocsAndPositionsEnum.FLAG_PAYLOADS
-		        );
+                    // Set the position in the iterator to the term that is seeked
+                    if (termsEnum.seekExact(term.bytes())) {
 
-			if (docs.advance(docID) == docID) {
-			    docs.nextPosition();
+                        if (DEBUG)
+                            log.trace("Search for {} in doc {} with pos {}",
+                                    term.toString(), posDoc.docID, posDoc.pos);
 
-			    BytesRef payload = docs.getPayload();
+                        // Start an iterator to fetch all payloads of the term
+                        DocsAndPositionsEnum docs = termsEnum.docsAndPositions(
+                                null, null, DocsAndPositionsEnum.FLAG_PAYLOADS);
 
-			    if (payload.length == 8) {
-				bbOffset.clear();
-				bbOffset.put(payload.bytes, payload.offset, 8);
-				bbOffset.rewind();
-				Integer[] offsetArray = new Integer[2];
-				offsetArray[0] = bbOffset.getInt();
-				offsetArray[1] = bbOffset.getInt();
-				offsets.put(posDoc, offsetArray);
+                        if (docs.advance(docID) == docID) {
+                            docs.nextPosition();
 
-				if (DEBUG)
-				    log.trace("Found {}-{} for {}",
-					      offsetArray[0],
-					      offsetArray[1],
-					      term.toString());
-			    }
+                            BytesRef payload = docs.getPayload();
 
-			    else {
-				log.error(
-				    "Doc {} has no offsets stored for {}",
-				    docID,
-				    term.toString()
-				);
-			    };
-			};
-		    };
-		};
-	    };
-	}
-	catch (IOException e) {
-	    log.warn(e.getLocalizedMessage());
-	};
+                            if (payload.length == 8) {
+                                bbOffset.clear();
+                                bbOffset.put(payload.bytes, payload.offset, 8);
+                                bbOffset.rewind();
+                                Integer[] offsetArray = new Integer[2];
+                                offsetArray[0] = bbOffset.getInt();
+                                offsetArray[1] = bbOffset.getInt();
+                                offsets.put(posDoc, offsetArray);
 
-	processed = true;
-	positions.clear();
-	return offsets;
+                                if (DEBUG)
+                                    log.trace("Found {}-{} for {}",
+                                            offsetArray[0], offsetArray[1],
+                                            term.toString());
+                            }
+
+                            else {
+                                log.error(
+                                        "Doc {} has no offsets stored for {}",
+                                        docID, term.toString());
+                            };
+                        };
+                    };
+                };
+            };
+        }
+        catch (IOException e) {
+            log.warn(e.getLocalizedMessage());
+        };
+
+        processed = true;
+        positions.clear();
+        return offsets;
     };
 
+
     public AtomicReaderContext getAtomicReader () {
-	return this.atomic;
+        return this.atomic;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java b/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
index b8d5ea5..5c797ce 100644
--- a/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/SpanInfo.java
@@ -1,9 +1,9 @@
 package de.ids_mannheim.korap.index;
+
 import de.ids_mannheim.korap.index.TermInfo;
 import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.index.PositionsToOffset;
 
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -11,7 +11,7 @@
 
 public class SpanInfo {
     ArrayList<TermInfo> terms;
-    HashMap<Integer,Integer> startChar, endChar;
+    HashMap<Integer, Integer> startChar, endChar;
     PositionsToOffset pto;
     int localDocID;
 
@@ -20,14 +20,16 @@
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
 
+
     public SpanInfo (PositionsToOffset pto, int localDocID) {
-        this.terms      = new ArrayList<TermInfo>(64);
-        this.startChar  = new HashMap<Integer,Integer>(16);
-        this.endChar    = new HashMap<Integer,Integer>(16);
-        this.pto        = pto;
+        this.terms = new ArrayList<TermInfo>(64);
+        this.startChar = new HashMap<Integer, Integer>(16);
+        this.endChar = new HashMap<Integer, Integer>(16);
+        this.pto = pto;
         this.localDocID = localDocID;
     };
 
+
     public void add (TermInfo info) {
         info.analyze();
         if (info.getType() != "pos") {
@@ -39,6 +41,7 @@
         };
     };
 
+
     public ArrayList<TermInfo> getTerms () {
         // Sort terms (this will also analyze them!)
         Collections.sort(this.terms);
@@ -48,7 +51,8 @@
         // missing this information
         for (TermInfo t : this.terms) {
             if (DEBUG)
-                log.trace("Check offsets for {} and {}", t.getStartPos(), t.getEndPos());
+                log.trace("Check offsets for {} and {}", t.getStartPos(),
+                        t.getEndPos());
             found = true;
             if (t.getStartChar() == -1) {
                 if (this.startChar.containsKey(t.getStartPos()))
@@ -62,15 +66,11 @@
                 else
                     found = false;
             };
-            
+
             // Add this to found offsets
             if (found && t.getStartPos() == t.getEndPos())
-                this.pto.addOffset(
-                    this.localDocID,
-                    t.getStartPos(),
-                    t.getStartChar(),
-                    t.getEndChar()
-                );
+                this.pto.addOffset(this.localDocID, t.getStartPos(),
+                        t.getStartChar(), t.getEndChar());
             else {
                 if (DEBUG)
                     log.trace("{} can't be found!", t.getAnnotation());
diff --git a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
index 2835be3..6354f82 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TermInfo.java
@@ -24,23 +24,23 @@
     private ByteBuffer payload;
     private boolean analyzed = false;
 
-    private int startChar = -1,
-        endChar   = -1,
-        startPos  = -1,
-        endPos    = -1;
+    private int startChar = -1, endChar = -1, startPos = -1, endPos = -1;
 
     private byte depth = (byte) 0;
-    
-    private Pattern prefixRegex = Pattern.compile("(?:([^/]+)/)?([^:/]+)(?::(.+?))?");
+
+    private Pattern prefixRegex = Pattern
+            .compile("(?:([^/]+)/)?([^:/]+)(?::(.+?))?");
     private Matcher matcher;
 
+
     public TermInfo (String term, int pos, ByteBuffer payload) {
-        this.term     = term;
+        this.term = term;
         this.startPos = pos;
-        this.endPos   = pos;
-        this.payload  = payload;
+        this.endPos = pos;
+        this.payload = payload;
     };
 
+
     public TermInfo analyze () {
         if (analyzed)
             return this;
@@ -51,39 +51,40 @@
         this.payload.rewind();
 
         switch (tterm.charAt(0)) {
-        case '<':
-            // "<>:mate/l:..."
-            if (tterm.charAt(1) == '>') {
-                // span
-                this.type = "span";
-                tterm = tterm.substring(3);
-                ttype = 2;
-            }
-            // rel-target
-            else {
-                this.type = "relTarget";
+            case '<':
+                // "<>:mate/l:..."
+                if (tterm.charAt(1) == '>') {
+                    // span
+                    this.type = "span";
+                    tterm = tterm.substring(3);
+                    ttype = 2;
+                }
+                // rel-target
+                else {
+                    this.type = "relTarget";
+                    tterm = tterm.substring(2);
+                    ttype = 3;
+                }
+                ;
+                break;
+
+            case '>':
+                // rel-src
+                this.type = "relSrc";
                 tterm = tterm.substring(2);
                 ttype = 3;
-            };
-            break;
+                break;
 
-        case '>':
-            // rel-src
-            this.type = "relSrc";
-            tterm = tterm.substring(2);
-            ttype = 3;
-            break;
-            
-        case '_':
-            // pos
-            this.type = "pos";
-            ttype = 1;
-            tterm = tterm.substring(1);
-            break;
+            case '_':
+                // pos
+                this.type = "pos";
+                ttype = 1;
+                tterm = tterm.substring(1);
+                break;
 
-        default:
-            // term
-            this.type = "term";
+            default:
+                // term
+                this.type = "term";
         };
 
         // Analyze term value
@@ -97,8 +98,8 @@
                     this.foundry = matcher.group(1);
                 else
                     this.foundry = "base";
-                this.layer   = matcher.group(2);
-                this.value   = matcher.group(3);
+                this.layer = matcher.group(2);
+                this.value = matcher.group(3);
             };
         }
 
@@ -106,77 +107,90 @@
         else {
             this.value = tterm;
             this.startChar = this.payload.getInt();
-            this.endChar   = this.payload.getInt();
+            this.endChar = this.payload.getInt();
         };
-        
+
         // for spans
         if (ttype == 2) {
             this.startChar = this.payload.getInt();
-            this.endChar   = this.payload.getInt();
+            this.endChar = this.payload.getInt();
         };
 
         // for spans and relations
         if (ttype > 1)
             // Unsure if this is correct
-            this.endPos = this.payload.getInt() -1;
-        
+            this.endPos = this.payload.getInt() - 1;
+
         if (ttype == 2 && this.payload.position() < lastPos) {
             this.depth = this.payload.get();
         };
-        
+
         // payloads can have different meaning
         analyzed = true;
         return this;
     };
 
+
     public String getType () {
         return this.type;
     };
 
+
     public int getStartChar () {
         return this.startChar;
     };
 
+
     public void setStartChar (int pos) {
         this.startChar = pos;
     };
 
+
     public int getEndChar () {
         return this.endChar;
     };
 
+
     public void setEndChar (int pos) {
         this.endChar = pos;
     };
 
+
     public int getStartPos () {
         return this.startPos;
     };
 
+
     public int getEndPos () {
         return this.endPos;
     };
 
+
     public byte getDepth () {
         return this.depth;
     };
 
+
     public String getFoundry () {
         return this.foundry;
     };
 
+
     public String getLayer () {
         return this.layer;
     };
 
+
     public String getValue () {
         return this.value;
     };
 
+
     public String getAnnotation () {
         return this.annotation;
     };
 
+
     public String toString () {
         this.analyze();
 
@@ -198,6 +212,7 @@
         return sb.toString();
     };
 
+
     @Override
     public int compareTo (TermInfo obj) {
         this.analyze();
diff --git a/src/main/java/de/ids_mannheim/korap/index/TimeOutThread.java b/src/main/java/de/ids_mannheim/korap/index/TimeOutThread.java
index df24db1..ae09567 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TimeOutThread.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TimeOutThread.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.index;
+
 import org.apache.lucene.util.Counter;
 import java.lang.*;
 import java.lang.InterruptedException.*;
@@ -14,31 +15,35 @@
     private volatile boolean stop = false;
     private Counter counter;
 
+
     public TimeOutThread () {
-	super("TimeOutThread");
-	counter = Counter.newCounter(true);
+        super("TimeOutThread");
+        counter = Counter.newCounter(true);
     };
 
+
     @Override
-    public void run() {
-	while (!stop) {
-	    counter.addAndGet(resolution);
-	    try {
-		Thread.sleep( resolution );
-	    }
-	    catch (InterruptedException ie) {
-		throw new ThreadInterruptedException(ie);
-	    };
-	};
+    public void run () {
+        while (!stop) {
+            counter.addAndGet(resolution);
+            try {
+                Thread.sleep(resolution);
+            }
+            catch (InterruptedException ie) {
+                throw new ThreadInterruptedException(ie);
+            };
+        };
     };
 
+
     // Get miliseconds
     public long getTime () {
-	return counter.get();
+        return counter.get();
     };
-	
+
+
     // Stops the timer thread 
     public void stopTimer () {
-	stop = true;
+        stop = true;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/DistanceConstraint.java b/src/main/java/de/ids_mannheim/korap/query/DistanceConstraint.java
index 806384f..7a87bdd 100644
--- a/src/main/java/de/ids_mannheim/korap/query/DistanceConstraint.java
+++ b/src/main/java/de/ids_mannheim/korap/query/DistanceConstraint.java
@@ -4,13 +4,15 @@
  * DistanceConstraint specifies the constraints used in
  * {@link SpanDistanceQuery SpanDistanceQueries} or
  * {@link SpanMultipleDistanceQuery SpanMultipleDistanceQueries}. The
- * constraints comprise the distance unit, the minimum and maximum distances,
+ * constraints comprise the distance unit, the minimum and maximum
+ * distances,
  * the order and the co-occurence of the compared spans.
  * 
  * Distance constraint examples:
  * 
  * <ol>
- * <li>Two terms x and y are separated by minimum two and maximum three other
+ * <li>Two terms x and y are separated by minimum two and maximum
+ * three other
  * words. The order of x and y does not matter.
  * 
  * <pre>
@@ -18,7 +20,8 @@
  * </pre>
  * 
  * </li>
- * <li>Two terms x and y are separated by minimum two and maximum three other
+ * <li>Two terms x and y are separated by minimum two and maximum
+ * three other
  * words. X must precede y.
  * 
  * <pre>
@@ -27,7 +30,8 @@
  * 
  * </li>
  * <li>
- * Term x do not occur with term y in minimum two and maximum three other words.
+ * Term x do not occur with term y in minimum two and maximum three
+ * other words.
  * X must precede y.
  * 
  * <pre>
@@ -39,8 +43,10 @@
  * <em>sentences</em>. X must precede y.
  * 
  * <pre>
- * SpanElementQuery e = new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
- * DistanceConstraint dc = new DistanceConstraint(e, 2, 3, true, false);
+ * SpanElementQuery e = new SpanElementQuery(&quot;tokens&quot;,
+ * &quot;s&quot;);
+ * DistanceConstraint dc = new DistanceConstraint(e, 2, 3, true,
+ * false);
  * </pre>
  * 
  * </li>
@@ -56,22 +62,33 @@
     private boolean exclusion;
     private boolean isOrdered;
 
+
     /**
-     * Constructs a DistanceConstraint object with the specified minimum and
-     * maximum distances. If isOrdered is true, the spans must occur in order.
-     * If exclusion is true, the second span must <em>not</em> occur together
+     * Constructs a DistanceConstraint object with the specified
+     * minimum and
+     * maximum distances. If isOrdered is true, the spans must occur
+     * in order.
+     * If exclusion is true, the second span must <em>not</em> occur
+     * together
      * with the first span.
      * 
-     * @param min the minimum distance
-     * @param max the maximum distance
-     * @param isOrdered a boolean flag representing the value <code>true</code>
-     *        if the spans should occur in order, false otherwise.
-     * @param exclusion a boolean flag representing the value <code>true</code>,
-     *        if the second span should occur together with the first span,
-     *        false otherwise.
+     * @param min
+     *            the minimum distance
+     * @param max
+     *            the maximum distance
+     * @param isOrdered
+     *            a boolean flag representing the value
+     *            <code>true</code>
+     *            if the spans should occur in order, false otherwise.
+     * @param exclusion
+     *            a boolean flag representing the value
+     *            <code>true</code>,
+     *            if the second span should occur together with the
+     *            first span,
+     *            false otherwise.
      */
-    public DistanceConstraint(int min, int max, boolean isOrdered,
-            boolean exclusion) {
+    public DistanceConstraint (int min, int max, boolean isOrdered,
+                               boolean exclusion) {
         this.unit = "w";
         this.minDistance = min;
         this.maxDistance = max;
@@ -79,24 +96,36 @@
         this.exclusion = exclusion;
     }
 
+
     /**
-     * Constructs a DistanceContraint object with the specified SpanElementQuery
+     * Constructs a DistanceContraint object with the specified
+     * SpanElementQuery
      * as the distance unit, and the specified minimum and the maximum
-     * distances. If isOrdered is true, the spans must occur in order. If
-     * exclusion is true, the second span must <em>not</em> occur together with
+     * distances. If isOrdered is true, the spans must occur in order.
+     * If
+     * exclusion is true, the second span must <em>not</em> occur
+     * together with
      * the first span.
      * 
-     * @param elementQuery the distance unit
-     * @param min the minimum distance
-     * @param max the maximum distance
-     * @param isOrdered a boolean flag representing the value <code>true</code>
-     *        if the spans should occur in order, false otherwise.
-     * @param exclusion a boolean flag representing the value <code>true</code>,
-     *        if the second span should occur together with the first span,
-     *        false otherwise.
+     * @param elementQuery
+     *            the distance unit
+     * @param min
+     *            the minimum distance
+     * @param max
+     *            the maximum distance
+     * @param isOrdered
+     *            a boolean flag representing the value
+     *            <code>true</code>
+     *            if the spans should occur in order, false otherwise.
+     * @param exclusion
+     *            a boolean flag representing the value
+     *            <code>true</code>,
+     *            if the second span should occur together with the
+     *            first span,
+     *            false otherwise.
      */
-    public DistanceConstraint(SpanElementQuery elementQuery, int min, int max,
-            boolean isOrdered, boolean exclusion) {
+    public DistanceConstraint (SpanElementQuery elementQuery, int min, int max,
+                               boolean isOrdered, boolean exclusion) {
         if (elementQuery == null) {
             throw new IllegalArgumentException("Element query cannot be null.");
         }
@@ -109,117 +138,141 @@
         this.elementQuery = elementQuery;
     }
 
+
     /**
      * Returns the minimum distance.
      * 
      * @return the minimum distance
      */
-    public int getMinDistance() {
+    public int getMinDistance () {
         return minDistance;
     }
 
+
     /**
      * Sets the minimum distance.
      * 
-     * @param minDistance the minimum distance
+     * @param minDistance
+     *            the minimum distance
      */
-    public void setMinDistance(int minDistance) {
+    public void setMinDistance (int minDistance) {
         this.minDistance = minDistance;
     }
 
+
     /**
      * Returns the maximum distance.
      * 
      * @return the maximum distance
      */
-    public int getMaxDistance() {
+    public int getMaxDistance () {
         return maxDistance;
     }
 
+
     /**
      * Sets the maximum distance.
      * 
-     * @param maxDistance the maximum distance
+     * @param maxDistance
+     *            the maximum distance
      */
-    public void setMaxDistance(int maxDistance) {
+    public void setMaxDistance (int maxDistance) {
         this.maxDistance = maxDistance;
     }
 
+
     /**
      * Returns the distance unit.
      * 
      * @return the distance unit
      */
-    public String getUnit() {
+    public String getUnit () {
         return unit;
     }
 
+
     /**
      * Sets the distance unit.
      * 
-     * @param unit the distance unit
+     * @param unit
+     *            the distance unit
      */
-    public void setUnit(String unit) {
+    public void setUnit (String unit) {
         this.unit = unit;
     }
 
+
     /**
      * Returns the element query used as the distance unit.
      * 
      * @return the element query used as the distance unit
      */
-    public SpanElementQuery getElementQuery() {
+    public SpanElementQuery getElementQuery () {
         return elementQuery;
     }
 
+
     /**
      * Sets the element query used as the distance unit.
      * 
-     * @param elementQuery the element query used as the distance unit.
+     * @param elementQuery
+     *            the element query used as the distance unit.
      */
-    public void setElementQuery(SpanElementQuery elementQuery) {
+    public void setElementQuery (SpanElementQuery elementQuery) {
         this.elementQuery = elementQuery;
     }
 
+
     /**
-     * Tells if the second span must occur together with the first span, or not.
+     * Tells if the second span must occur together with the first
+     * span, or not.
      * 
-     * @return <code>true</code> if the second span must <em>not</em> occur
-     *         together with the first span, <code>false</code> otherwise.
+     * @return <code>true</code> if the second span must <em>not</em>
+     *         occur
+     *         together with the first span, <code>false</code>
+     *         otherwise.
      */
-    public boolean isExclusion() {
+    public boolean isExclusion () {
         return exclusion;
     }
 
+
     /**
-     * Sets <code>true</code> if the second span must <em>not</em> occur
+     * Sets <code>true</code> if the second span must <em>not</em>
+     * occur
      * together with the first span, <code>false</code> otherwise.
      * 
-     * @param exclusion a boolean with value <code>true</code> if the second
-     *        span must <em>not</em> occur together with the first span,
-     *        <code>false</code> otherwise.
+     * @param exclusion
+     *            a boolean with value <code>true</code> if the second
+     *            span must <em>not</em> occur together with the first
+     *            span,
+     *            <code>false</code> otherwise.
      */
-    public void setExclusion(boolean exclusion) {
+    public void setExclusion (boolean exclusion) {
         this.exclusion = exclusion;
     }
 
+
     /**
      * Tells if the spans must occur in order or not.
      * 
      * @return <code>true</code> if the spans must occur in order,
      *         <code>false</code> otherwise.
      */
-    public boolean isOrdered() {
+    public boolean isOrdered () {
         return isOrdered;
     }
 
+
     /**
      * Sets if the spans must occur in order or not.
      * 
-     * @param isOrdered a boolean with value <code>true</code> if the spans must
-     *        occur in order, <code>false</code> otherwise.
+     * @param isOrdered
+     *            a boolean with value <code>true</code> if the spans
+     *            must
+     *            occur in order, <code>false</code> otherwise.
      */
-    public void setOrdered(boolean isOrdered) {
+    public void setOrdered (boolean isOrdered) {
         this.isOrdered = isOrdered;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/FrameConstraint.java b/src/main/java/de/ids_mannheim/korap/query/FrameConstraint.java
index c26aba6..e0c3dd6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/FrameConstraint.java
+++ b/src/main/java/de/ids_mannheim/korap/query/FrameConstraint.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.query;
+
 import de.ids_mannheim.korap.util.QueryException;
 import org.apache.lucene.search.spans.Spans;
 
@@ -10,75 +11,66 @@
  * Multiple constraints are represented as a bit vector,
  * supporting fast checks if a certain condition is met.
  * The following distinctive frame conditions are supported:
- *
+ * 
  * <dl>
- *   <dt>precedes</dt>
- *   <dd>A precedes B</dd>
- *
- *   <dt>precedesDirectly</dt>
- *   <dd>A precedes B directly</dd>
- *
- *   <dt>overlapsLeft</dt>
- *   <dd>A overlaps B to the left</dd>
- *
- *   <dt>alignsLeft</dt>
- *   <dd>A aligns with B to the left</dd>
- *
- *   <dt>startsWith</dt>
- *   <dd>A starts with B</dd>
- *
- *   <dt>matches</dt>
- *   <dd>A matches B</dd>
- *
- *   <dt>isWithin</dt>
- *   <dd>A is within B</dd>
- *
- *   <dt>isAround</dt>
- *   <dd>A is around B</dd>
- *
- *   <dt>endsWith</dt>
- *   <dd>A ends with B</dd>
- *
- *   <dt>alignsRight</dt>
- *   <dd>A aligns with B to the right</dd>
- *
- *   <dt>overlapsRight</dt>
- *   <dd>A overlaps B to the right</dd>
- *
- *   <dt>succeedsDirectly</dt>
- *   <dd>A succeeds B directly</dd>
- *
- *   <dt>succeeds</dt>
- *   <dd>A succeeds B</dd>
+ * <dt>precedes</dt>
+ * <dd>A precedes B</dd>
+ * 
+ * <dt>precedesDirectly</dt>
+ * <dd>A precedes B directly</dd>
+ * 
+ * <dt>overlapsLeft</dt>
+ * <dd>A overlaps B to the left</dd>
+ * 
+ * <dt>alignsLeft</dt>
+ * <dd>A aligns with B to the left</dd>
+ * 
+ * <dt>startsWith</dt>
+ * <dd>A starts with B</dd>
+ * 
+ * <dt>matches</dt>
+ * <dd>A matches B</dd>
+ * 
+ * <dt>isWithin</dt>
+ * <dd>A is within B</dd>
+ * 
+ * <dt>isAround</dt>
+ * <dd>A is around B</dd>
+ * 
+ * <dt>endsWith</dt>
+ * <dd>A ends with B</dd>
+ * 
+ * <dt>alignsRight</dt>
+ * <dd>A aligns with B to the right</dd>
+ * 
+ * <dt>overlapsRight</dt>
+ * <dd>A overlaps B to the right</dd>
+ * 
+ * <dt>succeedsDirectly</dt>
+ * <dd>A succeeds B directly</dd>
+ * 
+ * <dt>succeeds</dt>
+ * <dd>A succeeds B</dd>
  * </dl>
- *
+ * 
  * @author diewald
  */
 public class FrameConstraint {
 
-    public static final int
-        PRECEDES          = 1,
-        PRECEDES_DIRECTLY = 1 << 1,
-        OVERLAPS_LEFT     = 1 << 2,
-        ALIGNS_LEFT       = 1 << 3,
-        STARTS_WITH       = 1 << 4,
-        MATCHES           = 1 << 5,
-        IS_WITHIN         = 1 << 6,
-        IS_AROUND         = 1 << 7,
-        ENDS_WITH         = 1 << 8,
-        ALIGNS_RIGHT      = 1 << 9,
-        OVERLAPS_RIGHT    = 1 << 10,
-        SUCCEEDS_DIRECTLY = 1 << 11,
-        SUCCEEDS          = 1 << 12,
-        ALL               = 1024 * 8 - 1;
+    public static final int PRECEDES = 1, PRECEDES_DIRECTLY = 1 << 1,
+            OVERLAPS_LEFT = 1 << 2, ALIGNS_LEFT = 1 << 3, STARTS_WITH = 1 << 4,
+            MATCHES = 1 << 5, IS_WITHIN = 1 << 6, IS_AROUND = 1 << 7,
+            ENDS_WITH = 1 << 8, ALIGNS_RIGHT = 1 << 9,
+            OVERLAPS_RIGHT = 1 << 10, SUCCEEDS_DIRECTLY = 1 << 11,
+            SUCCEEDS = 1 << 12, ALL = 1024 * 8 - 1;
 
 
-    private static final Map<String,Integer> FRAME;
+    private static final Map<String, Integer> FRAME;
     private static final List<Integer> NEXT_B;
 
     static {
         Map<String, Integer> FRAME_t = new HashMap<>();
-        List<Integer> NEXT_B_t       = new ArrayList(16);
+        List<Integer> NEXT_B_t = new ArrayList(16);
 
         /*
          * A precedes B
@@ -122,7 +114,7 @@
          */
         FRAME_t.put("alignsLeft", ALIGNS_LEFT);
         NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | ALIGNS_LEFT);
-        
+
         /*
          * A starts with B
          *
@@ -132,10 +124,9 @@
          * a.end > b.end && a.start == b.start
          */
         FRAME_t.put("startsWith", STARTS_WITH);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT |
-                     ALIGNS_LEFT | STARTS_WITH | MATCHES |
-                     IS_AROUND | ENDS_WITH);
-        
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | ALIGNS_LEFT
+                | STARTS_WITH | MATCHES | IS_AROUND | ENDS_WITH);
+
         /*
          * A matches B
          *
@@ -145,9 +136,9 @@
          * a.end = b.end && a.start = b.start
          */
         FRAME_t.put("matches", MATCHES);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT |
-                     ALIGNS_LEFT | MATCHES | ENDS_WITH);
-        
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | ALIGNS_LEFT
+                | MATCHES | ENDS_WITH);
+
         /*
          * A is within B
          *
@@ -168,8 +159,8 @@
          * a.start < b.start && a.end > b.end
          */
         FRAME_t.put("isAround", IS_AROUND);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT |
-                     IS_AROUND | ENDS_WITH);
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | IS_AROUND
+                | ENDS_WITH);
 
         /*
          * A ends with B
@@ -191,8 +182,8 @@
          * a.start > b.start && a.end == b.end
          */
         FRAME_t.put("alignsRight", ALIGNS_RIGHT);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | ALIGNS_LEFT |
-                     MATCHES | IS_WITHIN | ALIGNS_RIGHT);
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | ALIGNS_LEFT | MATCHES
+                | IS_WITHIN | ALIGNS_RIGHT);
 
         /*
          * A overlaps B to the right
@@ -203,9 +194,9 @@
          * a.start > b.start && a.start < b.end && a.end > b.end
          */
         FRAME_t.put("overlapsRight", OVERLAPS_RIGHT);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT |
-                     ALIGNS_LEFT | STARTS_WITH | MATCHES | IS_WITHIN |
-                     IS_AROUND | ENDS_WITH | ALIGNS_RIGHT | OVERLAPS_RIGHT);
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | ALIGNS_LEFT
+                | STARTS_WITH | MATCHES | IS_WITHIN | IS_AROUND | ENDS_WITH
+                | ALIGNS_RIGHT | OVERLAPS_RIGHT);
 
         /*
          * A succeeds B directly
@@ -216,10 +207,9 @@
          * a.start == b.end
          */
         FRAME_t.put("succeedsDirectly", SUCCEEDS_DIRECTLY);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT |
-                     ALIGNS_LEFT | STARTS_WITH | MATCHES | IS_WITHIN |
-                     IS_AROUND | ENDS_WITH | ALIGNS_RIGHT |
-                     OVERLAPS_RIGHT | SUCCEEDS_DIRECTLY);
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | OVERLAPS_LEFT | ALIGNS_LEFT
+                | STARTS_WITH | MATCHES | IS_WITHIN | IS_AROUND | ENDS_WITH
+                | ALIGNS_RIGHT | OVERLAPS_RIGHT | SUCCEEDS_DIRECTLY);
 
         /*
          * A succeeds B
@@ -230,17 +220,18 @@
          * a.start > b.end
          */
         FRAME_t.put("succeeds", SUCCEEDS);
-        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | ALIGNS_LEFT |
-                     STARTS_WITH | MATCHES | IS_WITHIN |
-                     ALIGNS_RIGHT | SUCCEEDS_DIRECTLY | SUCCEEDS);
+        NEXT_B_t.add(PRECEDES | PRECEDES_DIRECTLY | ALIGNS_LEFT | STARTS_WITH
+                | MATCHES | IS_WITHIN | ALIGNS_RIGHT | SUCCEEDS_DIRECTLY
+                | SUCCEEDS);
 
-        FRAME  = Collections.unmodifiableMap(FRAME_t);
+        FRAME = Collections.unmodifiableMap(FRAME_t);
         NEXT_B = Collections.unmodifiableList(NEXT_B_t);
     };
 
     // Bitvector representing the frame constraint
     public int vector;
 
+
     /**
      * Constructs a new Frame Constraint.
      */
@@ -248,11 +239,13 @@
         this.vector = 0;
     };
 
+
     /**
      * Add a new valid condition to the Frame Constraint.
-     *
-     * @param condition A string representing a valid condition.
-     *        See the synopsis for valid condition names.
+     * 
+     * @param condition
+     *            A string representing a valid condition.
+     *            See the synopsis for valid condition names.
      * @return The {@link FrameConstraint} for chaining.
      * @throws QueryException
      */
@@ -268,9 +261,10 @@
 
     /**
      * Add new valid conditions to the Frame Constraint.
-     *
-     * @param constraint A Frame constraint representing a set
-     *        of valid conditions.
+     * 
+     * @param constraint
+     *            A Frame constraint representing a set
+     *            of valid conditions.
      * @return The {@link FrameConstraint} for chaining.
      */
     public FrameConstraint add (FrameConstraint constraint) {
@@ -283,7 +277,7 @@
      * Invert the condition set of the frame constraint.
      * All valid conditions become invalid, all invalid
      * conditions become valid.
-     *
+     * 
      * @return The {@link FrameConstraint} for chaining.
      */
     public FrameConstraint invert () {
@@ -294,10 +288,12 @@
 
     /**
      * Check if a condition is valid.
-     *
-     * @param condition A string representing a condition.
-     *        See the synopsis for valid condition names.
-     * @return A boolean value, indicating if a condition is valid or not.
+     * 
+     * @param condition
+     *            A string representing a condition.
+     *            See the synopsis for valid condition names.
+     * @return A boolean value, indicating if a condition is valid or
+     *         not.
      * @throws QueryException
      */
     public boolean check (String condition) throws QueryException {
@@ -312,9 +308,12 @@
 
     /**
      * Check if conditions are valid.
-     *
-     * @param conditions An integer bit vector representing a set of conditions.
-     * @return A boolean value, indicating if at least one condition is valid or not.
+     * 
+     * @param conditions
+     *            An integer bit vector representing a set of
+     *            conditions.
+     * @return A boolean value, indicating if at least one condition
+     *         is valid or not.
      */
     public boolean check (int conditions) {
         return (this.vector & conditions) != 0;
@@ -323,9 +322,12 @@
 
     /**
      * Check if conditions are valid.
-     *
-     * @param conditions A {@link FrameConstraint} representing a set of conditions.
-     * @return A boolean value, indicating if at least one condition is valid or not.
+     * 
+     * @param conditions
+     *            A {@link FrameConstraint} representing a set of
+     *            conditions.
+     * @return A boolean value, indicating if at least one condition
+     *         is valid or not.
      */
     public boolean check (FrameConstraint conditions) {
         return (this.vector & conditions.vector) != 0;
diff --git a/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java b/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
index 28600d5..1e0e0f0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/query/QueryBuilder.java
@@ -10,20 +10,20 @@
 /**
  * QueryBuilder implements a simple API for wrapping
  * KrillQuery classes.
- *
+ * 
  * Build complex queries.
  * <blockquote><pre>
- *   QueryBuilder qb = new QueryBuilder("tokens");
- *   SpanQueryWrapper sqw = (SpanQueryWrapper)
- *     qb.seq(
- *       qb.empty(),
- *       qb.seg(
- *         qb.re("mate/p=N.*"),
- *         qb.re("opennlp/p=N.*")
- *       )
- *     );
+ * QueryBuilder qb = new QueryBuilder("tokens");
+ * SpanQueryWrapper sqw = (SpanQueryWrapper)
+ * qb.seq(
+ * qb.empty(),
+ * qb.seg(
+ * qb.re("mate/p=N.*"),
+ * qb.re("opennlp/p=N.*")
+ * )
+ * );
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  */
 public class QueryBuilder {
@@ -36,14 +36,15 @@
     public static final boolean DEBUG = false;
 
     // <legacy>
-    public static final byte
-        OVERLAP      = SpanWithinQuery.OVERLAP,
-        REAL_OVERLAP = SpanWithinQuery.REAL_OVERLAP,
-        WITHIN       = SpanWithinQuery.WITHIN,
-        REAL_WITHIN  = SpanWithinQuery.REAL_WITHIN,
-        ENDSWITH     = SpanWithinQuery.ENDSWITH,
-        STARTSWITH   = SpanWithinQuery.STARTSWITH,
-        MATCH        = SpanWithinQuery.MATCH;
+    public static final byte OVERLAP = SpanWithinQuery.OVERLAP,
+            REAL_OVERLAP = SpanWithinQuery.REAL_OVERLAP,
+            WITHIN = SpanWithinQuery.WITHIN,
+            REAL_WITHIN = SpanWithinQuery.REAL_WITHIN,
+            ENDSWITH = SpanWithinQuery.ENDSWITH,
+            STARTSWITH = SpanWithinQuery.STARTSWITH,
+            MATCH = SpanWithinQuery.MATCH;
+
+
     // </legacy>
 
 
@@ -54,15 +55,17 @@
         this.field = field;
     };
 
+
     /**
      * Create a query object based on a regular expression.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanRegexQueryWrapper re = kq.re(".+?");
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanRegexQueryWrapper re = kq.re(".+?");
      * </pre></blockquote>
-     *
-     * @param re The regular expession as a string.
+     * 
+     * @param re
+     *            The regular expession as a string.
      * @return A {@link SpanRegexQueryWrapper} object.
      */
     public SpanRegexQueryWrapper re (String re) {
@@ -72,26 +75,35 @@
 
     /**
      * Create a query object based on a regular expression.
-     *
-     * Supports flags as defined in {@link org.apache.lucene.util.automaton.RegExp}:
+     * 
+     * Supports flags as defined in
+     * {@link org.apache.lucene.util.automaton.RegExp}:
      * <ul>
-     *   <li><tt>RegExp.ALL</tt> - enables all optional regexp syntax</li>
-     *   <li><tt>RegExp.ANYSTRING</tt> - enables anystring (@)</li>
-     *   <li><tt>RegExp.AUTOMATON</tt> - enables named automata (&lt;identifier&gt;)</li>
-     *   <li><tt>RegExp.COMPLEMENT</tt> - enables complement (~)</li>
-     *   <li><tt>RegExp.EMPTY</tt> - enables empty language (#)</li>
-     *   <li><tt>RegExp.INTERSECTION</tt> - enables intersection (&amp;)</li>
-     *   <li><tt>RegExp.INTERVAL</tt> - enables numerical intervals (&lt;n-m&gt;)</li>
-     *   <li><tt>RegExp.NONE</tt> - enables no optional regexp syntax</li>
+     * <li><tt>RegExp.ALL</tt> - enables all optional regexp
+     * syntax</li>
+     * <li><tt>RegExp.ANYSTRING</tt> - enables anystring (@)</li>
+     * <li><tt>RegExp.AUTOMATON</tt> - enables named automata
+     * (&lt;identifier&gt;)</li>
+     * <li><tt>RegExp.COMPLEMENT</tt> - enables complement (~)</li>
+     * <li><tt>RegExp.EMPTY</tt> - enables empty language (#)</li>
+     * <li><tt>RegExp.INTERSECTION</tt> - enables intersection
+     * (&amp;)</li>
+     * <li><tt>RegExp.INTERVAL</tt> - enables numerical intervals
+     * (&lt;n-m&gt;)</li>
+     * <li><tt>RegExp.NONE</tt> - enables no optional regexp
+     * syntax</li>
      * </ul>
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanRegexQueryWrapper re = kq.re("[Aa]lternatives?", RegExp.NONE);
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanRegexQueryWrapper re = kq.re("[Aa]lternatives?",
+     * RegExp.NONE);
      * </pre></blockquote>
-     *
-     * @param re The regular expession as a string.
-     * @param flags The flag for the regular expression.
+     * 
+     * @param re
+     *            The regular expession as a string.
+     * @param flags
+     *            The flag for the regular expression.
      * @return A {@link SpanRegexQueryWrapper} object.
      */
     public SpanRegexQueryWrapper re (String re, int flags) {
@@ -101,70 +113,85 @@
 
     /**
      * Create a query object based on a regular expression.
-     *
+     * 
      * Supports flags (see above) and case insensitivity.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanRegexQueryWrapper re = kq.re("alternatives?", RegExp.NONE, true);
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanRegexQueryWrapper re = kq.re("alternatives?", RegExp.NONE,
+     * true);
      * </pre></blockquote>
-     *
-     * @param re The regular expession as a string.
-     * @param flags The flag for the regular expression.
-     * @param caseinsensitive A boolean value indicating case insensitivity.
+     * 
+     * @param re
+     *            The regular expession as a string.
+     * @param flags
+     *            The flag for the regular expression.
+     * @param caseinsensitive
+     *            A boolean value indicating case insensitivity.
      * @return A {@link SpanRegexQueryWrapper} object.
      */
-    public SpanRegexQueryWrapper re (String re, int flags, boolean caseinsensitive) {
+    public SpanRegexQueryWrapper re (String re, int flags,
+            boolean caseinsensitive) {
         return new SpanRegexQueryWrapper(this.field, re, flags, caseinsensitive);
     };
 
 
     /**
      * Create a query object based on a regular expression.
-     *
+     * 
      * Supports case insensitivity.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanRegexQueryWrapper re = kq.re("alternatives?", true);
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanRegexQueryWrapper re = kq.re("alternatives?", true);
      * </pre></blockquote>
-     *
-     * @param re The regular expession as a string.
-     * @param flags The flag for the regular expression.
+     * 
+     * @param re
+     *            The regular expession as a string.
+     * @param flags
+     *            The flag for the regular expression.
      * @return A {@link SpanRegexQueryWrapper} object.
      */
     public SpanRegexQueryWrapper re (String re, boolean caseinsensitive) {
-        return new SpanRegexQueryWrapper(this.field, re, RegExp.ALL, caseinsensitive);
+        return new SpanRegexQueryWrapper(this.field, re, RegExp.ALL,
+                caseinsensitive);
     };
 
+
     /**
      * Create a query object based on a wildcard term.
-     * <tt>*</tt> indicates an optional sequence of arbitrary characters,
+     * <tt>*</tt> indicates an optional sequence of arbitrary
+     * characters,
      * <tt>?</tt> indicates a single character,
      * <tt>\</tt> can be used for escaping.
-     *
-     * @param wc The wildcard term as a string.
+     * 
+     * @param wc
+     *            The wildcard term as a string.
      * @return A {@link SpanWildcardQueryWrapper} object.
      */
     public SpanWildcardQueryWrapper wc (String wc) {
         return new SpanWildcardQueryWrapper(this.field, wc, false);
     };
 
+
     /**
      * Create a query object based on a wildcard term.
-     * <tt>*</tt> indicates an optional sequence of arbitrary characters,
+     * <tt>*</tt> indicates an optional sequence of arbitrary
+     * characters,
      * <tt>?</tt> indicates a single character,
      * <tt>\</tt> can be used for escaping.
-     *
+     * 
      * Supports case insensitivity.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanWildcardQueryWrapper wc = kq.wc("wall*", true);
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanWildcardQueryWrapper wc = kq.wc("wall*", true);
      * </pre></blockquote>
-     *
-     * @param wc The wildcard term as a string.
-     * @param caseinsensitive A boolean value indicating case insensitivity.
+     * 
+     * @param wc
+     *            The wildcard term as a string.
+     * @param caseinsensitive
+     *            A boolean value indicating case insensitivity.
      * @return A {@link SpanWildcardQueryWrapper} object.
      */
     public SpanWildcardQueryWrapper wc (String wc, boolean caseinsensitive) {
@@ -174,12 +201,12 @@
 
     /**
      * Create a segment query object.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanSegmentQueryWrapper seg = kq.seg();
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanSegmentQueryWrapper seg = kq.seg();
      * </pre></blockquote>
-     *
+     * 
      * @return A {@link SpanSegmentQueryWrapper} object.
      */
     public SpanSegmentQueryWrapper seg () {
@@ -191,16 +218,17 @@
      * Create a segment query object.
      * Supports sequences of strings or {@link SpanRegexQueryWrapper},
      * and {@link SpanAlterQueryWrapper} objects.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanSegmentQueryWrapper seg = kq.seg(
-     *       kq.re("mate/p=.*?"),
-     *       kq.re("opennlp/p=.*?")
-     *   );
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanSegmentQueryWrapper seg = kq.seg(
+     * kq.re("mate/p=.*?"),
+     * kq.re("opennlp/p=.*?")
+     * );
      * </pre></blockquote>
-     *
-     * @param terms[] An array of terms, the segment consists of.
+     * 
+     * @param terms
+     *            [] An array of terms, the segment consists of.
      * @return A {@link SpanSegmentQueryWrapper} object.
      */
     // Sequence of regular expression queries
@@ -211,6 +239,7 @@
         return ssq;
     };
 
+
     // Sequence of alternative queries
     public SpanSegmentQueryWrapper seg (SpanAlterQueryWrapper ... terms) {
         SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper(this.field);
@@ -219,6 +248,7 @@
         return ssq;
     };
 
+
     // Sequence of alternative queries
     public SpanSegmentQueryWrapper seg (String ... terms) {
         SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper(this.field);
@@ -227,12 +257,13 @@
         return ssq;
     };
 
+
     /**
      * Create an empty query segment.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillQuery kq = new KrillQuery("tokens");
-     *   SpanRepetitionQueryWrapper seg = kq.empty();
+     * KrillQuery kq = new KrillQuery("tokens");
+     * SpanRepetitionQueryWrapper seg = kq.empty();
      * </pre></blockquote>
      */
     public SpanRepetitionQueryWrapper empty () {
@@ -245,7 +276,9 @@
 
     /**
      * Create a segment alternation query object.
-     * @param terms[] An array of alternative terms.
+     * 
+     * @param terms
+     *            [] An array of alternative terms.
      */
     public SpanAlterQueryWrapper or (SpanQueryWrapper ... terms) {
         SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
@@ -274,7 +307,9 @@
 
     /**
      * Create a sequence of segments query object.
-     * @param terms[] An array of segment defining terms.
+     * 
+     * @param terms
+     *            [] An array of segment defining terms.
      */
     public SpanSequenceQueryWrapper seq (SpanQueryWrapper ... terms) {
         SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper(this.field);
@@ -286,7 +321,9 @@
 
     /**
      * Create a sequence of segments query object.
-     * @param re A SpanSegmentRegexQuery, starting the sequence.
+     * 
+     * @param re
+     *            A SpanSegmentRegexQuery, starting the sequence.
      */
     public SpanSequenceQueryWrapper seq (SpanRegexQueryWrapper re) {
         return new SpanSequenceQueryWrapper(this.field, re);
@@ -303,7 +340,8 @@
                 ssq.append((SpanRegexQueryWrapper) t);
             }
             else {
-                log.error("{} is not an acceptable parameter for seq()", t.getClass());
+                log.error("{} is not an acceptable parameter for seq()",
+                        t.getClass());
                 return ssq;
             };
         };
@@ -315,82 +353,103 @@
         return new SpanElementQueryWrapper(this.field, element);
     };
 
+
     /**
      * Create a wrapping within query object.
-     * @param element A SpanQuery.
-     * @param embedded A SpanQuery that is wrapped in the element.
+     * 
+     * @param element
+     *            A SpanQuery.
+     * @param embedded
+     *            A SpanQuery that is wrapped in the element.
      */
     @Deprecated
     public SpanWithinQueryWrapper within (SpanQueryWrapper element,
-                                          SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded);
     };
-    
+
+
     public SpanWithinQueryWrapper contains (SpanQueryWrapper element,
-                                            SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded, WITHIN);
     };
 
+
     public SpanWithinQueryWrapper startswith (SpanQueryWrapper element,
-                                              SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded, STARTSWITH);
     };
 
+
     public SpanWithinQueryWrapper endswith (SpanQueryWrapper element,
-                                            SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded, ENDSWITH);
     };
 
+
     public SpanWithinQueryWrapper overlaps (SpanQueryWrapper element,
-                                            SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded, OVERLAP);
-    }; 
+    };
+
 
     public SpanWithinQueryWrapper matches (SpanQueryWrapper element,
-                                           SpanQueryWrapper embedded) {
+            SpanQueryWrapper embedded) {
         return new SpanWithinQueryWrapper(element, embedded, MATCH);
-    }; 
+    };
+
 
     // Class
     public SpanClassQueryWrapper _ (byte number, SpanQueryWrapper element) {
         return new SpanClassQueryWrapper(element, number);
     };
 
+
     public SpanClassQueryWrapper _ (int number, SpanQueryWrapper element) {
         return new SpanClassQueryWrapper(element, number);
     };
 
+
     public SpanClassQueryWrapper _ (short number, SpanQueryWrapper element) {
         return new SpanClassQueryWrapper(element, number);
     };
 
+
     public SpanClassQueryWrapper _ (SpanQueryWrapper element) {
         return new SpanClassQueryWrapper(element);
     };
 
+
     // Focus
     public SpanFocusQueryWrapper focus (byte number, SpanQueryWrapper element) {
         return new SpanFocusQueryWrapper(element, number);
     };
 
+
     public SpanFocusQueryWrapper focus (int number, SpanQueryWrapper element) {
         return new SpanFocusQueryWrapper(element, number);
     };
 
+
     public SpanFocusQueryWrapper focus (short number, SpanQueryWrapper element) {
         return new SpanFocusQueryWrapper(element, number);
     };
 
+
     public SpanFocusQueryWrapper focus (SpanQueryWrapper element) {
         return new SpanFocusQueryWrapper(element);
     };
 
+
     // Repetition
-    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element, int exact) {
+    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element,
+            int exact) {
         return new SpanRepetitionQueryWrapper(element, exact);
     };
 
-    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element, int min, int max) {
+
+    public SpanRepetitionQueryWrapper repeat (SpanQueryWrapper element,
+            int min, int max) {
         return new SpanRepetitionQueryWrapper(element, min, max);
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
index b490bf8..ff47287 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SimpleSpanQuery.java
@@ -14,21 +14,28 @@
 import de.ids_mannheim.korap.query.spans.ElementSpans;
 
 /**
- * A base class for Spanqueries. It added some properties and methods to the
+ * A base class for Spanqueries. It added some properties and methods
+ * to the
  * Lucene {@link SpanQuery} class.
  * 
- * The constructors of this class specify three kinds of spanqueries: <br/>
+ * The constructors of this class specify three kinds of spanqueries:
+ * <br/>
  * <br/>
  * 
  * <ol>
- * <li>Term span based queries are spanqueries retrieving spans based on a
+ * <li>Term span based queries are spanqueries retrieving spans based
+ * on a
  * single sub/child spanquery. <br/>
- * This kind of query is similar to the Lucene {@link SpanTermQuery}. It
- * searches for term spans in an index and creates a span enumeration of them.
- * Additionally, the retrieved spans contain some information related to the
+ * This kind of query is similar to the Lucene {@link SpanTermQuery}.
+ * It
+ * searches for term spans in an index and creates a span enumeration
+ * of them.
+ * Additionally, the retrieved spans contain some information related
+ * to the
  * type of the term spans, or modified the term span positions.
  * 
- * For instance, a {@link SpanAttributeQuery} retrieves {@link AttributeSpans},
+ * For instance, a {@link SpanAttributeQuery} retrieves
+ * {@link AttributeSpans},
  * which in addition to the Lucene SpanTermQuery properties, also have
  * references to element or relation spans. <br/>
  * <br/>
@@ -36,17 +43,23 @@
  * 
  * <li>Spanqueries based on two sub/child spanqueries. <br/>
  * These queries compare the positions or other properties of two sub
- * spanqueries. Examples of such queries are distance-based queries calculating
- * the distance between two sub/child spans. The resulting spans possibly
- * stretch from the start position of a sub/child span to the end position of
+ * spanqueries. Examples of such queries are distance-based queries
+ * calculating
+ * the distance between two sub/child spans. The resulting spans
+ * possibly
+ * stretch from the start position of a sub/child span to the end
+ * position of
  * the other sub/child span. <br/>
  * <br/>
  * </li>
  * 
- * <li>Spanqueries comparing a sub/child spanquery to a list of spanqueries. <br/>
- * An example of such queries is {@link SpanWithAttributeQuery} matching an
- * {@link SpanElementQuery} and a list of SpanAttributeQueries. In other words,
- * it retrieves {@link ElementSpans} having some specific attributes.<br/>
+ * <li>Spanqueries comparing a sub/child spanquery to a list of
+ * spanqueries. <br/>
+ * An example of such queries is {@link SpanWithAttributeQuery}
+ * matching an {@link SpanElementQuery} and a list of
+ * SpanAttributeQueries. In other words,
+ * it retrieves {@link ElementSpans} having some specific
+ * attributes.<br/>
  * <br/>
  * </li>
  * </ol>
@@ -57,21 +70,26 @@
  * */
 public abstract class SimpleSpanQuery extends SpanQuery implements Cloneable {
 
-	protected SpanQuery firstClause = null, secondClause = null;
+    protected SpanQuery firstClause = null, secondClause = null;
     protected List<SpanQuery> clauseList = null;
     private String field;
     protected boolean collectPayloads;
 
+
     /**
-     * Constructs a new SimpleSpanQuery using the specified {@link SpanQuery}
-     * and set whether payloads are to be collected or not.
+     * Constructs a new SimpleSpanQuery using the specified
+     * {@link SpanQuery} and set whether payloads are to be collected
+     * or not.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      * */
-    public SimpleSpanQuery(SpanQuery firstClause, boolean collectPayloads) {
+    public SimpleSpanQuery (SpanQuery firstClause, boolean collectPayloads) {
         if (firstClause == null) {
             throw new IllegalArgumentException(
                     "The first clause cannot be null.");
@@ -81,18 +99,24 @@
         this.collectPayloads = collectPayloads;
     }
 
+
     /**
-     * Constructs a new SimpleSpanQuery using the specified spanqueries and set
+     * Constructs a new SimpleSpanQuery using the specified
+     * spanqueries and set
      * whether payloads are to be collected or not.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param secondClause a {@link SpanQuery}
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param secondClause
+     *            a {@link SpanQuery}
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      * */
-    public SimpleSpanQuery(SpanQuery firstClause, SpanQuery secondClause,
-            boolean collectPayloads) {
+    public SimpleSpanQuery (SpanQuery firstClause, SpanQuery secondClause,
+                            boolean collectPayloads) {
         this(firstClause, collectPayloads);
         if (secondClause == null) {
             throw new IllegalArgumentException(
@@ -102,140 +126,163 @@
         this.setSecondClause(secondClause);
     }
 
+
     /**
-     * Constructs a new SimpleSpanQuery using the spanqueries in the specified
+     * Constructs a new SimpleSpanQuery using the spanqueries in the
+     * specified
      * list and set whether payloads are to be collected or not.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param secondClauses a list of spanqueries
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param secondClauses
+     *            a list of spanqueries
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      * */
-    public SimpleSpanQuery(SpanQuery firstClause,
-            List<SpanQuery> secondClauses, boolean collectPayloads) {
-		this(firstClause, collectPayloads);
-		setClauseList(secondClauses);
+    public SimpleSpanQuery (SpanQuery firstClause,
+                            List<SpanQuery> secondClauses,
+                            boolean collectPayloads) {
+        this(firstClause, collectPayloads);
+        setClauseList(secondClauses);
     }
 
-	public SimpleSpanQuery(List<SpanQuery> clauses, boolean collectPayloads) {
-		this.collectPayloads = collectPayloads;
-		setClauseList(clauses);
-	}
 
-	private void checkField(SpanQuery clause) {
+    public SimpleSpanQuery (List<SpanQuery> clauses, boolean collectPayloads) {
+        this.collectPayloads = collectPayloads;
+        setClauseList(clauses);
+    }
+
+
+    private void checkField (SpanQuery clause) {
         if (!clause.getField().equals(field)) {
             throw new IllegalArgumentException(
                     "Clauses must have the same field.");
         }
     }
 
+
     /**
      * Returns a set of child spanqueries used in this query.
      * 
      * @return a list of spanqueries
      */
-    public List<SpanQuery> getClauseList() {
+    public List<SpanQuery> getClauseList () {
         return clauseList;
     }
 
+
     /**
      * Sets a list of child spanqueries.
      * 
-     * @param clauseList a list of spanqueries
+     * @param clauseList
+     *            a list of spanqueries
      */
-	public void setClauseList(List<SpanQuery> clauses) {
-		if (clauses == null) {
-			throw new IllegalArgumentException(
-					"The list of clauses cannot be null.");
-		}
-		if (clauses.size() < 1) {
-			throw new IllegalArgumentException(
-					"The list of clauses cannot be empty.");
-		}
+    public void setClauseList (List<SpanQuery> clauses) {
+        if (clauses == null) {
+            throw new IllegalArgumentException(
+                    "The list of clauses cannot be null.");
+        }
+        if (clauses.size() < 1) {
+            throw new IllegalArgumentException(
+                    "The list of clauses cannot be empty.");
+        }
 
-		if (this.field == null) {
-			this.field = clauses.get(0).getField();
-		}
+        if (this.field == null) {
+            this.field = clauses.get(0).getField();
+        }
 
-		for (SpanQuery clause : clauses) {
-			if (clause == null) {
-				throw new IllegalArgumentException("A clause cannot be null.");
-			}
-			checkField(clause);
-		}
-		this.clauseList = clauses;
+        for (SpanQuery clause : clauses) {
+            if (clause == null) {
+                throw new IllegalArgumentException("A clause cannot be null.");
+            }
+            checkField(clause);
+        }
+        this.clauseList = clauses;
     }
 
+
     /**
      * {@inheritDoc}
      * */
     @Override
-    public String getField() {
+    public String getField () {
         return field;
     }
 
+
     /**
      * Returns the first child {@link SpanQuery}.
      * 
      * @return the first child {@link SpanQuery}.
      */
-    public SpanQuery getFirstClause() {
+    public SpanQuery getFirstClause () {
         return firstClause;
     }
 
+
     /**
      * Sets the first child {@link SpanQuery}.
      * 
-     * @param firstClause the first child {@link SpanQuery}.
+     * @param firstClause
+     *            the first child {@link SpanQuery}.
      */
-    public void setFirstClause(SpanQuery firstClause) {
+    public void setFirstClause (SpanQuery firstClause) {
         this.firstClause = firstClause;
     }
 
+
     /**
      * Returns the second child {@link SpanQuery}.
      * 
      * @return the second child {@link SpanQuery}.
      */
-    public SpanQuery getSecondClause() {
+    public SpanQuery getSecondClause () {
         return secondClause;
     }
 
+
     /**
      * Sets the second child {@link SpanQuery}.
      * 
-     * @param secondClause the second child {@link SpanQuery}.
+     * @param secondClause
+     *            the second child {@link SpanQuery}.
      */
-    public void setSecondClause(SpanQuery secondClause) {
+    public void setSecondClause (SpanQuery secondClause) {
         this.secondClause = secondClause;
     }
 
+
     /**
      * Tells if payloads are to be collected or not.
      * 
      * @return <code>true</code> if payloads are to be collected,
      *         <code>false</code> otherwise.
      */
-    public boolean isCollectPayloads() {
+    public boolean isCollectPayloads () {
         return collectPayloads;
     }
 
+
     /**
      * Sets <code>true</code> if payloads are to be collected,
      * <code>false</code> otherwise.
      * 
-     * @param collectPayloads a boolean flag determining if payloads are to be
-     *        collected or not.
+     * @param collectPayloads
+     *            a boolean flag determining if payloads are to be
+     *            collected or not.
      */
-    public void setCollectPayloads(boolean collectPayloads) {
+    public void setCollectPayloads (boolean collectPayloads) {
         this.collectPayloads = collectPayloads;
     }
 
+
     // For rewriting fuzzy searches like wildcard and regex
     /** {@inheritDoc} */
     @Override
-    public void extractTerms(Set<Term> terms) {
+    public void extractTerms (Set<Term> terms) {
 
         if (terms == null) {
             throw new IllegalArgumentException("The term set cannot be null.");
@@ -247,31 +294,35 @@
 
         if (secondClause != null) {
             secondClause.extractTerms(terms);
-        } else if (clauseList != null) {
+        }
+        else if (clauseList != null) {
             for (SpanQuery clause : clauseList) {
                 clause.extractTerms(terms);
             }
         }
     };
 
+
     /** {@inheritDoc} */
     @Override
-    public Query rewrite(IndexReader reader) throws IOException {
+    public Query rewrite (IndexReader reader) throws IOException {
         SimpleSpanQuery clone = null;
-		if (firstClause != null) {
-			clone = updateClone(reader, clone, firstClause, 1);
-		}
+        if (firstClause != null) {
+            clone = updateClone(reader, clone, firstClause, 1);
+        }
         if (secondClause != null) {
             clone = updateClone(reader, clone, secondClause, 2);
-        } 
+        }
         else if (clauseList != null) {
             clone = updateClone(reader, clone, clauseList);
         }
         return (clone != null ? clone : this);
     }
 
+
     /**
-     * Rewrites the spanqueries from the specified list, sets them to the clone,
+     * Rewrites the spanqueries from the specified list, sets them to
+     * the clone,
      * and return the clone.
      * 
      * @param reader
@@ -280,7 +331,7 @@
      * @return a SimpleSpanQuery
      * @throws IOException
      */
-    private SimpleSpanQuery updateClone(IndexReader reader,
+    private SimpleSpanQuery updateClone (IndexReader reader,
             SimpleSpanQuery clone, List<SpanQuery> spanQueries)
             throws IOException {
 
@@ -295,8 +346,10 @@
         return clone;
     }
 
+
     /**
-     * Rewrites the specified {@link SpanQuery} and sets it either as the first
+     * Rewrites the specified {@link SpanQuery} and sets it either as
+     * the first
      * or the second child {@link SpanQuery} of the clone.
      * 
      * @param reader
@@ -306,7 +359,7 @@
      * @return a SimpleSpanQuery
      * @throws IOException
      */
-    private SimpleSpanQuery updateClone(IndexReader reader,
+    private SimpleSpanQuery updateClone (IndexReader reader,
             SimpleSpanQuery clone, SpanQuery sq, int clauseNumber)
             throws IOException {
         SpanQuery query = (SpanQuery) sq.rewrite(reader);
@@ -321,12 +374,13 @@
         return clone;
     }
 
+
     /**
      * {@inheritDoc}
      * */
     // Used in rewriting query
     @Override
-    public boolean equals(Object o) {
+    public boolean equals (Object o) {
         if (this == o)
             return true;
         if (getClass() != o.getClass())
@@ -339,7 +393,8 @@
             return false;
         if (secondClause != null && !secondClause.equals(q.secondClause)) {
             return false;
-        } else if (clauseList != null) {
+        }
+        else if (clauseList != null) {
             for (int i = 0; i < clauseList.size(); i++) {
                 SpanQuery query = (SpanQuery) clauseList.get(i);
                 if (!query.equals(q.getClauseList().get(i))) {
@@ -351,13 +406,15 @@
         return true;
     };
 
+
     /** {@inheritDoc} */
     @Override
-    public int hashCode() {
+    public int hashCode () {
         int hc = firstClause.hashCode();
         if (secondClause != null) {
             hc += secondClause.hashCode();
-        } else if (clauseList != null) {
+        }
+        else if (clauseList != null) {
             for (int i = 0; i < clauseList.size(); i++) {
                 hc += clauseList.get(i).hashCode();
             }
@@ -367,6 +424,7 @@
         return hc;
     };
 
-    public abstract SimpleSpanQuery clone();
+
+    public abstract SimpleSpanQuery clone ();
 
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
index 6a5038c..2bef713 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
@@ -15,25 +15,30 @@
 import de.ids_mannheim.korap.query.spans.AttributeSpans;
 
 /**
- * SpanAttributeQuery retrieves {@link AttributeSpans}, that are tokens
+ * SpanAttributeQuery retrieves {@link AttributeSpans}, that are
+ * tokens
  * annotated with prefix @, for example {@literal @}:class=header.
- * SpanAttributeQueries are commonly used to search for elements or relations
+ * SpanAttributeQueries are commonly used to search for elements or
+ * relations
  * having some specific attribute(s).
  * 
  * Example: <br/>
  * <br/>
  * 
  * <pre>
- * SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term(
- *         &quot;tokens&quot;, &quot;@:class=title&quot;)), true);
+ * SpanAttributeQuery saq = new SpanAttributeQuery(new
+ * SpanTermQuery(new Term(
+ * &quot;tokens&quot;, &quot;@:class=title&quot;)), true);
  * </pre>
  * 
- * Negation enables searching for elements <em>without</em> some attribute(s).
+ * Negation enables searching for elements <em>without</em> some
+ * attribute(s).
  * Example:
  * 
  * <pre>
- * SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term(
- *         &quot;token&quot;, &quot;@:class=title&quot;)), true, true);
+ * SpanAttributeQuery saq = new SpanAttributeQuery(new
+ * SpanTermQuery(new Term(
+ * &quot;token&quot;, &quot;@:class=title&quot;)), true, true);
  * </pre>
  * 
  * @author margaretha
@@ -42,43 +47,59 @@
 
     boolean negation;
 
-    /**
-     * Constructs a SpanAttributeQuery based on the specified
-     * {@link SpanTermQuery} and set whether payloads are to be collected or
-     * not.
-     * 
-     * @param firstClause a {@link SpanTermQuery}
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
-     */
-    public SpanAttributeQuery(SpanTermQuery firstClause, boolean collectPayloads) {
-        super(firstClause, collectPayloads);
-    }
 
     /**
      * Constructs a SpanAttributeQuery based on the specified
-     * {@link SpanTermQuery}, which is also marked for negation/omission when
-     * matching to element/relation spans. Additionally set whether payloads are
+     * {@link SpanTermQuery} and set whether payloads are to be
+     * collected or
+     * not.
+     * 
+     * @param firstClause
+     *            a {@link SpanTermQuery}
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
+     */
+    public SpanAttributeQuery (SpanTermQuery firstClause,
+                               boolean collectPayloads) {
+        super(firstClause, collectPayloads);
+    }
+
+
+    /**
+     * Constructs a SpanAttributeQuery based on the specified
+     * {@link SpanTermQuery}, which is also marked for
+     * negation/omission when
+     * matching to element/relation spans. Additionally set whether
+     * payloads are
      * to be collected or not.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param negation a boolean flag representing the value <code>true</code>
-     *        if the attributes are to be omitted when matching with element or
-     *        relation spans, otherwise <code>false</code>.
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param negation
+     *            a boolean flag representing the value
+     *            <code>true</code>
+     *            if the attributes are to be omitted when matching
+     *            with element or
+     *            relation spans, otherwise <code>false</code>.
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanAttributeQuery(SpanTermQuery firstClause, boolean negation,
-            boolean collectPayloads) {
+    public SpanAttributeQuery (SpanTermQuery firstClause, boolean negation,
+                               boolean collectPayloads) {
         super(firstClause, collectPayloads);
         this.negation = negation;
     }
 
+
     /** {@inheritDoc} */
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SpanAttributeQuery sq = new SpanAttributeQuery(
                 (SpanTermQuery) this.firstClause.clone(), this.negation,
                 this.collectPayloads);
@@ -86,44 +107,56 @@
         return sq;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new AttributeSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanAttribute(");
-		if (negation) sb.append("!");
+        if (negation)
+            sb.append("!");
         sb.append(firstClause.toString(field));
         sb.append(")");
         sb.append(ToStringUtils.boost(getBoost()));
         return sb.toString();
     }
 
+
     /**
-     * Tells weather the attributes are to be omitted when matching to element
+     * Tells weather the attributes are to be omitted when matching to
+     * element
      * or relation spans, or not.
      * 
-     * @return <code>true</code> if the attributes are to be omitted when
-     *         matching to element or relation spans, <code>false</code>
+     * @return <code>true</code> if the attributes are to be omitted
+     *         when
+     *         matching to element or relation spans,
+     *         <code>false</code>
      *         otherwise.
      */
-    public boolean isNegation() {
+    public boolean isNegation () {
         return negation;
     }
 
+
     /**
-     * Sets true if the attributes are to be omitted when matching to element or
+     * Sets true if the attributes are to be omitted when matching to
+     * element or
      * relation spans, false otherwise.
      * 
-     * @param negation a boolean with value <code>true</code>, if the attributes
-     *        are to be omitted when matching to element or relation spans,
-     *        <code>false</code> otherwise.
+     * @param negation
+     *            a boolean with value <code>true</code>, if the
+     *            attributes
+     *            are to be omitted when matching to element or
+     *            relation spans,
+     *            <code>false</code> otherwise.
      */
-    public void setNegation(boolean negation) {
+    public void setNegation (boolean negation) {
         this.negation = negation;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
index e493c9e..aa9fc7a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
@@ -26,105 +26,112 @@
     protected byte number;
     protected SpanQuery operand;
 
+
     public SpanClassQuery (SpanQuery operand, byte number) {
-	this.field = operand.getField();
-	this.operand = operand;
-	this.number = number;
+        this.field = operand.getField();
+        this.operand = operand;
+        this.number = number;
     };
 
+
     public SpanClassQuery (SpanQuery operand) {
-	this.field = operand.getField();
-	this.operand = operand;
-	this.number = (byte) 1;
+        this.field = operand.getField();
+        this.operand = operand;
+        this.number = (byte) 1;
     };
 
+
     public byte number () {
-	return this.number;
+        return this.number;
     };
 
+
     @Override
-    public String getField () { return field; }
+    public String getField () {
+        return field;
+    }
+
 
     @Override
     public void extractTerms (Set<Term> terms) {
-	this.operand.extractTerms(terms);
+        this.operand.extractTerms(terms);
     };
 
+
     @Override
     public String toString (String field) {
-	StringBuffer buffer = new StringBuffer("{");
-	short classNr = (short) this.number;
-	buffer.append(classNr & 0xFF).append(": ");
+        StringBuffer buffer = new StringBuffer("{");
+        short classNr = (short) this.number;
+        buffer.append(classNr & 0xFF).append(": ");
         buffer.append(this.operand.toString()).append('}');
-	buffer.append(ToStringUtils.boost(getBoost()));
-	return buffer.toString();
+        buffer.append(ToStringUtils.boost(getBoost()));
+        return buffer.toString();
     };
 
+
     @Override
-    public Spans getSpans (final AtomicReaderContext context,
-			   Bits acceptDocs,
-			   Map<Term,TermContext> termContexts) throws IOException {
-	return (Spans) new ClassSpans(
-	    this.operand,
-	    context,
-	    acceptDocs,
-	    termContexts,
-	    number
-        );
+    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+            Map<Term, TermContext> termContexts) throws IOException {
+        return (Spans) new ClassSpans(this.operand, context, acceptDocs,
+                termContexts, number);
     };
 
+
     @Override
     public Query rewrite (IndexReader reader) throws IOException {
-	SpanClassQuery clone = null;
-	SpanQuery query = (SpanQuery) this.operand.rewrite(reader);
+        SpanClassQuery clone = null;
+        SpanQuery query = (SpanQuery) this.operand.rewrite(reader);
 
-	if (query != this.operand) {
-	    if (clone == null)
-		clone = this.clone();
-	    clone.operand = query;
-	};
+        if (query != this.operand) {
+            if (clone == null)
+                clone = this.clone();
+            clone.operand = query;
+        };
 
-	if (clone != null)
-	    return clone;
+        if (clone != null)
+            return clone;
 
-	return this;
+        return this;
     };
 
+
     @Override
-    public SpanClassQuery clone() {
-	SpanClassQuery spanClassQuery = new SpanClassQuery(
-	    (SpanQuery) this.operand.clone(),
-	    this.number
-        );
-	spanClassQuery.setBoost(getBoost());
-	return spanClassQuery;
+    public SpanClassQuery clone () {
+        SpanClassQuery spanClassQuery = new SpanClassQuery(
+                (SpanQuery) this.operand.clone(), this.number);
+        spanClassQuery.setBoost(getBoost());
+        return spanClassQuery;
     };
 
 
     /** Returns true iff <code>o</code> is equal to this. */
     @Override
     public boolean equals (Object o) {
-	if (this == o) return true;
-	if (!(o instanceof SpanClassQuery)) return false;
-	
-	final SpanClassQuery spanClassQuery = (SpanClassQuery) o;
-	
-	if (!this.operand.equals(spanClassQuery.operand)) return false;
+        if (this == o)
+            return true;
+        if (!(o instanceof SpanClassQuery))
+            return false;
 
-	if (this.number != spanClassQuery.number) return false;
+        final SpanClassQuery spanClassQuery = (SpanClassQuery) o;
 
-	return getBoost() == spanClassQuery.getBoost();
+        if (!this.operand.equals(spanClassQuery.operand))
+            return false;
+
+        if (this.number != spanClassQuery.number)
+            return false;
+
+        return getBoost() == spanClassQuery.getBoost();
     };
 
 
     // I don't know what I am doing here
     @Override
-    public int hashCode() {
-	int result = 1;
-	result = operand.hashCode();
-	result += (int) number;
-	result ^= (result << 15) | (result >>> 18);
-	result += Float.floatToRawIntBits(getBoost());
-	return result;
+    public int hashCode () {
+        int result = 1;
+        result = operand.hashCode();
+        result += (int) number;
+        result ^= (result << 15) | (result >>> 18);
+        result += Float.floatToRawIntBits(getBoost());
+        return result;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
index ba07dac..c77bf71 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
@@ -19,20 +19,26 @@
 import de.ids_mannheim.korap.query.spans.UnorderedTokenDistanceSpans;
 
 /**
- * SpanDistanceQuery calculates the distance between two spans and compares it
- * to the distance constraints. The distance constraints are specified as a
- * {@link DistanceConstraint} instance having various properties: the distance
- * unit, the order of the spans (ordered or unordered), co-occurrence (i.e. the
+ * SpanDistanceQuery calculates the distance between two spans and
+ * compares it
+ * to the distance constraints. The distance constraints are specified
+ * as a {@link DistanceConstraint} instance having various properties:
+ * the distance
+ * unit, the order of the spans (ordered or unordered), co-occurrence
+ * (i.e. the
  * spans should co-occur or not), minimum and maximum distance. <br/>
  * <br/>
- * The distance unit can be a word (token), a sentence or a paragraph. The
- * resulting spans typically stretch from the starting position of a former span
+ * The distance unit can be a word (token), a sentence or a paragraph.
+ * The
+ * resulting spans typically stretch from the starting position of a
+ * former span
  * to the end position of the latter span. <br/>
  * <br/>
  * Query examples:
  * 
  * <ol>
- * <li>Search two terms x and y which are separated by minimum two and maximum
+ * <li>Search two terms x and y which are separated by minimum two and
+ * maximum
  * three other words. The order of x and y does not matter.
  * 
  * <pre>
@@ -40,7 +46,8 @@
  * </pre>
  * 
  * </li>
- * <li>Search two terms x and y which are separated by minimum two and maximum
+ * <li>Search two terms x and y which are separated by minimum two and
+ * maximum
  * three other words. X must precede y.
  * 
  * <pre>
@@ -49,7 +56,8 @@
  * 
  * </li>
  * <li>
- * Search term x which do not occur with term y in minimum two and maximum three
+ * Search term x which do not occur with term y in minimum two and
+ * maximum three
  * other words. X must precede y.
  * 
  * <pre>
@@ -57,12 +65,15 @@
  * </pre>
  * 
  * </li>
- * <li>Search two terms x and y separated by minimum one and maximum two
+ * <li>Search two terms x and y separated by minimum one and maximum
+ * two
  * sentences. X must precede y.
  * 
  * <pre>
- * SpanElementQuery e = new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
- * DistanceConstraint dc = new DistanceConstraint(e, 2, 3, true, false);
+ * SpanElementQuery e = new SpanElementQuery(&quot;tokens&quot;,
+ * &quot;s&quot;);
+ * DistanceConstraint dc = new DistanceConstraint(e, 2, 3, true,
+ * false);
  * </pre>
  * 
  * </li>
@@ -74,8 +85,10 @@
  * <li>
  * 
  * <pre>
- * SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(new Term(
- *         &quot;tokens&quot;, x)), new SpanTermQuery(new Term(&quot;tokens&quot;, y)), dc, true);
+ * SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(new
+ * Term(
+ * &quot;tokens&quot;, x)), new SpanTermQuery(new
+ * Term(&quot;tokens&quot;, y)), dc, true);
  * </pre>
  * 
  * </li>
@@ -83,8 +96,9 @@
  * 
  * <pre>
  * SpanDistanceQuery sq = new SpanDistanceQuery(
- *         new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), new SpanElementQuery(&quot;tokens&quot;, y),
- *         dc, true);
+ * new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), new
+ * SpanElementQuery(&quot;tokens&quot;, y),
+ * dc, true);
  * </pre>
  * 
  * </li>
@@ -104,21 +118,30 @@
     private String spanName;
     private DistanceConstraint constraint;
 
+
     /**
-     * Constructs a SpanDistanceQuery comparing the distance between the spans
-     * of the two specified spanqueries and based-on the given distance
+     * Constructs a SpanDistanceQuery comparing the distance between
+     * the spans
+     * of the two specified spanqueries and based-on the given
+     * distance
      * constraints.
      * 
-     * @param firstClause a span query
-     * @param secondClause a span query
-     * @param constraint a DistanceConstraint containing all the constraints
-     *        required for the distance query
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a span query
+     * @param secondClause
+     *            a span query
+     * @param constraint
+     *            a DistanceConstraint containing all the constraints
+     *            required for the distance query
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanDistanceQuery(SpanQuery firstClause, SpanQuery secondClause,
-            DistanceConstraint constraint, boolean collectPayloads) {
+    public SpanDistanceQuery (SpanQuery firstClause, SpanQuery secondClause,
+                              DistanceConstraint constraint,
+                              boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
 
         if (constraint == null) {
@@ -136,13 +159,15 @@
         if (constraint.getElementQuery() != null) {
             spanName = "spanElementDistance";
             this.elementQuery = constraint.getElementQuery();
-        } else {
+        }
+        else {
             spanName = "spanDistance";
         }
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append(this.spanName);
         sb.append("(");
@@ -163,8 +188,9 @@
         return sb.toString();
     }
 
+
     @Override
-    public SpanDistanceQuery clone() {
+    public SpanDistanceQuery clone () {
         SpanDistanceQuery spanDistanceQuery = new SpanDistanceQuery(
                 (SpanQuery) firstClause.clone(),
                 (SpanQuery) secondClause.clone(), this.constraint,
@@ -177,25 +203,29 @@
         return spanDistanceQuery;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         if (this.elementQuery != null) {
             if (isExclusion()) {
                 return new ElementDistanceExclusionSpans(this, context,
                         acceptDocs, termContexts);
-            } else if (isOrdered) {
+            }
+            else if (isOrdered) {
                 return new ElementDistanceSpans(this, context, acceptDocs,
                         termContexts);
             }
             return new UnorderedElementDistanceSpans(this, context, acceptDocs,
                     termContexts);
 
-        } else if (isExclusion()) {
+        }
+        else if (isExclusion()) {
             return new DistanceExclusionSpans(this, context, acceptDocs,
                     termContexts);
-        } else if (isOrdered) {
+        }
+        else if (isOrdered) {
             return new TokenDistanceSpans(this, context, acceptDocs,
                     termContexts);
         }
@@ -203,99 +233,117 @@
                 termContexts);
     }
 
+
     /**
      * Returns the minimum distance constraint.
      * 
      * @return the minimum distance constraint
      */
-    public int getMinDistance() {
+    public int getMinDistance () {
         return minDistance;
     }
 
+
     /**
      * Sets the minimum distance constraint.
      * 
-     * @param minDistance the minimum distance constraint
+     * @param minDistance
+     *            the minimum distance constraint
      */
-    public void setMinDistance(int minDistance) {
+    public void setMinDistance (int minDistance) {
         this.minDistance = minDistance;
     }
 
+
     /**
      * Returns the maximum distance.
      * 
      * @return the maximum distance constraint
      */
-    public int getMaxDistance() {
+    public int getMaxDistance () {
         return maxDistance;
     }
 
+
     /**
      * Sets a maximum distance.
      * 
-     * @param maxDistance the maximum distance
+     * @param maxDistance
+     *            the maximum distance
      */
-    public void setMaxDistance(int maxDistance) {
+    public void setMaxDistance (int maxDistance) {
         this.maxDistance = maxDistance;
     }
 
+
     /**
      * Returns the element query used as the distance unit.
      * 
      * @return the element distance unit
      */
-    public SpanElementQuery getElementQuery() {
+    public SpanElementQuery getElementQuery () {
         return elementQuery;
     }
 
+
     /**
      * Sets the specified element query used as the distance unit.
      * 
-     * @param elementQuery the SpanElementQuery used as the distance unit
+     * @param elementQuery
+     *            the SpanElementQuery used as the distance unit
      */
-    public void setElementQuery(SpanElementQuery elementQuery) {
+    public void setElementQuery (SpanElementQuery elementQuery) {
         this.elementQuery = elementQuery;
     }
 
+
     /**
      * Tells weather the second sub-span should co-occur or not.
      * 
-     * @return a boolean with <code>true</code> if the second sub-span should
+     * @return a boolean with <code>true</code> if the second sub-span
+     *         should
      *         <em>not</em> co-occur, <code>false</code> otherwise.
      */
-    public boolean isExclusion() {
+    public boolean isExclusion () {
         return exclusion;
     }
 
+
     /**
-     * Sets <code>true</code> if the second sub-span should <em>not</em>
+     * Sets <code>true</code> if the second sub-span should
+     * <em>not</em>
      * co-occur, <code>false</code> otherwise.
      * 
-     * @param exclusion a boolean with value <code>true</code> if the second
-     *        sub-span should <em>not</em> co-occur, <code>false</code>
-     *        otherwise.
+     * @param exclusion
+     *            a boolean with value <code>true</code> if the second
+     *            sub-span should <em>not</em> co-occur,
+     *            <code>false</code>
+     *            otherwise.
      */
-    public void setExclusion(boolean exclusion) {
+    public void setExclusion (boolean exclusion) {
         this.exclusion = exclusion;
     }
 
+
     /**
      * Tells whether the spans must occur in order or not.
      * 
      * @return <code>true</code> if the spans must occur in order,
      *         <code>false</code> otherwise.
      */
-    public boolean isOrdered() {
+    public boolean isOrdered () {
         return isOrdered;
     }
 
+
     /**
      * Sets whether the spans must occur in order or not.
      * 
-     * @param isOrdered <code>true</code> if the spans must occur in order,
-     *        <code>false</code> otherwise.
+     * @param isOrdered
+     *            <code>true</code> if the spans must occur in order,
+     *            <code>false</code> otherwise.
      */
-    public void setOrder(boolean isOrdered) {
+    public void setOrder (boolean isOrdered) {
         this.isOrdered = isOrdered;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
index 1e3f5f6..9aa684a 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
@@ -18,7 +18,8 @@
 /**
  * SpanElementQuery retrieves {@link ElementSpans} which are special
  * {@link Term Terms} with prefix &quot;&lt;&gt;&quot;.
- * Unlike {@link TermSpans} ElementSpans may span multiple tokens comprising a
+ * Unlike {@link TermSpans} ElementSpans may span multiple tokens
+ * comprising a
  * phrase, a clause, a sentence and so on. <br/>
  * <br/>
  * Examples of {@link ElementSpans} are
@@ -27,14 +28,16 @@
  * <li>sentences indexed as &lt;&gt;:s
  * 
  * <pre>
- * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
+ * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;,
+ * &quot;s&quot;);
  * </pre>
  * 
  * </li>
  * <li>paragraphs indexed as &lt;&gt;:p
  * 
  * <pre>
- * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;, &quot;p&quot;);
+ * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;,
+ * &quot;p&quot;);
  * </pre>
  * 
  * </li>
@@ -48,66 +51,71 @@
     private static Term elementTerm;
     private String elementStr;
 
+
     /**
-     * Constructs a SpanElementQuery for the given term in the given field.
+     * Constructs a SpanElementQuery for the given term in the given
+     * field.
      * 
-     * @param field a field where a term belongs to
-     * @param term a term
+     * @param field
+     *            a field where a term belongs to
+     * @param term
+     *            a term
      */
-    public SpanElementQuery(String field, String term) {
+    public SpanElementQuery (String field, String term) {
         super(new SpanTermQuery((elementTerm = new Term(field, "<>:" + term))),
-              true);
+                true);
         this.elementStr = term;
     };
 
 
     @Override
-    public Spans getSpans(final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new ElementSpans(this, context, acceptDocs, termContexts);
     };
 
 
     /**
-     * Returns the element name or string, for instance "s" for sentence
+     * Returns the element name or string, for instance "s" for
+     * sentence
      * elements.
      * 
      * @return the element name/string.
      */
-    public String getElementStr() {
+    public String getElementStr () {
         return elementStr;
     };
 
 
     /**
-     * Sets the element name or string, for instance "s" for sentence elements.
+     * Sets the element name or string, for instance "s" for sentence
+     * elements.
      * 
-     * @param elementStr the element name or string
+     * @param elementStr
+     *            the element name or string
      */
-    public void setElementStr(String elementStr) {
+    public void setElementStr (String elementStr) {
         this.elementStr = elementStr;
     }
 
 
     @Override
-    public SimpleSpanQuery clone() {
-        SpanElementQuery sq = new SpanElementQuery(
-            this.getField(),
-            this.getElementStr()
-        );
+    public SimpleSpanQuery clone () {
+        SpanElementQuery sq = new SpanElementQuery(this.getField(),
+                this.getElementStr());
         sq.setBoost(this.getBoost());
         return sq;
     };
 
 
     @Override
-    public void extractTerms(Set<Term> terms) {
+    public void extractTerms (Set<Term> terms) {
         terms.add(elementTerm);
     };
 
 
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder buffer = new StringBuilder("<");
         buffer.append(getField()).append(':').append(elementStr);
         buffer.append(ToStringUtils.boost(getBoost()));
@@ -116,7 +124,7 @@
 
 
     @Override
-    public int hashCode() {
+    public int hashCode () {
         final int prime = 37; // Instead of 31
         int result = super.hashCode();
         result = prime * result
@@ -126,7 +134,7 @@
 
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals (Object obj) {
         if (this == obj)
             return true;
         // if (!super.equals(obj)) return false;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
index 65f786a..2fb8e84 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
@@ -15,25 +15,35 @@
 import de.ids_mannheim.korap.query.spans.ExpandedSpans;
 
 /**
- * SpanExpansionQuery makes a span longer by stretching out the start or the end
- * position of the span. The constraints of the expansion, such as how large the
- * expansion should be (min and max position) and the direction of the expansion
- * with respect to the original span, are specified in ExpansionConstraint. The
- * direction is designated with the sign of a number, namely a negative number
- * signifies the left direction, and a positive number (including 0) signifies
+ * SpanExpansionQuery makes a span longer by stretching out the start
+ * or the end
+ * position of the span. The constraints of the expansion, such as how
+ * large the
+ * expansion should be (min and max position) and the direction of the
+ * expansion
+ * with respect to the original span, are specified in
+ * ExpansionConstraint. The
+ * direction is designated with the sign of a number, namely a
+ * negative number
+ * signifies the left direction, and a positive number (including 0)
+ * signifies
  * the right direction.
  * 
  * <pre>
- * SpanTermQuery stq = new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;s:lightning&quot;));
- * SpanExpansionQuery seq = new SpanExpansionQuery(stq, 0, 2, -1, true);
+ * SpanTermQuery stq = new SpanTermQuery(new Term(&quot;tokens&quot;,
+ * &quot;s:lightning&quot;));
+ * SpanExpansionQuery seq = new SpanExpansionQuery(stq, 0, 2, -1,
+ * true);
  * </pre>
  * 
  * In the example above, the SpanExpansionQuery describes that the
- * {@link TermSpans} of "lightning" may be expanded up to two token positions to
+ * {@link TermSpans} of "lightning" may be expanded up to two token
+ * positions to
  * the left.
  * 
  * <pre>
- * &quot;Trees are often struck by lightning because they are natural lightning conductors to the ground.&quot;
+ * &quot;Trees are often struck by lightning because they are natural
+ * lightning conductors to the ground.&quot;
  * </pre>
  * 
  * The matches for the sample text are:
@@ -48,34 +58,42 @@
  * </pre>
  * 
  * The expansion can also be specified to <em>not</em> contain any
- * direct/immediate /adjacent occurrence(s) of another span. Examples in
+ * direct/immediate /adjacent occurrence(s) of another span. Examples
+ * in
  * Poliqarp:
  * 
  * <pre>
- * 	[orth=the][orth!=lightning]         "the" must not be followed by "lightning" 
- * 	[pos!=ADJ]{1,2}[orth=jacket]	    one or two adjectives cannot precedes "jacket"
+ * [orth=the][orth!=lightning] "the" must not be followed by
+ * "lightning"
+ * [pos!=ADJ]{1,2}[orth=jacket] one or two adjectives cannot precedes
+ * "jacket"
  * </pre>
  * 
- * The SpanExpansionQuery for the latter Poliqarp query with left direction from
+ * The SpanExpansionQuery for the latter Poliqarp query with left
+ * direction from
  * "jacket" example is:
  * 
  * <pre>
- * SpanTermQuery notQuery = new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;tt:p:/ADJ&quot;));
- * SpanTermQuery stq = new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;s:jacket&quot;));
- * SpanExpansionQuery seq = new SpanExpansionQuery(stq, notQuery, 1, 2, -1, true);
+ * SpanTermQuery notQuery = new SpanTermQuery(new
+ * Term(&quot;tokens&quot;, &quot;tt:p:/ADJ&quot;));
+ * SpanTermQuery stq = new SpanTermQuery(new Term(&quot;tokens&quot;,
+ * &quot;s:jacket&quot;));
+ * SpanExpansionQuery seq = new SpanExpansionQuery(stq, notQuery, 1,
+ * 2, -1, true);
  * </pre>
  * 
  * Matches and non matches example:
  * 
  * <pre>
- * [a jacket]                         match
- * [such a jacket]                    non match, where such is an ADJ
- * [leather jacket]                   non match
- * [black leather jacket]             non match
- * [large black leather jacket]       non match
+ * [a jacket] match
+ * [such a jacket] non match, where such is an ADJ
+ * [leather jacket] non match
+ * [black leather jacket] non match
+ * [large black leather jacket] non match
  * </pre>
  * 
- * The positions of the expansion parts can be optionally stored in payloads
+ * The positions of the expansion parts can be optionally stored in
+ * payloads
  * together with a class number.
  * 
  * @author margaretha
@@ -95,20 +113,27 @@
     // if true, no occurrence of another span
     final boolean isExclusion;
 
+
     /**
-     * Constructs a SpanExpansionQuery for simple expansion of the specified
-     * {@link SpanQuery}.
+     * Constructs a SpanExpansionQuery for simple expansion of the
+     * specified {@link SpanQuery}.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param min the minimum length of the expansion
-     * @param max the maximum length of the expansion
-     * @param direction the direction of the expansion
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param min
+     *            the minimum length of the expansion
+     * @param max
+     *            the maximum length of the expansion
+     * @param direction
+     *            the direction of the expansion
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanExpansionQuery(SpanQuery firstClause, int min, int max,
-            int direction, boolean collectPayloads) {
+    public SpanExpansionQuery (SpanQuery firstClause, int min, int max,
+                               int direction, boolean collectPayloads) {
         super(firstClause, collectPayloads);
         if (max < min) {
             throw new IllegalArgumentException("The max position has to be "
@@ -120,42 +145,62 @@
         this.isExclusion = false;
     }
 
+
     /**
-     * Constructs a SpanExpansionQuery for simple expansion of the specified
-     * {@link SpanQuery} and stores expansion offsets in payloads associated
+     * Constructs a SpanExpansionQuery for simple expansion of the
+     * specified {@link SpanQuery} and stores expansion offsets in
+     * payloads associated
      * with the given class number.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param min the minimum length of the expansion
-     * @param max the maximum length of the expansion
-     * @param direction the direction of the expansion
-     * @param classNumber the class number for storing expansion offsets in
-     *        payloads
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param min
+     *            the minimum length of the expansion
+     * @param max
+     *            the maximum length of the expansion
+     * @param direction
+     *            the direction of the expansion
+     * @param classNumber
+     *            the class number for storing expansion offsets in
+     *            payloads
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanExpansionQuery(SpanQuery firstClause, int min, int max,
-            int direction, byte classNumber, boolean collectPayloads) {
+    public SpanExpansionQuery (SpanQuery firstClause, int min, int max,
+                               int direction, byte classNumber,
+                               boolean collectPayloads) {
         this(firstClause, min, max, direction, collectPayloads);
         this.classNumber = classNumber;
     }
 
+
     /**
      * Constructs a SpanExpansionQuery for expansion of the first
-     * {@link SpanQuery} with exclusions of the second {@link SpanQuery}.
+     * {@link SpanQuery} with exclusions of the second
+     * {@link SpanQuery}.
      * 
-     * @param firstClause the SpanQuery to be expanded
-     * @param notClause the SpanQuery to be excluded
-     * @param min the minimum length of the expansion
-     * @param max the maximum length of the expansion
-     * @param direction the direction of the expansion
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            the SpanQuery to be expanded
+     * @param notClause
+     *            the SpanQuery to be excluded
+     * @param min
+     *            the minimum length of the expansion
+     * @param max
+     *            the maximum length of the expansion
+     * @param direction
+     *            the direction of the expansion
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanExpansionQuery(SpanQuery firstClause, SpanQuery notClause,
-            int min, int max, int direction, boolean collectPayloads) {
+    public SpanExpansionQuery (SpanQuery firstClause, SpanQuery notClause,
+                               int min, int max, int direction,
+                               boolean collectPayloads) {
         super(firstClause, notClause, collectPayloads);
         if (max < min) {
             throw new IllegalArgumentException("The max position has to be "
@@ -167,37 +212,50 @@
         this.isExclusion = true;
     }
 
+
     /**
      * Constructs a SpanExpansionQuery for expansion of the first
-     * {@link SpanQuery} with exclusions of the second {@link SpanQuery}, and
-     * stores expansion offsets in payloads associated with the given class
+     * {@link SpanQuery} with exclusions of the second
+     * {@link SpanQuery}, and
+     * stores expansion offsets in payloads associated with the given
+     * class
      * number.
      * 
-     * @param firstClause the SpanQuery to be expanded
-     * @param notClause the SpanQuery to be excluded
-     * @param min the minimum length of the expansion
-     * @param max the maximum length of the expansion
-     * @param direction the direction of the expansion
-     * @param classNumber the class number for storing expansion offsets in
-     *        payloads
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            the SpanQuery to be expanded
+     * @param notClause
+     *            the SpanQuery to be excluded
+     * @param min
+     *            the minimum length of the expansion
+     * @param max
+     *            the maximum length of the expansion
+     * @param direction
+     *            the direction of the expansion
+     * @param classNumber
+     *            the class number for storing expansion offsets in
+     *            payloads
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanExpansionQuery(SpanQuery firstClause, SpanQuery notClause,
-            int min, int max, int direction, byte classNumber,
-            boolean collectPayloads) {
+    public SpanExpansionQuery (SpanQuery firstClause, SpanQuery notClause,
+                               int min, int max, int direction,
+                               byte classNumber, boolean collectPayloads) {
         this(firstClause, notClause, min, max, direction, collectPayloads);
         this.classNumber = classNumber;
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SpanExpansionQuery sq = null;
         if (isExclusion) {
             sq = new SpanExpansionQuery(firstClause, secondClause, min, max,
                     direction, classNumber, collectPayloads);
-        } else {
+        }
+        else {
             sq = new SpanExpansionQuery(firstClause, min, max, direction,
                     classNumber, collectPayloads);
         }
@@ -205,8 +263,9 @@
         return sq;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         //	      Temporary:
@@ -218,15 +277,17 @@
             return new ExpandedSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanExpansion(");
         sb.append(firstClause.toString());
         if (isExclusion && secondClause != null) {
             sb.append(", !");
             sb.append(secondClause.toString());
-        } else {
+        }
+        else {
             sb.append(", []");
         }
         sb.append("{");
@@ -246,75 +307,88 @@
         return sb.toString();
     }
 
+
     /**
      * Returns the minimum length of the expansion.
      * 
      * @return the minimum length of the expansion
      */
-    public int getMin() {
+    public int getMin () {
         return min;
     }
 
+
     /**
      * Sets the minimum length of the expansion.
      * 
-     * @param min the minimum length of the expansion
+     * @param min
+     *            the minimum length of the expansion
      */
-    public void setMin(int min) {
+    public void setMin (int min) {
         this.min = min;
     }
 
+
     /**
      * Returns the maximum length of the expansion.
      * 
      * @return the maximum length of the expansion
      */
-    public int getMax() {
+    public int getMax () {
         return max;
     }
 
+
     /**
      * Sets the maximum length of the expansion.
      * 
-     * @param max the maximum length of the expansion
+     * @param max
+     *            the maximum length of the expansion
      */
-    public void setMax(int max) {
+    public void setMax (int max) {
         this.max = max;
     }
 
+
     /**
      * Returns the class number associated with the expansion offsets
      * 
      * @return the class number associated with the expansion offsets
      */
-    public byte getClassNumber() {
+    public byte getClassNumber () {
         return classNumber;
     }
 
+
     /**
      * Sets the class number associated with the expansion offsets
      * 
-     * @param classNumber the class number associated with the expansion offsets
+     * @param classNumber
+     *            the class number associated with the expansion
+     *            offsets
      */
-    public void setClassNumber(byte classNumber) {
+    public void setClassNumber (byte classNumber) {
         this.classNumber = classNumber;
     }
 
+
     /**
      * Returns the direction of the expansion
      * 
      * @return the direction of the expansion
      */
-    public int getDirection() {
+    public int getDirection () {
         return direction;
     }
 
+
     /**
      * Sets the direction of the expansion
      * 
-     * @param direction the direction of the expansion
+     * @param direction
+     *            the direction of the expansion
      */
-    public void setDirection(int direction) {
+    public void setDirection (int direction) {
         this.direction = direction;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
index 20fa3ef..30cc536 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
@@ -20,26 +20,30 @@
 
 /**
  * Modify the span of a match to the boundaries of a certain class.
- *
- * In case multiple classes are found with the very same number, the span
- * is maximized to start on the first occurrence from the left and end on
+ * 
+ * In case multiple classes are found with the very same number, the
+ * span
+ * is maximized to start on the first occurrence from the left and end
+ * on
  * the last occurrence on the right.
- *
+ * 
  * In case the class to modify on is not found in the subquery,
  * the match is ignored.
- *
+ * 
  * @author diewald
- *
+ * 
  * @see FocusSpans
  */
 public class SpanFocusQuery extends SpanClassQuery {
 
     /**
      * Construct a new SpanFocusQuery.
-     *
-     * @param operand The nested {@link SpanQuery}, that contains one or
-     *        more classed spans.
-     * @param number The class number to focus on.
+     * 
+     * @param operand
+     *            The nested {@link SpanQuery}, that contains one or
+     *            more classed spans.
+     * @param number
+     *            The class number to focus on.
      */
     public SpanFocusQuery (SpanQuery operand, byte number) {
         super(operand, number);
@@ -49,9 +53,10 @@
     /**
      * Construct a new SpanFocusQuery.
      * The class to focus on defaults to <tt>1</tt>.
-     *
-     * @param operand The nested {@link SpanQuery}, that contains one or
-     *        more classed spans.
+     * 
+     * @param operand
+     *            The nested {@link SpanQuery}, that contains one or
+     *            more classed spans.
      */
     public SpanFocusQuery (SpanQuery operand) {
         this(operand, (byte) 1);
@@ -72,16 +77,10 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context,
-                           Bits acceptDocs,
-                           Map<Term,TermContext> termContexts) throws IOException {
-        return (Spans) new FocusSpans(
-            this.operand,
-            context,
-            acceptDocs,
-            termContexts,
-            number
-        );
+    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+            Map<Term, TermContext> termContexts) throws IOException {
+        return (Spans) new FocusSpans(this.operand, context, acceptDocs,
+                termContexts, number);
     };
 
 
@@ -89,7 +88,7 @@
     public Query rewrite (IndexReader reader) throws IOException {
         SpanFocusQuery clone = null;
         SpanQuery query = (SpanQuery) this.operand.rewrite(reader);
-        
+
         if (query != this.operand) {
             if (clone == null)
                 clone = this.clone();
@@ -104,11 +103,9 @@
 
 
     @Override
-    public SpanFocusQuery clone() {
+    public SpanFocusQuery clone () {
         SpanFocusQuery spanFocusQuery = new SpanFocusQuery(
-            (SpanQuery) this.operand.clone(),
-            this.number
-        );
+                (SpanQuery) this.operand.clone(), this.number);
         spanFocusQuery.setBoost(getBoost());
         return spanFocusQuery;
     };
@@ -116,14 +113,17 @@
 
     @Override
     public boolean equals (Object o) {
-        if (this == o) return true;
-        if (!(o instanceof SpanFocusQuery)) return false;
-	
-        final SpanFocusQuery spanFocusQuery =
-            (SpanFocusQuery) o;
-	
-        if (!this.operand.equals(spanFocusQuery.operand)) return false;
-        if (this.number != spanFocusQuery.number) return false;
+        if (this == o)
+            return true;
+        if (!(o instanceof SpanFocusQuery))
+            return false;
+
+        final SpanFocusQuery spanFocusQuery = (SpanFocusQuery) o;
+
+        if (!this.operand.equals(spanFocusQuery.operand))
+            return false;
+        if (this.number != spanFocusQuery.number)
+            return false;
 
         // Probably not necessary
         return getBoost() == spanFocusQuery.getBoost();
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
index 31b8f26..b8553d9 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
@@ -15,44 +15,58 @@
 import de.ids_mannheim.korap.query.spans.MultipleDistanceSpans;
 
 /**
- * SpanMultipleDistanceQuery matches two spans with respect to a list of
- * distance constraints. No repetition of constraints of the same unit type
- * (e.g. word, sentence, paragraph) is allowed. For example, there must only
- * exactly one constraint for word/token-based distance. A SpanDistanceQuery is
+ * SpanMultipleDistanceQuery matches two spans with respect to a list
+ * of
+ * distance constraints. No repetition of constraints of the same unit
+ * type
+ * (e.g. word, sentence, paragraph) is allowed. For example, there
+ * must only
+ * exactly one constraint for word/token-based distance. A
+ * SpanDistanceQuery is
  * created for each constraint.<br />
  * <br />
  * Examples:
  * <ul>
  * 
  * <li>
- * Search two terms x and y which are separated by minimum two and maximum three
- * other words within the same sentence. The order of x and y does not matter.
+ * Search two terms x and y which are separated by minimum two and
+ * maximum three
+ * other words within the same sentence. The order of x and y does not
+ * matter.
  * 
  * <pre>
- * List&lt;DistanceConstraint&gt; constraints = new ArrayList&lt;DistanceConstraint&gt;();
+ * List&lt;DistanceConstraint&gt; constraints = new
+ * ArrayList&lt;DistanceConstraint&gt;();
  * constraints.add(new DistanceConstraint(2, 3, false, false));
- * constraints.add(DistanceConstraint(new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), 0, 0,
- *         false, false));
+ * constraints.add(DistanceConstraint(new
+ * SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), 0, 0,
+ * false, false));
  * 
- * SpanMultipleDistanceQuery mdq = SpanMultipleDistanceQuery(x, y, constraints,
- *         false, true);
+ * SpanMultipleDistanceQuery mdq = SpanMultipleDistanceQuery(x, y,
+ * constraints,
+ * false, true);
  * </pre>
  * 
  * </li>
  * 
  * <li>
- * Search term x which do <em>not</em> occur with term y in minimum two and
- * maximum three other words and <em>not</em> in the same sentence. X must
+ * Search term x which do <em>not</em> occur with term y in minimum
+ * two and
+ * maximum three other words and <em>not</em> in the same sentence. X
+ * must
  * precede y.
  * 
  * <pre>
- * List&lt;DistanceConstraint&gt; constraints = new ArrayList&lt;DistanceConstraint&gt;();
+ * List&lt;DistanceConstraint&gt; constraints = new
+ * ArrayList&lt;DistanceConstraint&gt;();
  * constraints.add(new DistanceConstraint(2, 3, false, true));
- * constraints.add(DistanceConstraint(new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), 0, 0,
- *         false, true));
+ * constraints.add(DistanceConstraint(new
+ * SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;), 0, 0,
+ * false, true));
  * 
- * SpanMultipleDistanceQuery mdq = SpanMultipleDistanceQuery(x, y, constraints,
- *         true, true);
+ * SpanMultipleDistanceQuery mdq = SpanMultipleDistanceQuery(x, y,
+ * constraints,
+ * true, true);
  * </pre>
  * 
  * </li>
@@ -66,30 +80,42 @@
     private boolean isOrdered;
     private String spanName;
 
+
     /**
-     * Constructs a SpanMultipleDistanceQuery for the two given SpanQueries.
+     * Constructs a SpanMultipleDistanceQuery for the two given
+     * SpanQueries.
      * 
-     * @param firstClause the first SpanQuery
-     * @param secondClause the second SpanQuery
-     * @param constraints the list of distance constraints
-     * @param isOrdered a boolean representing the value <code>true</code>, if
-     *        the firstspans must occur before the secondspans, otherwise
-     *        <code>false</code>.
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            the first SpanQuery
+     * @param secondClause
+     *            the second SpanQuery
+     * @param constraints
+     *            the list of distance constraints
+     * @param isOrdered
+     *            a boolean representing the value <code>true</code>,
+     *            if
+     *            the firstspans must occur before the secondspans,
+     *            otherwise
+     *            <code>false</code>.
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanMultipleDistanceQuery(SpanQuery firstClause,
-            SpanQuery secondClause, List<DistanceConstraint> constraints,
-            boolean isOrdered, boolean collectPayloads) {
+    public SpanMultipleDistanceQuery (SpanQuery firstClause,
+                                      SpanQuery secondClause,
+                                      List<DistanceConstraint> constraints,
+                                      boolean isOrdered, boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
         this.constraints = constraints;
         this.isOrdered = isOrdered;
         spanName = "spanMultipleDistance";
     }
 
+
     @Override
-    public SpanMultipleDistanceQuery clone() {
+    public SpanMultipleDistanceQuery clone () {
         SpanMultipleDistanceQuery query = new SpanMultipleDistanceQuery(
                 (SpanQuery) firstClause.clone(),
                 (SpanQuery) secondClause.clone(), this.constraints,
@@ -99,8 +125,9 @@
         return query;
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append(this.spanName);
         sb.append("(");
@@ -131,14 +158,16 @@
         return sb.toString();
     }
 
+
     /**
-     * Filters the span matches of each constraint, returning only the matches
+     * Filters the span matches of each constraint, returning only the
+     * matches
      * meeting all the constraints.
      * 
      * @return only the span matches meeting all the constraints.
      * */
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         SpanDistanceQuery sdq, sdq2;
@@ -164,21 +193,24 @@
         return mds;
     }
 
+
     /**
      * Returns the list of distance constraints.
      * 
      * @return the list of distance constraints
      */
-    public List<DistanceConstraint> getConstraints() {
+    public List<DistanceConstraint> getConstraints () {
         return constraints;
     }
 
+
     /**
      * Sets the list of distance constraints.
      * 
-     * @param constraints the list of distance constraints
+     * @param constraints
+     *            the list of distance constraints
      */
-    public void setConstraints(List<DistanceConstraint> constraints) {
+    public void setConstraints (List<DistanceConstraint> constraints) {
         this.constraints = constraints;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
index dbef6db..6a0c679 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
@@ -22,18 +22,22 @@
  */
 
 /**
- * SpanNextQuery matches two spans which are directly next to each other. It is
+ * SpanNextQuery matches two spans which are directly next to each
+ * other. It is
  * identical to a phrase query with exactly two clauses.
  * 
- * In the example below, the SpanNextQuery retrieves {@link NextSpans} starting
- * from the start position of {@link TermSpans} "turn" and ending at the end
+ * In the example below, the SpanNextQuery retrieves {@link NextSpans}
+ * starting
+ * from the start position of {@link TermSpans} "turn" and ending at
+ * the end
  * position of {@link TermSpans} "off" occurring immediately after the
  * {@link TermSpans} "turn".
  * 
  * <pre>
  * SpanNextQuery sq = new SpanNextQuery(
- *      new SpanTermQuery(new Term(&quot;tokens&quot;,&quot;s:turn&quot;)), 
- *      new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;s:off&quot;)));
+ * new SpanTermQuery(new Term(&quot;tokens&quot;,&quot;s:turn&quot;)),
+ * new SpanTermQuery(new Term(&quot;tokens&quot;,
+ * &quot;s:off&quot;)));
  * </pre>
  * 
  * @author diewald
@@ -43,42 +47,55 @@
 public class SpanNextQuery extends SimpleSpanQuery implements Cloneable {
 
     /**
-     * Constructs a SpanNextQuery for the two specified {@link SpanQuery
-     * SpanQueries} whose payloads are to be collected for the resulting
-     * {@link NextSpans}. The first SpanQuery is immediately followed by the
+     * Constructs a SpanNextQuery for the two specified
+     * {@link SpanQuery
+     * SpanQueries} whose payloads are to be collected for the
+     * resulting {@link NextSpans}. The first SpanQuery is immediately
+     * followed by the
      * second SpanQuery.
      * 
-     * @param firstClause the first SpanQuery
-     * @param secondClause the second SpanQuery
+     * @param firstClause
+     *            the first SpanQuery
+     * @param secondClause
+     *            the second SpanQuery
      */
-    public SpanNextQuery(SpanQuery firstClause, SpanQuery secondClause) {
+    public SpanNextQuery (SpanQuery firstClause, SpanQuery secondClause) {
         this(firstClause, secondClause, true);
     };
 
+
     /**
-     * Constructs a SpanNextQuery for the two specified {@link SpanQuery
-     * SpanQueries} where the first SpanQuery is immediately followed by the
+     * Constructs a SpanNextQuery for the two specified
+     * {@link SpanQuery
+     * SpanQueries} where the first SpanQuery is immediately followed
+     * by the
      * second SpanQuery.
      * 
-     * @param firstClause the first SpanQuery
-     * @param secondClause the second SpanQuery
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            the first SpanQuery
+     * @param secondClause
+     *            the second SpanQuery
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanNextQuery(SpanQuery firstClause, SpanQuery secondClause,
-            boolean collectPayloads) {
+    public SpanNextQuery (SpanQuery firstClause, SpanQuery secondClause,
+                          boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
     };
 
+
     @Override
-    public Spans getSpans(final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new NextSpans(this, context, acceptDocs, termContexts);
     };
 
+
     @Override
-    public SpanNextQuery clone() {
+    public SpanNextQuery clone () {
         SpanNextQuery spanNextQuery = new SpanNextQuery(
                 (SpanQuery) firstClause.clone(),
                 (SpanQuery) secondClause.clone(), collectPayloads);
@@ -86,11 +103,12 @@
         return spanNextQuery;
     };
 
+
     /*
      * Rewrite query in case it includes regular expressions or wildcards
      */
     @Override
-    public Query rewrite(IndexReader reader) throws IOException {
+    public Query rewrite (IndexReader reader) throws IOException {
         SpanNextQuery clone = null;
 
         // Does the first clause needs a rewrite?
@@ -99,8 +117,7 @@
             if (clone == null)
                 clone = this.clone();
             clone.firstClause = query;
-        }
-        ;
+        };
 
         // Does the second clause needs a rewrite?
         query = (SpanQuery) secondClause.rewrite(reader);
@@ -108,8 +125,7 @@
             if (clone == null)
                 clone = this.clone();
             clone.secondClause = query;
-        }
-        ;
+        };
 
         // There is a clone and it is important
         if (clone != null)
@@ -118,8 +134,9 @@
         return this;
     };
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanNext(");
         sb.append(firstClause.toString(field));
@@ -130,9 +147,10 @@
         return sb.toString();
     }
 
+
     /** Returns true iff <code>o</code> is equal to this. */
     @Override
-    public boolean equals(Object o) {
+    public boolean equals (Object o) {
         if (this == o)
             return true;
         if (!(o instanceof SpanNextQuery))
@@ -150,9 +168,10 @@
         return getBoost() == spanNextQuery.getBoost();
     };
 
+
     // I don't know what I am doing here
     @Override
-    public int hashCode() {
+    public int hashCode () {
         int result;
         result = firstClause.hashCode() + secondClause.hashCode();
         result ^= (result << 31) | (result >>> 2); // reversible
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
index 0433b2f..f19a1dc 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
@@ -14,29 +14,36 @@
 import de.ids_mannheim.korap.query.spans.RelationSpans;
 
 /**
- * SpanRelationQuery retrieves spans representing a relation between tokens,
- * elements, or a-token-and-an-element. Relation are marked with prefix "<" or
- * ">". The direction of the angle bracket represents the direction of the 
+ * SpanRelationQuery retrieves spans representing a relation between
+ * tokens,
+ * elements, or a-token-and-an-element. Relation are marked with
+ * prefix "<" or
+ * ">". The direction of the angle bracket represents the direction of
+ * the
  * corresponding relation. <br/><br/>
  * 
  * This class provides two types of query:
  * <ol>
- * <li>querying any relations, for instance dependency relation "<:xip/syntax-dep_rel".
+ * <li>querying any relations, for instance dependency relation
+ * "<:xip/syntax-dep_rel".
  * 
  * <pre>SpanRelationQuery sq = new SpanRelationQuery(
- *          new SpanTermQuery(
- *              new Term("tokens","<:xip/syntax-dep_rel")),
- *          true); 
+ * new SpanTermQuery(
+ * new Term("tokens","<:xip/syntax-dep_rel")),
+ * true);
  * </pre>
  * </li>
- * <li>querying relations matching a certain type of sources/targets, that are the
- * left or the right sides of the relations. This query is used within 
- * {@link SpanRelationPartQuery}, for instance, to retrieve all dependency relations 
- * "<:xip/syntax-dep_rel" whose sources (right side) are noun phrases. 
+ * <li>querying relations matching a certain type of sources/targets,
+ * that are the
+ * left or the right sides of the relations. This query is used within
+ * {@link SpanRelationPartQuery}, for instance, to retrieve all
+ * dependency relations
+ * "<:xip/syntax-dep_rel" whose sources (right side) are noun phrases.
  * <pre>
  * SpanRelationPartQuery rv =
- *      new SpanRelationPartQuery(sq, new SpanElementQuery("tokens","np"), true, 
- *      false, true);
+ * new SpanRelationPartQuery(sq, new SpanElementQuery("tokens","np"),
+ * true,
+ * false, true);
  * </pre>
  * </li>
  * 
@@ -48,33 +55,40 @@
 
     private String type;
 
+
     /**
      * Constructs a SpanRelationQuery based on the given span query.
      * 
-     * @param firstClause a SpanQuery.
+     * @param firstClause
+     *            a SpanQuery.
      * @param collectPayloads
-     *            a boolean flag representing the value <code>true</code> if
-     *            payloads are to be collected, otherwise <code>false</code>.
+     *            a boolean flag representing the value
+     *            <code>true</code> if
+     *            payloads are to be collected, otherwise
+     *            <code>false</code>.
      */
-    public SpanRelationQuery(SpanQuery firstClause, boolean collectPayloads) {
+    public SpanRelationQuery (SpanQuery firstClause, boolean collectPayloads) {
         super(firstClause, collectPayloads);
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SimpleSpanQuery sq = new SpanRelationQuery(
                 (SpanQuery) this.firstClause.clone(), this.collectPayloads);
         return sq;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new RelationSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanRelation(");
         sb.append(firstClause.toString(field));
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
index 9ea420f..7e95bf6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
@@ -14,30 +14,36 @@
 import de.ids_mannheim.korap.query.spans.RepetitionSpans;
 
 /**
- * SpanRepetitionQuery means that the given SpanQuery must appears multiple
- * times in a sequence. The number of repetition depends on the minimum and the
+ * SpanRepetitionQuery means that the given SpanQuery must appears
+ * multiple
+ * times in a sequence. The number of repetition depends on the
+ * minimum and the
  * maximum number parameters. <br />
  * <br />
  * 
- * In the example below, SpanRepetitionQuery retrieves {@link RepetitionSpans}
- * consisting of the TermSpans "tt:p/ADJ" that must appear at least once or
- * consecutively two times. What appears after the RepetitionSpans is not
+ * In the example below, SpanRepetitionQuery retrieves
+ * {@link RepetitionSpans} consisting of the TermSpans "tt:p/ADJ" that
+ * must appear at least once or
+ * consecutively two times. What appears after the RepetitionSpans is
+ * not
  * considered, so it is possible that it is another "tt:p/ADJ". <br />
  * <br />
  * 
  * <pre>
- * SpanRepetitionQuery sq = new SpanRepetitionQuery(new SpanTermQuery(new Term(
- *         &quot;tokens&quot;, &quot;tt:p/ADJ&quot;)), 1, 2, true);
+ * SpanRepetitionQuery sq = new SpanRepetitionQuery(new
+ * SpanTermQuery(new Term(
+ * &quot;tokens&quot;, &quot;tt:p/ADJ&quot;)), 1, 2, true);
  * </pre>
  * 
- * For instance, "a large black leather jacket" contains the following matches.
+ * For instance, "a large black leather jacket" contains the following
+ * matches.
  * 
  * <pre>
- *  [large]
- *  [large black]
- *  [black]
- *  [black leather]
- *  [leather]
+ * [large]
+ * [large black]
+ * [black]
+ * [black leather]
+ * [leather]
  * </pre>
  * 
  * @author margaretha
@@ -46,25 +52,33 @@
 
     private int min, max;
 
+
     /**
-     * Constructs a SpanRepetitionQuery for the given {@link SpanQuery}.
+     * Constructs a SpanRepetitionQuery for the given
+     * {@link SpanQuery}.
      * 
-     * @param sq a SpanQuery
-     * @param min the minimum number of the required repetition
-     * @param max the maximum number of the required repetition
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param sq
+     *            a SpanQuery
+     * @param min
+     *            the minimum number of the required repetition
+     * @param max
+     *            the maximum number of the required repetition
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanRepetitionQuery(SpanQuery sq, int min, int max,
-            boolean collectPayloads) {
+    public SpanRepetitionQuery (SpanQuery sq, int min, int max,
+                                boolean collectPayloads) {
         super(sq, collectPayloads);
         this.min = min;
         this.max = max;
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SpanRepetitionQuery sq = new SpanRepetitionQuery(
                 (SpanQuery) this.firstClause.clone(), this.min, this.max,
                 this.collectPayloads);
@@ -72,14 +86,16 @@
         return sq;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new RepetitionSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanRepetition(");
         sb.append(firstClause.toString(field));
@@ -92,39 +108,45 @@
         return sb.toString();
     }
 
+
     /**
      * Returns the minimum number of required repetitions.
      * 
      * @return the minimum number of required repetitions
      */
-    public int getMin() {
+    public int getMin () {
         return min;
     }
 
+
     /**
      * Sets the minimum number of required repetitions.
      * 
-     * @param min the minimum number of required repetitions
+     * @param min
+     *            the minimum number of required repetitions
      */
-    public void setMin(int min) {
+    public void setMin (int min) {
         this.min = min;
     }
 
+
     /**
      * Returns the maximum number of required repetitions.
      * 
      * @return the maximum number of required repetitions
      */
-    public int getMax() {
+    public int getMax () {
         return max;
     }
 
+
     /**
      * Sets the maximum number of required repetitions.
      * 
-     * @param max the maximum number of required repetitions
+     * @param max
+     *            the maximum number of required repetitions
      */
-    public void setMax(int max) {
+    public void setMax (int max) {
         this.max = max;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
index 39c2a59..512adc0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
@@ -14,59 +14,75 @@
 import de.ids_mannheim.korap.query.spans.SegmentSpans;
 
 /**
- * SpanSegmentQuery matches two spans having exactly the same start and end
+ * SpanSegmentQuery matches two spans having exactly the same start
+ * and end
  * positions, for instance:
  * 
  * <pre>
- * sq = new SpanSegmentQuery(new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;s:Hund&quot;)),
- *         new SpanTermQuery(new Term(&quot;tokens&quot;, &quot;tt/p:NN&quot;)));
+ * sq = new SpanSegmentQuery(new SpanTermQuery(new
+ * Term(&quot;tokens&quot;, &quot;s:Hund&quot;)),
+ * new SpanTermQuery(new Term(&quot;tokens&quot;,
+ * &quot;tt/p:NN&quot;)));
  * </pre>
  * 
  * @author margaretha
  * */
 public class SpanSegmentQuery extends SimpleSpanQuery {
 
-	private boolean isRelation;
+    private boolean isRelation;
+
 
     /**
-     * Constructs a SpanSegmentQuery from the two given SpanQueries, by default
+     * Constructs a SpanSegmentQuery from the two given SpanQueries,
+     * by default
      * payloads are to be collected.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param secondClause a {@link SpanQuery}
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param secondClause
+     *            a {@link SpanQuery}
      */
-    public SpanSegmentQuery(SpanQuery firstClause, SpanQuery secondClause) {
+    public SpanSegmentQuery (SpanQuery firstClause, SpanQuery secondClause) {
         this(firstClause, secondClause, true);
     }
 
+
     /**
      * Constructs a SpanSegmentQuery from the two given SpanQueries.
      * 
-     * @param firstClause a {@link SpanQuery}
-     * @param secondClause a {@link SpanQuery}
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a {@link SpanQuery}
+     * @param secondClause
+     *            a {@link SpanQuery}
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanSegmentQuery(SpanQuery firstClause, SpanQuery secondClause,
-            boolean collectPayloads) {
+    public SpanSegmentQuery (SpanQuery firstClause, SpanQuery secondClause,
+                             boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
     }
 
-	public SpanSegmentQuery(SpanRelationQuery firstClause,
-			SpanWithIdQuery secondClause, boolean collectPayloads) {
-		super(firstClause, secondClause, true);
-		isRelation = true;
+
+    public SpanSegmentQuery (SpanRelationQuery firstClause,
+                             SpanWithIdQuery secondClause,
+                             boolean collectPayloads) {
+        super(firstClause, secondClause, true);
+        isRelation = true;
     }
-    
+
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new SegmentSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public SpanSegmentQuery clone() {
+    public SpanSegmentQuery clone () {
         SpanSegmentQuery spanSegmentQuery = new SpanSegmentQuery(
                 (SpanQuery) firstClause.clone(),
                 (SpanQuery) secondClause.clone(), collectPayloads);
@@ -74,8 +90,9 @@
         return spanSegmentQuery;
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanSegment(");
         sb.append(firstClause.toString(field));
@@ -86,8 +103,9 @@
         return sb.toString();
     }
 
+
     @Override
-    public boolean equals(Object o) {
+    public boolean equals (Object o) {
         if (this == o)
             return true;
         if (!(o instanceof SpanSegmentQuery))
@@ -105,21 +123,24 @@
         return getBoost() == spanSegmentQuery.getBoost();
     };
 
+
     @Override
-    public int hashCode() {
+    public int hashCode () {
         int result;
         result = firstClause.hashCode() + secondClause.hashCode();
         result ^= (31 * result) + (result >>> 3);
         result += Float.floatToRawIntBits(getBoost());
         return result;
-	}
+    }
 
-	public boolean isRelation() {
-		return isRelation;
-	}
 
-	public void setRelation(boolean isRelation) {
-		this.isRelation = isRelation;
-	};
+    public boolean isRelation () {
+        return isRelation;
+    }
+
+
+    public void setRelation (boolean isRelation) {
+        this.isRelation = isRelation;
+    };
 
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
index d16042e..010d077 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
@@ -14,20 +14,26 @@
 import de.ids_mannheim.korap.query.spans.SubSpans;
 
 /**
- * This query extracts a subspan from another span. The subspan starts from a
- * startOffset until startOffset + length. A positive startOffset is counted
- * from the start of the span, while a negative startOffset is calculated from
+ * This query extracts a subspan from another span. The subspan starts
+ * from a
+ * startOffset until startOffset + length. A positive startOffset is
+ * counted
+ * from the start of the span, while a negative startOffset is
+ * calculated from
  * the end of the span. <br />
  * <br />
- * SpanSubspanQuery takes a SpanQuery as its input and creates subspans from the
+ * SpanSubspanQuery takes a SpanQuery as its input and creates
+ * subspans from the
  * resulting spans of the SpanQuery. For instance:
  * 
  * <pre>
- * SpanElementQuery seq = new SpanElementQuery(new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
+ * SpanElementQuery seq = new SpanElementQuery(new
+ * SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
  * SpanSubspanQuery ssq = new SpanSubspanQuery(seq, 0, 2, true);
  * </pre>
  * 
- * In this example, the SpanSubspanQuery creates subspans, that are the first
+ * In this example, the SpanSubspanQuery creates subspans, that are
+ * the first
  * two tokens of all sentences. It also collects all payloads from the
  * {@link ElementSpans} for the SubSpans.
  * 
@@ -37,85 +43,100 @@
 
     private int startOffset, length;
 
+
     /**
-     * Creates a SpanSubspanQuery (subspan) from the given {@link SpanQuery}
-     * with the specified startOffset and length.
+     * Creates a SpanSubspanQuery (subspan) from the given
+     * {@link SpanQuery} with the specified startOffset and length.
      * 
-     * @param firstClause a SpanQuery
-     * @param startOffset the start offset of the subspan relative to the
-     *        original span
-     * @param length the length of the subspan
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a SpanQuery
+     * @param startOffset
+     *            the start offset of the subspan relative to the
+     *            original span
+     * @param length
+     *            the length of the subspan
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanSubspanQuery(SpanQuery firstClause, int startOffset, int length,
-            boolean collectPayloads) {
+    public SpanSubspanQuery (SpanQuery firstClause, int startOffset,
+                             int length, boolean collectPayloads) {
         super(firstClause, collectPayloads);
         this.startOffset = startOffset;
         this.length = length;
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SpanSubspanQuery sq = new SpanSubspanQuery(this.getFirstClause(),
                 this.startOffset, this.length, this.collectPayloads);
         sq.setBoost(this.getBoost());
         return sq;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new SubSpans(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("subspan(");
         sb.append(this.firstClause.toString());
-		sb.append(", ");
+        sb.append(", ");
         sb.append(this.startOffset);
-		sb.append(", ");
+        sb.append(", ");
         sb.append(this.length);
         sb.append(")");
         return sb.toString();
     }
 
+
     /**
      * Returns the start offset.
      * 
      * @return the start offset.
      */
-    public int getStartOffset() {
+    public int getStartOffset () {
         return startOffset;
     }
 
+
     /**
      * Sets the start offset.
      * 
-     * @param startOffset the start offset
+     * @param startOffset
+     *            the start offset
      */
-    public void setStartOffset(int startOffset) {
+    public void setStartOffset (int startOffset) {
         this.startOffset = startOffset;
     }
 
+
     /**
      * Returns the length of the subspan.
      * 
      * @return the length of the subspan
      */
-    public int getLength() {
+    public int getLength () {
         return length;
     }
 
+
     /**
      * Sets the length of the subspan.
      * 
-     * @param length the length of the subspan.
+     * @param length
+     *            the length of the subspan.
      */
-    public void setLength(int length) {
+    public void setLength (int length) {
         this.length = length;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
index fa70878..84e30b2 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
@@ -14,16 +14,20 @@
 import de.ids_mannheim.korap.query.spans.TermSpansWithId;
 
 /**
- * SpanTermWithIdQuery wraps a SpanTermQuery retrieving TermSpans and add a
- * spanid to the TermSpans. It is used in other spanqueries requiring spans with
- * id as their child spans, for example in span relation with variable query (
- * {@link SpanRelationPartQuery}).
+ * SpanTermWithIdQuery wraps a SpanTermQuery retrieving TermSpans and
+ * add a
+ * spanid to the TermSpans. It is used in other spanqueries requiring
+ * spans with
+ * id as their child spans, for example in span relation with variable
+ * query ( {@link SpanRelationPartQuery}).
  * 
  * <pre>
- * SpanTermWithIdQuery sq = new SpanTermWithIdQuery(new Term("base","tt:p/NN"),true)
+ * SpanTermWithIdQuery sq = new SpanTermWithIdQuery(new
+ * Term("base","tt:p/NN"),true)
  * </pre>
  * 
- * In this example, the SpanTermWithIdQuery retrieves {@link SpansWithId} for
+ * In this example, the SpanTermWithIdQuery retrieves
+ * {@link SpansWithId} for
  * the Term "tt:p/NN".
  * 
  * @author margaretha
@@ -33,29 +37,35 @@
     /**
      * Constructs a SpanTermWithIdQuery for the given term.
      * 
-     * @param term a {@link Term}
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param term
+     *            a {@link Term}
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanTermWithIdQuery(Term term, boolean collectPayloads) {
+    public SpanTermWithIdQuery (Term term, boolean collectPayloads) {
         super(new SpanTermQuery(term), collectPayloads);
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         SpanTermQuery sq = (SpanTermQuery) this.firstClause;
         return new SpanTermWithIdQuery(sq.getTerm(), this.collectPayloads);
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new TermSpansWithId(this, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder sb = new StringBuilder();
         sb.append("spanTermWithId(");
         sb.append(firstClause.toString(field));
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
index 4d5c011..12d6876 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
@@ -29,10 +29,12 @@
  * <code>@:class=header</code>.
  * 
  * <pre>
- * SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(new Term(
- *         &quot;tokens&quot;, &quot;@:class=header&quot;)), true);
- * SpanWithAttributeQuery sq = new SpanWithAttributeQuery(new SpanElementQuery(
- *         &quot;tokens&quot;, &quot;div&quot;), saq, true);
+ * SpanAttributeQuery saq = new SpanAttributeQuery(new
+ * SpanTermQuery(new Term(
+ * &quot;tokens&quot;, &quot;@:class=header&quot;)), true);
+ * SpanWithAttributeQuery sq = new SpanWithAttributeQuery(new
+ * SpanElementQuery(
+ * &quot;tokens&quot;, &quot;div&quot;), saq, true);
  * </pre>
  * 
  * 
@@ -43,6 +45,7 @@
     public boolean isMultipleAttributes;
     private String type;
 
+
     /**
      * Constructs a SpanWithAttributeQuery for any arbitrary
      * SpansWithId (e.g. elements, relations) having the specified
@@ -56,18 +59,20 @@
      *            otherwise <code>false</code>.
      */
     public SpanWithAttributeQuery (SpanAttributeQuery attributeQuery,
-            boolean collectPayloads) {
+                                   boolean collectPayloads) {
         super(attributeQuery, collectPayloads);
         type = "spanWithAttribute";
     }
 
+
     public SpanWithAttributeQuery (List<SpanQuery> attributeQueries,
-            boolean collectPayloads) {
+                                   boolean collectPayloads) {
         super(attributeQueries, collectPayloads);
         isMultipleAttributes = true;
         type = "spanWithAttribute";
     }
 
+
     /**
      * Constructs a SpanWithAttributeQuery for the specified
      * SpanWithIdQuery and SpanAttributeQuery retrieving spans having
@@ -87,11 +92,13 @@
      *            otherwise <code>false</code>.
      */
     public SpanWithAttributeQuery (SpanWithIdQuery firstClause,
-            SpanAttributeQuery secondClause, boolean collectPayloads) {
+                                   SpanAttributeQuery secondClause,
+                                   boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
         setType();
     }
 
+
     /**
      * @param firstClause
      *            a SpanWithIdQuery
@@ -103,27 +110,30 @@
      *            otherwise <code>false</code>.
      */
     public SpanWithAttributeQuery (SpanWithIdQuery firstClause,
-            List<SpanQuery> secondClauses, boolean collectPayloads) {
+                                   List<SpanQuery> secondClauses,
+                                   boolean collectPayloads) {
         super(firstClause, secondClauses, collectPayloads);
         isMultipleAttributes = true;
         setType();
     }
 
+
     /**
      * Returns the type of the query.
      * 
      * @return the type of the query
      */
-    public String getType() {
+    public String getType () {
         return type;
     }
 
+
     /**
      * Sets the type of the query based of the class of the
      * firstClause / first span.
      * 
      */
-    public void setType() {
+    public void setType () {
         if (SpanElementQuery.class.isInstance(firstClause)) {
             type = "spanElementWithAttribute";
         }
@@ -135,8 +145,9 @@
         }
     }
 
+
     @Override
-    public SimpleSpanQuery clone() {
+    public SimpleSpanQuery clone () {
         if (secondClause != null) {
             if (isMultipleAttributes) {
                 return new SpanWithAttributeQuery(
@@ -163,7 +174,8 @@
         }
     }
 
-    private List<SpanQuery> cloneClauseList() {
+
+    private List<SpanQuery> cloneClauseList () {
         List<SpanQuery> clauseList = new ArrayList<SpanQuery>();
         SpanAttributeQuery saq;
         for (SpanQuery q : this.clauseList) {
@@ -173,8 +185,9 @@
         return clauseList;
     }
 
+
     @Override
-    public Spans getSpans(AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         if (type.equals("spanWithAttribute")) {
@@ -203,8 +216,9 @@
         }
     }
 
+
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         boolean isFirstClassNull = true;
         StringBuilder sb = new StringBuilder();
         sb.append(type);
@@ -218,7 +232,8 @@
             sb.append(secondClause.toString(field));
         }
         else if (isMultipleAttributes) {
-            if (!isFirstClassNull) sb.append(", ");
+            if (!isFirstClassNull)
+                sb.append(", ");
             sb.append("[");
 
             SpanQuery sq;
@@ -226,7 +241,8 @@
                 sq = clauseList.get(i);
                 sb.append(sq.toString(field));
 
-                if (i < clauseList.size() - 1) sb.append(", ");
+                if (i < clauseList.size() - 1)
+                    sb.append(", ");
             }
 
             sb.append("]");
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
index 4845a01..3545808 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithIdQuery.java
@@ -5,7 +5,8 @@
 import org.apache.lucene.search.spans.SpanQuery;
 
 /**
- * Base query for span queries whose resulting spans requires an id, for
+ * Base query for span queries whose resulting spans requires an id,
+ * for
  * instance {@link SpanElementQuery} and {@link SpanRelationQuery}.
  * 
  * @author margaretha
@@ -14,51 +15,69 @@
 public abstract class SpanWithIdQuery extends SimpleSpanQuery {
 
     /**
-     * Constructs SpanWithIdQuery based on the given {@link SpanQuery} and the
+     * Constructs SpanWithIdQuery based on the given {@link SpanQuery}
+     * and the
      * collectPayloads flag, for example, {@link SpanElementQuery}.
      * 
-     * @param firstClause a SpanQuery
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a SpanQuery
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanWithIdQuery(SpanQuery firstClause, boolean collectPayloads) {
+    public SpanWithIdQuery (SpanQuery firstClause, boolean collectPayloads) {
         super(firstClause, collectPayloads);
     }
 
+
     /**
      * Constructs SpanWithIdQuery based on two span queries and the
-     * collectPayloads flag, for instance, query a relation having a specific
+     * collectPayloads flag, for instance, query a relation having a
+     * specific
      * attribute.
      * 
-     * @param firstClause a SpanQuery
-     * @param secondClause a SpanQuery
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a SpanQuery
+     * @param secondClause
+     *            a SpanQuery
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanWithIdQuery(SpanQuery firstClause, SpanQuery secondClause,
-            boolean collectPayloads) {
+    public SpanWithIdQuery (SpanQuery firstClause, SpanQuery secondClause,
+                            boolean collectPayloads) {
         super(firstClause, secondClause, collectPayloads);
     }
 
+
     /**
-     * Constructs SpanWithIdQuery based on a span query and a list of span
-     * queries, for instance, query an element having two specific attributes.
+     * Constructs SpanWithIdQuery based on a span query and a list of
+     * span
+     * queries, for instance, query an element having two specific
+     * attributes.
      * 
-     * @param firstClause a SpanQuery
-     * @param secondClauses a list of SpanQuery
-     * @param collectPayloads a boolean flag representing the value
-     *        <code>true</code> if payloads are to be collected, otherwise
-     *        <code>false</code>.
+     * @param firstClause
+     *            a SpanQuery
+     * @param secondClauses
+     *            a list of SpanQuery
+     * @param collectPayloads
+     *            a boolean flag representing the value
+     *            <code>true</code> if payloads are to be collected,
+     *            otherwise
+     *            <code>false</code>.
      */
-    public SpanWithIdQuery(SpanQuery firstClause,
-            List<SpanQuery> secondClauses, boolean collectPayloads) {
+    public SpanWithIdQuery (SpanQuery firstClause,
+                            List<SpanQuery> secondClauses,
+                            boolean collectPayloads) {
         super(firstClause, secondClauses, collectPayloads);
     }
 
-	public SpanWithIdQuery(List<SpanQuery> clauses,
-			boolean collectPayloads) {
-		super(clauses, collectPayloads);
-	}
+
+    public SpanWithIdQuery (List<SpanQuery> clauses, boolean collectPayloads) {
+        super(clauses, collectPayloads);
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
index c25b187..ee79869 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
@@ -35,22 +35,18 @@
     private byte flag;
     private boolean collectPayloads;
 
-    public static final byte
-        OVERLAP      = WithinSpans.OVERLAP,
-        REAL_OVERLAP = WithinSpans.REAL_OVERLAP,
-        WITHIN       = WithinSpans.WITHIN,
-        REAL_WITHIN  = WithinSpans.REAL_WITHIN,
-        ENDSWITH     = WithinSpans.ENDSWITH,
-        STARTSWITH   = WithinSpans.STARTSWITH,
-        MATCH        = WithinSpans.MATCH;
+    public static final byte OVERLAP = WithinSpans.OVERLAP,
+            REAL_OVERLAP = WithinSpans.REAL_OVERLAP,
+            WITHIN = WithinSpans.WITHIN, REAL_WITHIN = WithinSpans.REAL_WITHIN,
+            ENDSWITH = WithinSpans.ENDSWITH,
+            STARTSWITH = WithinSpans.STARTSWITH, MATCH = WithinSpans.MATCH;
+
 
     // may support "starting" and "ending"
 
 
     // Constructor
-    public SpanWithinQuery (SpanQuery wrap,
-                            SpanQuery embedded,
-                            byte flag,
+    public SpanWithinQuery (SpanQuery wrap, SpanQuery embedded, byte flag,
                             boolean collectPayloads) {
 
         this.field = embedded.getField();
@@ -62,72 +58,73 @@
 
 
     // Constructor
-    public SpanWithinQuery(String element,
-                           SpanQuery embedded) {
+    public SpanWithinQuery (String element, SpanQuery embedded) {
         this(element, embedded, WITHIN, true);
     };
 
 
     // Constructor
-    public SpanWithinQuery (String element,
-                            SpanQuery embedded,
-                            byte flag,
+    public SpanWithinQuery (String element, SpanQuery embedded, byte flag,
                             boolean collectPayloads) {
-        this(
-             (SpanQuery) new SpanElementQuery(embedded.getField(), element),
-             embedded,
-             flag,
-             collectPayloads
-             );
+        this((SpanQuery) new SpanElementQuery(embedded.getField(), element),
+                embedded, flag, collectPayloads);
     };
 
 
     // Constructor
-    public SpanWithinQuery(String element,
-                           SpanQuery embedded,
-                           byte flag) {
+    public SpanWithinQuery (String element, SpanQuery embedded, byte flag) {
         this(element, embedded, flag, true);
     };
 
 
     // Constructor
-    public SpanWithinQuery (String element,
-                            SpanQuery embedded,
+    public SpanWithinQuery (String element, SpanQuery embedded,
                             boolean collectPayloads) {
         this(element, embedded, WITHIN, collectPayloads);
     };
 
 
     // Constructor
-    public SpanWithinQuery(SpanQuery wrap,
-                           SpanQuery embedded,
-                           byte flag) {
+    public SpanWithinQuery (SpanQuery wrap, SpanQuery embedded, byte flag) {
         this(wrap, embedded, flag, true);
     };
 
 
     // Constructor
-    public SpanWithinQuery(SpanQuery wrap,
-                           SpanQuery embedded) {
+    public SpanWithinQuery (SpanQuery wrap, SpanQuery embedded) {
         this(wrap, embedded, WITHIN, true);
     };
 
 
     @Override
-    public String getField()    { return field;    };
-    public SpanQuery wrap()     { return wrap;     };
-    public SpanQuery embedded() { return embedded; };
-    public byte flag()          { return flag; };
+    public String getField () {
+        return field;
+    };
 
-    
+
+    public SpanQuery wrap () {
+        return wrap;
+    };
+
+
+    public SpanQuery embedded () {
+        return embedded;
+    };
+
+
+    public byte flag () {
+        return flag;
+    };
+
+
     @Override
-    public void extractTerms(Set<Term> terms) {
+    public void extractTerms (Set<Term> terms) {
         embedded.extractTerms(terms);
     };
-  
+
 
     @Override
-    public String toString(String field) {
+    public String toString (String field) {
         StringBuilder buffer = new StringBuilder();
         buffer.append("span");
         buffer.append(flagToString());
@@ -139,38 +136,36 @@
         buffer.append(ToStringUtils.boost(getBoost()));
         return buffer.toString();
     };
-    
+
 
     private String flagToString () {
         switch (flag) {
-        case OVERLAP:
-            return "Overlap";
-        case REAL_OVERLAP:
-            return "OverlapStrict";
-        case WITHIN:
-            return "Contain";
-        case REAL_WITHIN:
-            return "ContainStrict";
-        case ENDSWITH:
-            return "EndsWith";
-        case STARTSWITH:
-            return "StartsWith";
-        case MATCH:
-            return "Match";
+            case OVERLAP:
+                return "Overlap";
+            case REAL_OVERLAP:
+                return "OverlapStrict";
+            case WITHIN:
+                return "Contain";
+            case REAL_WITHIN:
+                return "ContainStrict";
+            case ENDSWITH:
+                return "EndsWith";
+            case STARTSWITH:
+                return "StartsWith";
+            case MATCH:
+                return "Match";
         };
         return "Contains";
     };
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context,
-                           Bits acceptDocs,
-                           Map<Term,TermContext> termContexts) throws IOException {
-        return (Spans) new WithinSpans (
-            this, context, acceptDocs, termContexts, this.flag
-        );
+    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+            Map<Term, TermContext> termContexts) throws IOException {
+        return (Spans) new WithinSpans(this, context, acceptDocs, termContexts,
+                this.flag);
     };
-    
+
 
     /*
      * Rewrite query in case it includes regular expressions or wildcards
@@ -201,16 +196,13 @@
 
         return this;
     };
-  
+
 
     @Override
     public SpanWithinQuery clone () {
         SpanWithinQuery spanWithinQuery = new SpanWithinQuery(
-            (SpanQuery) wrap.clone(),
-            (SpanQuery) embedded.clone(),
-            this.flag,
-            this.collectPayloads
-        );
+                (SpanQuery) wrap.clone(), (SpanQuery) embedded.clone(),
+                this.flag, this.collectPayloads);
         spanWithinQuery.setBoost(getBoost());
         return spanWithinQuery;
     };
@@ -220,23 +212,28 @@
      * Returns true iff <code>o</code> is equal to this.
      */
     @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (!(o instanceof SpanWithinQuery)) return false;
-        
+    public boolean equals (Object o) {
+        if (this == o)
+            return true;
+        if (!(o instanceof SpanWithinQuery))
+            return false;
+
         final SpanWithinQuery spanWithinQuery = (SpanWithinQuery) o;
-        
-        if (collectPayloads != spanWithinQuery.collectPayloads) return false;
-        if (!wrap.equals(spanWithinQuery.wrap)) return false;
-        if (!embedded.equals(spanWithinQuery.embedded)) return false;
-        
+
+        if (collectPayloads != spanWithinQuery.collectPayloads)
+            return false;
+        if (!wrap.equals(spanWithinQuery.wrap))
+            return false;
+        if (!embedded.equals(spanWithinQuery.embedded))
+            return false;
+
         return getBoost() == spanWithinQuery.getBoost();
     };
 
 
     // I don't know what I am doing here
     @Override
-    public int hashCode() {
+    public int hashCode () {
         int result = flag;
         result = embedded.hashCode();
         result += wrap.hashCode();
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
index 4d8d875..2816c96 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/AttributeSpans.java
@@ -18,19 +18,27 @@
 
 import de.ids_mannheim.korap.query.SpanAttributeQuery;
 
-/** UPDATE THIS!
- * Span enumeration of attributes which are term spans with special payload
- * assignments referring to another span (e.g. element/relation span) to which
- * an attribute span belongs. The class is basically a wrapper of Lucene
- * {@link TermSpans} with additional functionality regarding element/relation
- * reference. Element/relation id is annotated ascendingly starting from the
+/**
+ * UPDATE THIS!
+ * Span enumeration of attributes which are term spans with special
+ * payload
+ * assignments referring to another span (e.g. element/relation span)
+ * to which
+ * an attribute span belongs. The class is basically a wrapper of
+ * Lucene {@link TermSpans} with additional functionality regarding
+ * element/relation
+ * reference. Element/relation id is annotated ascendingly starting
+ * from the
  * left side. <br/>
  * <br/>
- * The enumeration is ordered firstly by the start position of the attribute and
- * secondly by the element/relation id descendingly. This order helps to match
+ * The enumeration is ordered firstly by the start position of the
+ * attribute and
+ * secondly by the element/relation id descendingly. This order helps
+ * to match
  * element and attributes faster.
  * 
- * AttributeSpans contain information about the elements they belongs to, thus
+ * AttributeSpans contain information about the elements they belongs
+ * to, thus
  * querying them alone is sufficient to get
  * "any element having a specific attribute".
  * 
@@ -44,18 +52,22 @@
 
     protected Logger logger = LoggerFactory.getLogger(AttributeSpans.class);
 
+
     /**
-     * Constructs Attributespans based on the specified SpanAttributeQuery.
+     * Constructs Attributespans based on the specified
+     * SpanAttributeQuery.
      * 
-     * @param spanAttributeQuery a spanAttributeQuery
+     * @param spanAttributeQuery
+     *            a spanAttributeQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public AttributeSpans(SpanAttributeQuery spanAttributeQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public AttributeSpans (SpanAttributeQuery spanAttributeQuery,
+                           AtomicReaderContext context, Bits acceptDocs,
+                           Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanAttributeQuery, context, acceptDocs, termContexts);
         candidateList = new ArrayList<>();
         hasMoreSpans = firstSpans.next();
@@ -65,21 +77,24 @@
         }
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         matchPayload.clear();
         return advance();
     }
 
+
     /**
-     * Moves to the next match by checking the candidate match list or setting
+     * Moves to the next match by checking the candidate match list or
+     * setting
      * the list first when it is empty.
      * 
      * @return true if a match is found
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (hasMoreSpans || !candidateList.isEmpty()) {
             if (!candidateList.isEmpty()) {
                 // set the current match from the first CandidateAttributeSpan
@@ -88,10 +103,11 @@
                 this.matchDocNumber = cs.getDoc();
                 this.matchStartPosition = cs.getStart();
                 this.matchEndPosition = cs.getEnd();
-				this.setSpanId(cs.getSpanId()); // referentId
+                this.setSpanId(cs.getSpanId()); // referentId
                 candidateList.remove(0);
                 return true;
-            } else {
+            }
+            else {
                 setCandidateList();
                 currentDoc = firstSpans.doc();
                 currentPosition = firstSpans.start();
@@ -100,14 +116,17 @@
         return false;
     }
 
+
     /**
-     * Collects all the attributes in the same start position and sort them by
-     * element/relation Id in a reverse order (the ones with the bigger
+     * Collects all the attributes in the same start position and sort
+     * them by
+     * element/relation Id in a reverse order (the ones with the
+     * bigger
      * element/relation Id first).
      * 
      * @throws IOException
      */
-    private void setCandidateList() throws IOException {
+    private void setCandidateList () throws IOException {
 
         while (hasMoreSpans && firstSpans.doc() == currentDoc
                 && firstSpans.start() == currentPosition) {
@@ -120,56 +139,66 @@
         Collections.reverse(candidateList);
     }
 
+
     /**
-     * Creates a CandidateAttributeSpan based on the child span and set the
+     * Creates a CandidateAttributeSpan based on the child span and
+     * set the
      * spanId and elementEnd from its payloads.
      * 
-     * @param firstSpans an AttributeSpans
+     * @param firstSpans
+     *            an AttributeSpans
      * @return a CandidateAttributeSpan
      * @throws IOException
      */
-    private CandidateAttributeSpan createCandidateSpan() throws IOException {
+    private CandidateAttributeSpan createCandidateSpan () throws IOException {
         List<byte[]> payload = (List<byte[]>) firstSpans.getPayload();
         ByteBuffer wrapper = ByteBuffer.wrap(payload.get(0));
 
-		short spanId;
-		int start = 0, end;
+        short spanId;
+        int start = 0, end;
 
-		if (payload.get(0).length == 6) {
-			end = wrapper.getInt(0);
-			spanId = wrapper.getShort(4);
-			return new CandidateAttributeSpan(firstSpans, spanId, end);
-		}
-		else if (payload.get(0).length == 10) {
-			end = wrapper.getInt(4);
-			spanId = wrapper.getShort(8);
-			return new CandidateAttributeSpan(firstSpans, spanId, start, end);
-		}
-        
-		throw new NullPointerException("Missing element end in payloads.");
+        if (payload.get(0).length == 6) {
+            end = wrapper.getInt(0);
+            spanId = wrapper.getShort(4);
+            return new CandidateAttributeSpan(firstSpans, spanId, end);
+        }
+        else if (payload.get(0).length == 10) {
+            end = wrapper.getInt(4);
+            spanId = wrapper.getShort(8);
+            return new CandidateAttributeSpan(firstSpans, spanId, start, end);
+        }
+
+        throw new NullPointerException("Missing element end in payloads.");
     }
 
+
     /**
-     * Tells if the enumeration of the AttributeSpans has come to an end.
+     * Tells if the enumeration of the AttributeSpans has come to an
+     * end.
      * 
      * @return true if the enumeration has finished.
      */
-    public boolean isFinish() {
+    public boolean isFinish () {
         return isFinish;
     }
 
+
     /**
-     * Sets true if the enumeration of the AttributeSpans has come to an end.
+     * Sets true if the enumeration of the AttributeSpans has come to
+     * an end.
      * 
-     * @param isFinish <code>true</code> if the enumeration of the
-     *        AttributeSpans has come to an end, <code>false</code> otherwise.
+     * @param isFinish
+     *            <code>true</code> if the enumeration of the
+     *            AttributeSpans has come to an end,
+     *            <code>false</code> otherwise.
      */
-    public void setFinish(boolean isFinish) {
+    public void setFinish (boolean isFinish) {
         this.isFinish = isFinish;
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 candidateList.clear();
@@ -182,16 +211,21 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost();
     }
 
     /**
-     * CandidateAttributeSpan contains information about an Attribute span. All
-     * attribute spans occurring in an identical position are collected as
-     * CandidateAttributeSpans. The list of these CandidateAttributeSpans are
-     * sorted based on the span ids to which the attributes belong to. The
+     * CandidateAttributeSpan contains information about an Attribute
+     * span. All
+     * attribute spans occurring in an identical position are
+     * collected as
+     * CandidateAttributeSpans. The list of these
+     * CandidateAttributeSpans are
+     * sorted based on the span ids to which the attributes belong to.
+     * The
      * attributes with smaller spanIds come first on the list.
      * 
      * */
@@ -200,43 +234,56 @@
 
         private short spanId;
 
+
         /**
-         * Construct a CandidateAttributeSpan based on the given span, spanId,
+         * Construct a CandidateAttributeSpan based on the given span,
+         * spanId,
          * and elementEnd.
          * 
-         * @param span an AttributeSpans
-         * @param spanId the element or relation span id to which the current
-         *        state of the specified AttributeSpans belongs to.
-         * @param elementEnd the end position of the element or relation span to
-         *        which the current state of the specified AttributeSpans
-         *        belongs to.
+         * @param span
+         *            an AttributeSpans
+         * @param spanId
+         *            the element or relation span id to which the
+         *            current
+         *            state of the specified AttributeSpans belongs
+         *            to.
+         * @param elementEnd
+         *            the end position of the element or relation span
+         *            to
+         *            which the current state of the specified
+         *            AttributeSpans
+         *            belongs to.
          * @throws IOException
          */
-        public CandidateAttributeSpan(Spans span, short spanId, int elementEnd)
+        public CandidateAttributeSpan (Spans span, short spanId, int elementEnd)
                 throws IOException {
             super(span);
-			setSpanId(spanId);
-			this.end = elementEnd;
+            setSpanId(spanId);
+            this.end = elementEnd;
         }
 
-		public CandidateAttributeSpan(Spans span, short spanId,
-				int start, int end) throws IOException {
-			super(span);
-			setSpanId(spanId);
-			this.start = start;
-			this.end = end;
-		}
 
-		public void setSpanId(short spanId) {
+        public CandidateAttributeSpan (Spans span, short spanId, int start,
+                                       int end) throws IOException {
+            super(span);
+            setSpanId(spanId);
+            this.start = start;
+            this.end = end;
+        }
+
+
+        public void setSpanId (short spanId) {
             this.spanId = spanId;
         }
 
-        public short getSpanId() {
+
+        public short getSpanId () {
             return spanId;
         }
 
+
         @Override
-        public int compareTo(CandidateSpan o) {
+        public int compareTo (CandidateSpan o) {
             CandidateAttributeSpan cs = (CandidateAttributeSpan) o;
             if (this.spanId == cs.spanId)
                 return 0;
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/CandidateSpan.java b/src/main/java/de/ids_mannheim/korap/query/spans/CandidateSpan.java
index ce930d4..c78eee4 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/CandidateSpan.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/CandidateSpan.java
@@ -7,31 +7,36 @@
 import org.apache.lucene.search.spans.Spans;
 
 /**
- * CandidateSpan stores the current state of a Lucene {@link Spans}, which is an
- * enumeration. CandidateSpan is used for various purposes, such as for
- * collecting spans which will be used in a latter process or next matching.
+ * CandidateSpan stores the current state of a Lucene {@link Spans},
+ * which is an
+ * enumeration. CandidateSpan is used for various purposes, such as
+ * for
+ * collecting spans which will be used in a latter process or next
+ * matching.
  * 
  * @author margaretha
  * */
 public class CandidateSpan implements Comparable<CandidateSpan>, Cloneable {
-	protected int doc, start, end;
+    protected int doc, start, end;
     private long cost;
     private Collection<byte[]> payloads = new ArrayList<>();
     private int position;
     private CandidateSpan childSpan; // used for example for multiple distance
                                      // with unordered constraint
     protected short spanId;
-	private short leftId, rightId;
-	private int leftStart, leftEnd;
-	private int rightStart, rightEnd;
+    private short leftId, rightId;
+    private int leftStart, leftEnd;
+    private int rightStart, rightEnd;
+
 
     /**
      * Constructs a CandidateSpan for the given Span.
      * 
-     * @param span a Span
+     * @param span
+     *            a Span
      * @throws IOException
      */
-    public CandidateSpan(Spans span) throws IOException {
+    public CandidateSpan (Spans span) throws IOException {
         this.doc = span.doc();
         this.start = span.start();
         this.end = span.end();
@@ -40,32 +45,44 @@
             setPayloads(span.getPayload());
     }
 
+
     /**
-     * Constructs a CandidateSpan for the given Span and element position (where
-     * the span is included in a document). The element position is important
+     * Constructs a CandidateSpan for the given Span and element
+     * position (where
+     * the span is included in a document). The element position is
+     * important
      * for the matching process in {@link ElementDistanceSpans}.
      * 
-     * @param span a Span
-     * @param position an element position
+     * @param span
+     *            a Span
+     * @param position
+     *            an element position
      * @throws IOException
      */
-    public CandidateSpan(Spans span, int position) throws IOException {
+    public CandidateSpan (Spans span, int position) throws IOException {
         this(span);
         this.position = position;
     }
 
+
     /**
-     * Constructs a CandidateSpan from all the given variables which are
+     * Constructs a CandidateSpan from all the given variables which
+     * are
      * properties of a Span.
      * 
-     * @param start the start position of a span
-     * @param end the end position of a span
-     * @param doc the document including the span
-     * @param cost the cost of finding a span
-     * @param payloads the payloads of a span
+     * @param start
+     *            the start position of a span
+     * @param end
+     *            the end position of a span
+     * @param doc
+     *            the document including the span
+     * @param cost
+     *            the cost of finding a span
+     * @param payloads
+     *            the payloads of a span
      */
-    public CandidateSpan(int start, int end, int doc, long cost,
-            Collection<byte[]> payloads) {
+    public CandidateSpan (int start, int end, int doc, long cost,
+                          Collection<byte[]> payloads) {
         this.start = start;
         this.end = end;
         this.doc = doc;
@@ -74,81 +91,94 @@
             setPayloads(payloads);
     }
 
+
     @Override
-    protected CandidateSpan clone() throws CloneNotSupportedException {
+    protected CandidateSpan clone () throws CloneNotSupportedException {
         return new CandidateSpan(this.start, this.end, this.doc, this.cost,
                 this.payloads);
     }
 
+
     /**
      * Returns the document number containing the CandidateSpan.
      * 
      * @return the document number
      */
-    public int getDoc() {
+    public int getDoc () {
         return doc;
     }
 
+
     /**
      * Sets the document number containing the CandidateSpan.
      * 
-     * @param doc the document number
+     * @param doc
+     *            the document number
      */
-    public void setDoc(int doc) {
+    public void setDoc (int doc) {
         this.doc = doc;
     }
 
+
     /**
      * Returns the start position of the CandidateSpan.
      * 
      * @return the start position
      */
-    public int getStart() {
+    public int getStart () {
         return start;
     }
 
+
     /**
      * Sets the start position of the CandidateSpan.
      * 
-     * @param start the start position
+     * @param start
+     *            the start position
      */
-    public void setStart(int start) {
+    public void setStart (int start) {
         this.start = start;
     }
 
+
     /**
      * Returns the end position of the CandidateSpan.
      * 
      * @return the end position
      */
-    public int getEnd() {
+    public int getEnd () {
         return end;
     }
 
+
     /**
      * Sets the end position of the CandidateSpan.
      * 
-     * @param end the end position
+     * @param end
+     *            the end position
      */
-    public void setEnd(int end) {
+    public void setEnd (int end) {
         this.end = end;
     }
 
+
     /**
      * Returns the payloads of the CandidateSpan.
      * 
      * @return the payloads
      */
-    public Collection<byte[]> getPayloads() {
+    public Collection<byte[]> getPayloads () {
         return payloads;
     }
 
+
     /**
      * Sets the payloads of the CandidateSpan.
      * 
-     * @param payloads the payloads
+     * @param payloads
+     *            the payloads
      */
-    public void setPayloads(Collection<byte[]> payloads) {
+    public void setPayloads (Collection<byte[]> payloads) {
 
         for (byte[] b : payloads) {
             if (b == null)
@@ -158,134 +188,168 @@
         }
     }
 
+
     /**
      * Returns the cost of finding the CandidateSpan.
      * 
      * @return the cost
      */
-    public long getCost() {
+    public long getCost () {
         return cost;
     }
 
+
     /**
      * Sets the cost of finding the CandidateSpan.
      * 
-     * @param cost the cost
+     * @param cost
+     *            the cost
      */
-    public void setCost(long cost) {
+    public void setCost (long cost) {
         this.cost = cost;
     }
 
+
     /**
-     * Returns the element position number containing the CandidateSpan.
+     * Returns the element position number containing the
+     * CandidateSpan.
      * 
      * @return the element position number
      */
-    public int getPosition() {
+    public int getPosition () {
         return position;
     }
 
+
     /**
      * Sets the element position number containing the CandidateSpan.
      * 
-     * @param position the element position number
+     * @param position
+     *            the element position number
      */
-    public void setPosition(int position) {
+    public void setPosition (int position) {
         this.position = position;
     }
 
+
     /**
      * Returns a child/sub Span of the CandidateSpan.
      * 
      * @return a child/sub span of the CandidateSpan
      */
-    public CandidateSpan getChildSpan() {
+    public CandidateSpan getChildSpan () {
         return childSpan;
     }
 
+
     /**
      * Sets the child/sub span of the CandidateSpan.
      * 
-     * @param childSpan a child/sub span of the CandidateSpan
+     * @param childSpan
+     *            a child/sub span of the CandidateSpan
      */
-    public void setChildSpan(CandidateSpan childSpan) {
+    public void setChildSpan (CandidateSpan childSpan) {
         this.childSpan = childSpan;
     }
 
+
     /**
-     * Returns the span id of another Span related to the CandidateSpan. Only
-     * CandidateSpan of particular Spans such as {@link AttributeSpans} having
-     * this property. For instance, an AttributeSpan has a spanId of the element
+     * Returns the span id of another Span related to the
+     * CandidateSpan. Only
+     * CandidateSpan of particular Spans such as
+     * {@link AttributeSpans} having
+     * this property. For instance, an AttributeSpan has a spanId of
+     * the element
      * it belongs to.
      * 
-     * @return the span id of another Span related to the CandidateSpan
+     * @return the span id of another Span related to the
+     *         CandidateSpan
      */
-    public short getSpanId() {
+    public short getSpanId () {
         return spanId;
     }
 
+
     /**
-     * Sets the span id of another Span related to the CandidateSpan. Only
-     * CandidateSpan of particular Spans such as {@link AttributeSpans} having
-     * this property. For instance, an AttributeSpan has a spanId of the element
+     * Sets the span id of another Span related to the CandidateSpan.
+     * Only
+     * CandidateSpan of particular Spans such as
+     * {@link AttributeSpans} having
+     * this property. For instance, an AttributeSpan has a spanId of
+     * the element
      * it belongs to.
      * 
-     * @param spanId the span id of another Span related to the CandidateSpan
+     * @param spanId
+     *            the span id of another Span related to the
+     *            CandidateSpan
      */
-    public void setSpanId(short spanId) {
+    public void setSpanId (short spanId) {
         this.spanId = spanId;
     }
 
-	public short getLeftId() {
-		return leftId;
-	}
 
-	public void setLeftId(short leftId) {
-		this.leftId = leftId;
-	}
+    public short getLeftId () {
+        return leftId;
+    }
 
-	public short getRightId() {
-		return rightId;
-	}
 
-	public void setRightId(short rightId) {
-		this.rightId = rightId;
-	}
+    public void setLeftId (short leftId) {
+        this.leftId = leftId;
+    }
 
-	public int getLeftStart() {
-		return leftStart;
-	}
 
-	public void setLeftStart(int leftStart) {
-		this.leftStart = leftStart;
-	}
+    public short getRightId () {
+        return rightId;
+    }
 
-	public int getLeftEnd() {
-		return leftEnd;
-	}
 
-	public void setLeftEnd(int leftEnd) {
-		this.leftEnd = leftEnd;
-	}
+    public void setRightId (short rightId) {
+        this.rightId = rightId;
+    }
 
-	public int getRightStart() {
-		return rightStart;
-	}
 
-	public void setRightStart(int rightStart) {
-		this.rightStart = rightStart;
-	}
+    public int getLeftStart () {
+        return leftStart;
+    }
 
-	public int getRightEnd() {
-		return rightEnd;
-	}
 
-	public void setRightEnd(int rightEnd) {
-		this.rightEnd = rightEnd;
-	}
+    public void setLeftStart (int leftStart) {
+        this.leftStart = leftStart;
+    }
 
-	@Override
-    public int compareTo(CandidateSpan o) {
+
+    public int getLeftEnd () {
+        return leftEnd;
+    }
+
+
+    public void setLeftEnd (int leftEnd) {
+        this.leftEnd = leftEnd;
+    }
+
+
+    public int getRightStart () {
+        return rightStart;
+    }
+
+
+    public void setRightStart (int rightStart) {
+        this.rightStart = rightStart;
+    }
+
+
+    public int getRightEnd () {
+        return rightEnd;
+    }
+
+
+    public void setRightEnd (int rightEnd) {
+        this.rightEnd = rightEnd;
+    }
+
+
+    @Override
+    public int compareTo (CandidateSpan o) {
         if (this.doc == o.doc) {
             if (this.getStart() == o.getStart()) {
                 if (this.getEnd() == o.getEnd())
@@ -294,11 +358,13 @@
                     return 1;
                 else
                     return -1;
-            } else if (this.getStart() < o.getStart())
+            }
+            else if (this.getStart() < o.getStart())
                 return -1;
             else
                 return 1;
-        } else if (this.doc < o.doc)
+        }
+        else if (this.doc < o.doc)
             return -1;
         else
             return 1;
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ClassSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ClassSpans.java
index b7492e9..35fe53f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ClassSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ClassSpans.java
@@ -21,7 +21,7 @@
  * And the start and end position of the span, so this information
  * can bubble up for later processing (similar to captures in regular
  * expression).
- *
+ * 
  * @author diewald
  */
 
@@ -39,25 +39,29 @@
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
 
+
     /**
      * Construct a new ClassSpans object.
-     *
-     * @param operand An arbitrary nested {@link SpanQuery}.
-     * @param context The {@link AtomicReaderContext}.
-     * @param acceptDocs Bit vector representing the documents
-     *        to be searched in.
-     * @param termContexts A map managing {@link TermState TermStates}.
-     * @param number The identifying class number.
+     * 
+     * @param operand
+     *            An arbitrary nested {@link SpanQuery}.
+     * @param context
+     *            The {@link AtomicReaderContext}.
+     * @param acceptDocs
+     *            Bit vector representing the documents
+     *            to be searched in.
+     * @param termContexts
+     *            A map managing {@link TermState TermStates}.
+     * @param number
+     *            The identifying class number.
      */
-    public ClassSpans (SpanQuery operand,
-                       AtomicReaderContext context,
-                       Bits acceptDocs,
-                       Map<Term,TermContext> termContexts,
+    public ClassSpans (SpanQuery operand, AtomicReaderContext context,
+                       Bits acceptDocs, Map<Term, TermContext> termContexts,
                        byte number) throws IOException {
         spans = operand.getSpans(context, acceptDocs, termContexts);
 
         // The number of the class
-        this.number  = number;
+        this.number = number;
 
         // The current operand
         this.operand = operand;
@@ -100,7 +104,8 @@
 
     @Override
     public boolean next () throws IOException {
-        if (DEBUG) log.trace("Forward next");
+        if (DEBUG)
+            log.trace("Forward next");
 
         if (spans.next())
             return this.addClassPayload();
@@ -108,46 +113,43 @@
         hasmorespans = false;
         return false;
     };
-    
-    private boolean addClassPayload () throws IOException {
-    	hasmorespans = true;
 
-	    classedPayload.clear();
+
+    private boolean addClassPayload () throws IOException {
+        hasmorespans = true;
+
+        classedPayload.clear();
 
         // Subquery has payloads
-	    if (spans.isPayloadAvailable()) {
+        if (spans.isPayloadAvailable()) {
             classedPayload.addAll(spans.getPayload());
-            if (DEBUG) log.trace("Found payload in nested SpanQuery");
-	    };
-
-	    if (DEBUG) {
-            log.trace(
-                "Wrap class {} around span {} - {}",
-                number,
-                spans.start(),
-                spans.end()
-            );
+            if (DEBUG)
+                log.trace("Found payload in nested SpanQuery");
         };
 
-	    // Todo: Better allocate using a Factory!
-	    bb.clear();
-	    bb.putInt(spans.start()).putInt(spans.end()).put(number);
+        if (DEBUG) {
+            log.trace("Wrap class {} around span {} - {}", number,
+                    spans.start(), spans.end());
+        };
 
-	    // Add highlight information as byte array
-	    classedPayload.add(bb.array());
+        // Todo: Better allocate using a Factory!
+        bb.clear();
+        bb.putInt(spans.start()).putInt(spans.end()).put(number);
+
+        // Add highlight information as byte array
+        classedPayload.add(bb.array());
         return true;
-	};
+    };
 
 
     @Override
     public boolean skipTo (int target) throws IOException {
         classedPayload.clear();
 
-        if (DEBUG) log.trace("Skip ClassSpans {} -> {}",
-                             spans.doc(), target);
+        if (DEBUG)
+            log.trace("Skip ClassSpans {} -> {}", spans.doc(), target);
 
-        if (hasmorespans && spans.doc() < target &&
-            spans.skipTo(target))
+        if (hasmorespans && spans.doc() < target && spans.skipTo(target))
             return this.addClassPayload();
         return false;
     };
@@ -155,13 +157,13 @@
 
     @Override
     public String toString () {
-        return getClass().getName() + "(" + this.operand.toString() + ")@" +
-            (doc() + ":" + start() + "-" + end());
+        return getClass().getName() + "(" + this.operand.toString() + ")@"
+                + (doc() + ":" + start() + "-" + end());
     };
 
 
     @Override
-    public long cost() {
+    public long cost () {
         return spans.cost();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceExclusionSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceExclusionSpans.java
index 2bc0cd4..517e8f8 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceExclusionSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceExclusionSpans.java
@@ -11,8 +11,10 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Span enumeration of spans (the firstSpans) which do <em>not</em> occur
- * together with other spans (the secondSpans) within a range of distance.
+ * Span enumeration of spans (the firstSpans) which do <em>not</em>
+ * occur
+ * together with other spans (the secondSpans) within a range of
+ * distance.
  * 
  * @author margaretha
  * */
@@ -22,21 +24,28 @@
     private boolean isOrdered;
     private boolean hasMoreSecondSpans;
 
+
     /**
      * Constructs DistanceExclusionSpans for the specified
      * {@link SpanDistanceQuery}.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
-     * @param isOrdered a boolean flag representing the value <code>true</code>
-     *        if the spans must occur in order, <code>false</code> otherwise.
+     * @param isOrdered
+     *            a boolean flag representing the value
+     *            <code>true</code>
+     *            if the spans must occur in order, <code>false</code>
+     *            otherwise.
      * @throws IOException
      */
-    public DistanceExclusionSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public DistanceExclusionSpans (SpanDistanceQuery query,
+                                   AtomicReaderContext context,
+                                   Bits acceptDocs,
+                                   Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
         minDistance = query.getMinDistance();
         maxDistance = query.getMaxDistance();
@@ -45,8 +54,9 @@
         hasMoreSecondSpans = secondSpans.next();
     }
 
+
     @Override
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
 
         while (hasMoreSpans) {
             if (hasMoreSecondSpans)
@@ -61,13 +71,15 @@
         return false;
     }
 
+
     /**
-     * Advance the second span until it occurs on the right side of the first
+     * Advance the second span until it occurs on the right side of
+     * the first
      * span.
      * 
      * @throws IOException
      */
-    private void forwardSecondSpans() throws IOException {
+    private void forwardSecondSpans () throws IOException {
 
         if (secondSpans.doc() < firstSpans.doc()) {
             hasMoreSecondSpans = secondSpans.skipTo(firstSpans.doc());
@@ -85,14 +97,17 @@
         }
     }
 
+
     /**
-     * Calculate the distance / difference between a firstspan and a secondspan
+     * Calculate the distance / difference between a firstspan and a
+     * secondspan
      * positions.
      * 
-     * @return distance the difference between the positions of a firstspan and
+     * @return distance the difference between the positions of a
+     *         firstspan and
      *         a secondspan.
      * */
-    private int calculateActualDistance() {
+    private int calculateActualDistance () {
         // right secondSpan
         if (firstSpans.end() <= secondSpans.start())
             return secondSpans.start() - firstSpans.end() + 1;
@@ -100,14 +115,18 @@
         return firstSpans.start() - secondSpans.end() + 1;
     }
 
+
     /**
-     * Check the distance between the current first span and second span against
+     * Check the distance between the current first span and second
+     * span against
      * the min and max distance constraints.
      * 
-     * @return true if the distance between the first and the second spans are
-     *         smaller as the minimum distance or bigger than the max distance.
+     * @return true if the distance between the first and the second
+     *         spans are
+     *         smaller as the minimum distance or bigger than the max
+     *         distance.
      */
-    private boolean findMatch() throws IOException {
+    private boolean findMatch () throws IOException {
         if (!hasMoreSecondSpans || secondSpans.doc() > firstSpans.doc()) {
             setMatchProperties();
             return true;
@@ -126,12 +145,13 @@
         return false;
     }
 
+
     /**
      * Set the current firstspan as the current match.
      * 
      * @throws IOException
      */
-    private void setMatchProperties() throws IOException {
+    private void setMatchProperties () throws IOException {
         matchDocNumber = firstSpans.doc();
         matchStartPosition = firstSpans.start();
         matchEndPosition = firstSpans.end();
@@ -142,8 +162,9 @@
         setMatchFirstSpan(new CandidateSpan(firstSpans));
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && firstSpans.doc() < target) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -153,8 +174,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost() + secondSpans.cost();
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
index 8559405..b6b6f9f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/DistanceSpans.java
@@ -14,10 +14,13 @@
 import de.ids_mannheim.korap.query.SpanMultipleDistanceQuery;
 
 /**
- * DistanceSpan is a base class for enumeration of span matches, whose two child
- * spans have a specific range of distance (within a min and a max distance) and
+ * DistanceSpan is a base class for enumeration of span matches, whose
+ * two child
+ * spans have a specific range of distance (within a min and a max
+ * distance) and
  * other constraints (i.e. order and co-occurrence) depending on the
- * {@link SpanDistanceQuery}. All distance related spans extends this class.
+ * {@link SpanDistanceQuery}. All distance related spans extends this
+ * class.
  * 
  * @see DistanceExclusionSpans
  * @see ElementDistanceExclusionSpans
@@ -33,109 +36,131 @@
     protected Logger log = LoggerFactory.getLogger(DistanceSpans.class);
     protected boolean exclusion; // for MultipleDistanceQuery
 
+
     /**
      * Constructs a DistanceSpans enumeration for the given
      * {@link SpanDistanceQuery}.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public DistanceSpans(SpanDistanceQuery query, AtomicReaderContext context,
-            Bits acceptDocs, Map<Term, TermContext> termContexts)
+    public DistanceSpans (SpanDistanceQuery query, AtomicReaderContext context,
+                          Bits acceptDocs, Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
         exclusion = query.isExclusion();
     }
 
+
     /**
      * Constructs a DistanceSpans enumeration for the given
      * {@link SpanMultipleDistanceQuery}.
      * 
-     * @param query a SpanMultipleDistanceQuery
+     * @param query
+     *            a SpanMultipleDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public DistanceSpans(SpanMultipleDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public DistanceSpans (SpanMultipleDistanceQuery query,
+                          AtomicReaderContext context, Bits acceptDocs,
+                          Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         matchPayload.clear();
         return advance();
     }
 
+
     /**
      * Advances the current span enumeration to the next span match.
      * 
      * @return <code>true</code> if a span match is available,
      *         <code>false</code> otherwise.
      * */
-    protected abstract boolean advance() throws IOException;
+    protected abstract boolean advance () throws IOException;
+
 
     /**
      * Returns the first span of the current match.
      * 
      * @return the first span of the current match.
      */
-    public CandidateSpan getMatchFirstSpan() {
+    public CandidateSpan getMatchFirstSpan () {
         return matchFirstSpan;
     }
 
+
     /**
      * Sets the first span of the current match.
      * 
-     * @param matchFirstSpan the first span of the current match.
+     * @param matchFirstSpan
+     *            the first span of the current match.
      */
-    public void setMatchFirstSpan(CandidateSpan matchFirstSpan) {
+    public void setMatchFirstSpan (CandidateSpan matchFirstSpan) {
         this.matchFirstSpan = matchFirstSpan;
     }
 
+
     /**
      * Returns the second span of the current match.
      * 
      * @return the second span of the current match.
      */
-    public CandidateSpan getMatchSecondSpan() {
+    public CandidateSpan getMatchSecondSpan () {
         return matchSecondSpan;
     }
 
+
     /**
      * Sets the second span of the current match.
      * 
-     * @param matchSecondSpan the second span of the current match.
+     * @param matchSecondSpan
+     *            the second span of the current match.
      */
-    public void setMatchSecondSpan(CandidateSpan matchSecondSpan) {
+    public void setMatchSecondSpan (CandidateSpan matchSecondSpan) {
         this.matchSecondSpan = matchSecondSpan;
     }
 
+
     /**
-     * Tells if the second span must occur together with the first span, or not.
+     * Tells if the second span must occur together with the first
+     * span, or not.
      * 
-     * @return <code>true</code> if the second span must <em>not</em> occur
-     *         together with the first span, <code>false</code> otherwise.
+     * @return <code>true</code> if the second span must <em>not</em>
+     *         occur
+     *         together with the first span, <code>false</code>
+     *         otherwise.
      */
-    public boolean isExclusion() {
+    public boolean isExclusion () {
         return exclusion;
     }
 
+
     /**
-     * Sets <code>true</code> if the second span must <em>not</em> occur
+     * Sets <code>true</code> if the second span must <em>not</em>
+     * occur
      * together with the first span, <code>false</code> otherwise.
      * 
-     * @param exclusion a boolean with the value <code>true</code> if the second
-     *        span must <em>not</em> occur together with the first span,
-     *        <code>false</code> otherwise.
+     * @param exclusion
+     *            a boolean with the value <code>true</code> if the
+     *            second
+     *            span must <em>not</em> occur together with the first
+     *            span,
+     *            <code>false</code> otherwise.
      */
-    public void setExclusion(boolean exclusion) {
+    public void setExclusion (boolean exclusion) {
         this.exclusion = exclusion;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceExclusionSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceExclusionSpans.java
index 3e701b6..f5fc8cb 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceExclusionSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceExclusionSpans.java
@@ -15,11 +15,16 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Span enumeration of spans (firstSpans) which do <em>not</em> occur together
- * with other spans (secondSpans) on the right side, within a range of an
- * element-based distance (i.e. a sentence or a paragraph as the distance unit).
- * If the query requires that the spans are ordered, then the firstSpans must
- * occur before the secondSpans. In this class, firstSpans are also referred to
+ * Span enumeration of spans (firstSpans) which do <em>not</em> occur
+ * together
+ * with other spans (secondSpans) on the right side, within a range of
+ * an
+ * element-based distance (i.e. a sentence or a paragraph as the
+ * distance unit).
+ * If the query requires that the spans are ordered, then the
+ * firstSpans must
+ * occur before the secondSpans. In this class, firstSpans are also
+ * referred to
  * as target spans and second spans as candidate spans.<br/>
  * <br/>
  * Note: The element distance unit does not overlap to each other.
@@ -45,19 +50,23 @@
     private int minDistance, maxDistance;
     private int firstSpanPostion;
 
+
     /**
      * Constructs ElementDistanceExclusionSpans from the specified
      * {@link SpanDistanceQuery}.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public ElementDistanceExclusionSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public ElementDistanceExclusionSpans (SpanDistanceQuery query,
+                                          AtomicReaderContext context,
+                                          Bits acceptDocs,
+                                          Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
 
         elements = query.getElementQuery().getSpans(context, acceptDocs,
@@ -76,8 +85,9 @@
         maxDistance = query.getMaxDistance();
     }
 
+
     @Override
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
         while (!targetList.isEmpty()
                 || (hasMoreSpans && ensureSameDoc(firstSpans, elements))) {
             if (!targetList.isEmpty()) {
@@ -92,14 +102,16 @@
         return false;
     }
 
+
     /**
      * Tells if the first target from the target list is a match.
      * 
-     * @return <code>true</code> if the first target from the target list is a
+     * @return <code>true</code> if the first target from the target
+     *         list is a
      *         match, <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean isFirstTargetValid() throws IOException {
+    private boolean isFirstTargetValid () throws IOException {
         CandidateSpan target = targetList.get(0);
         targetList.remove(0);
         firstSpanPostion = target.getPosition();
@@ -113,14 +125,16 @@
         return true;
     }
 
+
     /**
      * Validate if the current firstSpan is a match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean findMatch() throws IOException {
+    private boolean findMatch () throws IOException {
         if (firstSpans.doc() != currentDocNum) {
             currentDocNum = firstSpans.doc();
             candidateList.clear();
@@ -129,7 +143,8 @@
         if (hasMoreSecondSpans) {
             if (secondSpans.doc() == firstSpans.doc()) {
                 return (isFirstSpanValid() ? true : false);
-            } else if (secondSpans.doc() < firstSpans.doc()) {
+            }
+            else if (secondSpans.doc() < firstSpans.doc()) {
                 hasMoreSecondSpans = secondSpans.skipTo(firstSpans.doc());
                 return false;
             }
@@ -150,37 +165,45 @@
         return (isFirstSpanValid() ? true : false);
     }
 
+
     /**
      * Tells if the current firstSpan is a match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
-     * @throws IOException <pre>
-     * private boolean isFirstSpanValid() throws IOException {
-     *     if (candidateList.isEmpty()) {
-     *         if (isFirstSpanInElement()) {
-     *             setMatchProperties(new CandidateSpan(firstSpans, elementPosition));
+     * @throws IOException
+     *             <pre>
+     *             private boolean isFirstSpanValid() throws
+     *             IOException {
+     *             if (candidateList.isEmpty()) {
+     *             if (isFirstSpanInElement()) {
+     *             setMatchProperties(new CandidateSpan(firstSpans,
+     *             elementPosition));
      *             hasMoreSpans = firstSpans.next();
      *             return true;
-     *         }
-     *         hasMoreSpans = firstSpans.next();
-     *         return false;
-     *     }
-     *     return (findMatch() ? true : false);
-     * }
-     * </pre>
+     *             }
+     *             hasMoreSpans = firstSpans.next();
+     *             return false;
+     *             }
+     *             return (findMatch() ? true : false);
+     *             }
+     *             </pre>
      */
 
     /**
-     * Tells if the given span is in an element distance unit, or not, by
+     * Tells if the given span is in an element distance unit, or not,
+     * by
      * advancing the element distance unit to the span position.
      * 
-     * @param span a span
-     * @return <code>true</code> if the element distance unit can be advanced to
+     * @param span
+     *            a span
+     * @return <code>true</code> if the element distance unit can be
+     *         advanced to
      *         contain the given span, <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean advanceElementTo(Spans span) throws IOException {
+    private boolean advanceElementTo (Spans span) throws IOException {
         while (hasMoreElements && elements.doc() == currentDocNum
                 && elements.start() < span.end()) {
 
@@ -195,14 +218,16 @@
         return false;
     }
 
+
     /**
      * Tells if the current firstSpan is a match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean isFirstSpanValid() throws IOException {
+    private boolean isFirstSpanValid () throws IOException {
         if (!isOrdered)
             collectLeftCandidates();
 
@@ -227,14 +252,17 @@
         return false;
     }
 
+
     /**
-     * Collects all second spans (candidates) on the right side of the current
-     * first span (target) position. At the same time, also collects all other
+     * Collects all second spans (candidates) on the right side of the
+     * current
+     * first span (target) position. At the same time, also collects
+     * all other
      * first spans occurring before the second spans.
      * 
      * @throws IOException
      */
-    private void collectRightCandidates() throws IOException {
+    private void collectRightCandidates () throws IOException {
         while (hasMoreSecondSpans && secondSpans.doc() == currentDocNum) {
 
             if (elementPosition > firstSpanPostion + maxDistance) {
@@ -260,13 +288,15 @@
         }
     }
 
+
     /**
-     * Collects all the second spans (candidates) occurring before the first
+     * Collects all the second spans (candidates) occurring before the
+     * first
      * spans, and are within an element distance unit.
      * 
      * @throws IOException
      */
-    private void collectLeftCandidates() throws IOException {
+    private void collectLeftCandidates () throws IOException {
         while (hasMoreSecondSpans && secondSpans.doc() == firstSpans.doc()
                 && secondSpans.start() < firstSpans.end()) {
             if (advanceElementTo(secondSpans)) {
@@ -278,16 +308,22 @@
         }
     }
 
+
     /**
-     * Tells if there is a candidate span (second span) occurring together with
-     * the target span (firstspan) within the minimum and maximum distance
+     * Tells if there is a candidate span (second span) occurring
+     * together with
+     * the target span (firstspan) within the minimum and maximum
+     * distance
      * range.
      * 
-     * @return <code>true</code> if there is a candidate span (second span)
-     *         occurring together with the target span (firstspan) within the
-     *         minimum and maximum distance range, <code>false</code> otherwise.
+     * @return <code>true</code> if there is a candidate span (second
+     *         span)
+     *         occurring together with the target span (firstspan)
+     *         within the
+     *         minimum and maximum distance range, <code>false</code>
+     *         otherwise.
      */
-    private boolean isWithinDistance() {
+    private boolean isWithinDistance () {
         int actualDistance;
         for (CandidateSpan cs : candidateList) {
             actualDistance = cs.getPosition() - firstSpanPostion;
@@ -300,14 +336,16 @@
         return false;
     }
 
+
     /**
      * Tells if the current firstSpans is in an element.
      * 
-     * @return <code>true</code> if the current firstSpans in is an element,
+     * @return <code>true</code> if the current firstSpans in is an
+     *         element,
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean isFirstSpanInElement() throws IOException {
+    private boolean isFirstSpanInElement () throws IOException {
         if (advanceElementTo(firstSpans)) {
             firstSpanPostion = elementPosition;
             filterCandidateList(firstSpanPostion);
@@ -316,15 +354,20 @@
         return false;
     }
 
+
     /**
-     * From the candidateList, removes all candidate spans that are too far from
-     * the given target position, and have exactly the same position as the
-     * target position. Only candidate spans occurring within a range of
+     * From the candidateList, removes all candidate spans that are
+     * too far from
+     * the given target position, and have exactly the same position
+     * as the
+     * target position. Only candidate spans occurring within a range
+     * of
      * distance from the target position, are retained.
      * 
-     * @param position target/firstSpan position
+     * @param position
+     *            target/firstSpan position
      */
-    private void filterCandidateList(int position) {
+    private void filterCandidateList (int position) {
 
         Iterator<CandidateSpan> i = candidateList.iterator();
         CandidateSpan cs;
@@ -338,13 +381,15 @@
         }
     }
 
+
     /**
      * Sets the given target/match CandidateSpan as the current match.
      * 
-     * @param match a target/firstSpan wrapped as a CandidateSpan
+     * @param match
+     *            a target/firstSpan wrapped as a CandidateSpan
      * @throws IOException
      */
-    private void setMatchProperties(CandidateSpan match) throws IOException {
+    private void setMatchProperties (CandidateSpan match) throws IOException {
         matchDocNumber = match.getDoc();
         matchStartPosition = match.getStart();
         matchEndPosition = match.getEnd();
@@ -355,8 +400,9 @@
         setMatchFirstSpan(match);
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && firstSpans.doc() < target) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -366,8 +412,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return elements.cost() + firstSpans.cost() + secondSpans.cost();
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
index e4a77d6..5060b31 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ElementDistanceSpans.java
@@ -13,11 +13,16 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Span enumeration of element-based distance span matches. Each match consists
- * of two child spans. The element-distance between the child spans is the
- * difference between the element position numbers where the child spans are.
- * The element-distance unit can be a sentence or a paragraph. All other child
- * spans' occurrences which are not in a sentence or a paragraph (with respect
+ * Span enumeration of element-based distance span matches. Each match
+ * consists
+ * of two child spans. The element-distance between the child spans is
+ * the
+ * difference between the element position numbers where the child
+ * spans are.
+ * The element-distance unit can be a sentence or a paragraph. All
+ * other child
+ * spans' occurrences which are not in a sentence or a paragraph (with
+ * respect
  * to the element distance type currently used), are ignored.
  * 
  * Note: elements cannot overlap with each other.
@@ -31,18 +36,22 @@
     private int elementPosition;
     private int secondSpanPostion;
 
+
     /**
-     * Constructs ElementDistanceSpans based on the given SpanDistanceQuery.
+     * Constructs ElementDistanceSpans based on the given
+     * SpanDistanceQuery.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public ElementDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public ElementDistanceSpans (SpanDistanceQuery query,
+                                 AtomicReaderContext context, Bits acceptDocs,
+                                 Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
 
         elements = query.getElementQuery().getSpans(context, acceptDocs,
@@ -53,8 +62,9 @@
         elementPosition = 0;
     }
 
+
     @Override
-    protected boolean findMatch() throws IOException {
+    protected boolean findMatch () throws IOException {
         CandidateSpan candidateSpan = candidateList.get(candidateListIndex);
         int actualDistance = secondSpanPostion - candidateSpan.getPosition();
 
@@ -72,13 +82,15 @@
         return false;
     }
 
+
     @Override
-    protected void setCandidateList() throws IOException {
+    protected void setCandidateList () throws IOException {
         if (candidateListDocNum == elements.doc()
                 && candidateListDocNum == secondSpans.doc()) {
             candidateListIndex = -1;
             addNewCandidates();
-        } else {
+        }
+        else {
             candidateList.clear();
             if (hasMoreFirstSpans
                     && findSameDoc(firstSpans, secondSpans, elements)) {
@@ -90,13 +102,15 @@
         }
     }
 
+
     /**
-     * Add new possible (candidate) firstspans. Candidate firstspans must be in
+     * Add new possible (candidate) firstspans. Candidate firstspans
+     * must be in
      * an element and not too far from the secondspan.
      * 
      * @throws IOException
      */
-    private void addNewCandidates() throws IOException {
+    private void addNewCandidates () throws IOException {
         while (hasMoreFirstSpans && firstSpans.doc() == candidateListDocNum
                 && firstSpans.start() < secondSpans.end()) {
 
@@ -109,12 +123,14 @@
         }
     }
 
+
     /**
-     * Advance elements until encountering a span within the given document.
+     * Advance elements until encountering a span within the given
+     * document.
      * 
      * @return true iff an element containing the span, is found.
      */
-    private boolean advanceElementTo(Spans span) throws IOException {
+    private boolean advanceElementTo (Spans span) throws IOException {
         while (hasMoreElements && elements.doc() == candidateListDocNum
                 && elements.start() < span.end()) {
 
@@ -129,13 +145,16 @@
         return false;
     }
 
+
     /**
-     * Reduce the number of candidates by removing all candidates that are not
+     * Reduce the number of candidates by removing all candidates that
+     * are not
      * within the max distance from the given element position.
      * 
-     * @param position an element position
+     * @param position
+     *            an element position
      */
-    private void filterCandidateList(int position) {
+    private void filterCandidateList (int position) {
 
         Iterator<CandidateSpan> i = candidateList.iterator();
         CandidateSpan cs;
@@ -150,8 +169,9 @@
         // System.out.println("pos "+position+" " +candidateList.size());
     }
 
+
     @Override
-    protected boolean isSecondSpanValid() throws IOException {
+    protected boolean isSecondSpanValid () throws IOException {
         if (advanceElementTo(secondSpans)) {
             secondSpanPostion = elementPosition;
             filterCandidateList(secondSpanPostion);
@@ -161,8 +181,9 @@
         return false;
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         CandidateSpan candidateSpan = candidateList.get(candidateListIndex);
         return elements.cost() + candidateSpan.getCost() + secondSpans.cost();
     }
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 36b569d..21212c7 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
@@ -21,7 +21,8 @@
 import de.ids_mannheim.korap.query.SpanElementQuery;
 
 /**
- * Enumeration of special spans which length is stored in their payload,
+ * Enumeration of special spans which length is stored in their
+ * payload,
  * representing elements such as phrases, sentences and paragraphs.
  * 
  * @author margaretha
@@ -39,23 +40,29 @@
     /**
      * Constructs ElementSpans for the given {@link SpanElementQuery}.
      * 
-     * @param spanElementQuery A {@link SpanElementQuery}.
-     * @param context The {@link AtomicReaderContext}.
-     * @param acceptDocs Bit vector representing the documents
-     *        to be searched in.
-     * @param termContexts A map managing {@link TermState TermStates}.
+     * @param spanElementQuery
+     *            A {@link SpanElementQuery}.
+     * @param context
+     *            The {@link AtomicReaderContext}.
+     * @param acceptDocs
+     *            Bit vector representing the documents
+     *            to be searched in.
+     * @param termContexts
+     *            A map managing {@link TermState TermStates}.
      * @throws IOException
      */
-    public ElementSpans(SpanElementQuery spanElementQuery,
-                        AtomicReaderContext context, Bits acceptDocs,
-                        Map<Term, TermContext> termContexts) throws IOException {
+    public ElementSpans (SpanElementQuery spanElementQuery,
+                         AtomicReaderContext context, Bits acceptDocs,
+                         Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanElementQuery, context, acceptDocs, termContexts);
         termSpans = (TermSpans) this.firstSpans;
         hasMoreSpans = true;
     };
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
 
         if (!hasMoreSpans || !(hasMoreSpans = termSpans.next()))
@@ -134,18 +141,19 @@
         return this.matchEndPosition;
     };
 
-  	@Override
-  	public Collection<byte[]> getPayload() {
+
+    @Override
+    public Collection<byte[]> getPayload () {
         this.processPayload();
-  		return this.matchPayload;
-  	};
+        return this.matchPayload;
+    };
 
 
-  	@Override
-  	public boolean isPayloadAvailable() {
+    @Override
+    public boolean isPayloadAvailable () {
         this.processPayload();
-  		return !this.matchPayload.isEmpty();
-  	};
+        return !this.matchPayload.isEmpty();
+    };
 
 
     @Override
@@ -156,14 +164,13 @@
 
 
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
 
-        if (DEBUG) log.trace("Skip ElementSpans {} -> {}",
-                             firstSpans.doc(), target);
+        if (DEBUG)
+            log.trace("Skip ElementSpans {} -> {}", firstSpans.doc(), target);
 
-        if (hasMoreSpans &&
-            firstSpans.doc() < target &&
-            firstSpans.skipTo(target)) {
+        if (hasMoreSpans && firstSpans.doc() < target
+                && firstSpans.skipTo(target)) {
             return this.setToCurrent();
         };
 
@@ -172,8 +179,9 @@
         return false;
     };
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return termSpans.cost();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedExclusionSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedExclusionSpans.java
index d213425..19f7e7f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedExclusionSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedExclusionSpans.java
@@ -15,18 +15,25 @@
 import de.ids_mannheim.korap.query.SpanExpansionQuery;
 
 /**
- * Enumeration of Spans expanded with minimum <code>m</code> and maximum
- * <code>n</code> tokens, and throughout all the expansions do <em>not</em>
+ * Enumeration of Spans expanded with minimum <code>m</code> and
+ * maximum
+ * <code>n</code> tokens, and throughout all the expansions do
+ * <em>not</em>
  * contain a specific Spans (notClause). See examples in
  * {@link SpanExpansionQuery}.
  * 
- * The expansion direction is designated with the sign of a number, namely a
- * negative number signifies the expansion to the <em>left</em> of the original
- * span, and a positive number (including 0) signifies the expansion to the
+ * The expansion direction is designated with the sign of a number,
+ * namely a
+ * negative number signifies the expansion to the <em>left</em> of the
+ * original
+ * span, and a positive number (including 0) signifies the expansion
+ * to the
  * <em>right</em> of the original span.
  * 
- * The expansion offsets, namely the start and end position of an expansion
- * part, can be stored in payloads. A class number is assigned to the offsets
+ * The expansion offsets, namely the start and end position of an
+ * expansion
+ * part, can be stored in payloads. A class number is assigned to the
+ * offsets
  * grouping them altogether.
  * 
  * @author margaretha
@@ -42,19 +49,23 @@
 
     private long matchCost;
 
+
     /**
      * Constructs ExpandedExclusionSpans from the given
      * {@link SpanExpansionQuery}.
      * 
-     * @param spanExpansionQuery a SpanExpansionQuery
+     * @param spanExpansionQuery
+     *            a SpanExpansionQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public ExpandedExclusionSpans(SpanExpansionQuery spanExpansionQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public ExpandedExclusionSpans (SpanExpansionQuery spanExpansionQuery,
+                                   AtomicReaderContext context,
+                                   Bits acceptDocs,
+                                   Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanExpansionQuery, context, acceptDocs, termContexts);
 
         if (spanExpansionQuery.getSecondClause() == null) {
@@ -82,21 +93,24 @@
         hasMoreSpans = firstSpans.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         matchPayload.clear();
         isStartEnumeration = false;
         return advance();
     }
 
+
     /**
      * Advances the ExpandedExclusionSpans to the next match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (hasMoreSpans || candidateSpans.size() > 0) {
             if (candidateSpans.size() > 0) {
                 // set a candidate span as a match
@@ -108,22 +122,26 @@
                 matchCost = cs.getCost() + notClause.cost();
                 candidateSpans.remove(0);
                 return true;
-            } else if (!hasMoreNotClause || notClause.doc() > firstSpans.doc()) {
+            }
+            else if (!hasMoreNotClause || notClause.doc() > firstSpans.doc()) {
                 generateCandidates(min, max, direction);
                 hasMoreSpans = firstSpans.next();
-            } else
+            }
+            else
                 findMatches();
         }
         return false;
     }
 
+
     /**
-     * Finds matches by expanding the firstspans either to the left or to the
+     * Finds matches by expanding the firstspans either to the left or
+     * to the
      * right.
      * 
      * @throws IOException
      */
-    private void findMatches() throws IOException {
+    private void findMatches () throws IOException {
         while (hasMoreNotClause && notClause.doc() <= firstSpans.doc()) {
             if (notClause.doc() == firstSpans.doc()) {
                 if (direction < 0) { // left
@@ -133,17 +151,19 @@
                     expandRight();
                 }
                 break;
-            } else if (!notClause.next())
+            }
+            else if (!notClause.next())
                 hasMoreNotClause = false;
         }
     }
 
+
     /**
      * Expands the firstspans to the left.
      * 
      * @throws IOException
      */
-    private void expandLeft() throws IOException {
+    private void expandLeft () throws IOException {
         //int counter = max;
         int maxPos = max;
         CandidateSpan lastNotClause = null;
@@ -178,12 +198,13 @@
             hasMoreSpans = firstSpans.next();
     }
 
+
     /**
      * Expands the firstspans to the right.
      * 
      * @throws IOException
      */
-    private void expandRight() throws IOException {
+    private void expandRight () throws IOException {
         int expansionEnd = firstSpans.end() + max;
         int maxPos = max;
         boolean isFound = false;
@@ -213,20 +234,26 @@
                 maxPos = firstNotClause.getStart() - firstSpans.end() - 1;
                 generateCandidates(min, maxPos, direction);
             }
-        } else
+        }
+        else
             hasMoreSpans = firstSpans.next();
     }
 
+
     /**
-     * Creates new candidate matches for the given direction, minimum and
+     * Creates new candidate matches for the given direction, minimum
+     * and
      * maximum positions.
      * 
-     * @param minPos minimum position
-     * @param maxPos maximum position
-     * @param direction the expansion direction
+     * @param minPos
+     *            minimum position
+     * @param maxPos
+     *            maximum position
+     * @param direction
+     *            the expansion direction
      * @throws IOException
      */
-    private void generateCandidates(int minPos, int maxPos, int direction)
+    private void generateCandidates (int minPos, int maxPos, int direction)
             throws IOException {
         int counter;
         int start, end;
@@ -245,7 +272,8 @@
                 }
                 counter--;
             }
-        } else { // right
+        }
+        else { // right
             counter = minPos;
             while (counter <= maxPos) {
                 start = firstSpans.start();
@@ -261,17 +289,22 @@
         }
     }
 
+
     /**
-     * Creates payloads for a candiate match by copying the payloads of the
-     * firstspans, and adds expansion offsets with the given start and end
+     * Creates payloads for a candiate match by copying the payloads
+     * of the
+     * firstspans, and adds expansion offsets with the given start and
+     * end
      * positions to the payloads, if the class number is set.
      * 
-     * @param start the start offset
-     * @param end the end offset
+     * @param start
+     *            the start offset
+     * @param end
+     *            the end offset
      * @return payloads
      * @throws IOException
      */
-    private ArrayList<byte[]> createPayloads(int start, int end)
+    private ArrayList<byte[]> createPayloads (int start, int end)
             throws IOException {
 
         ArrayList<byte[]> payload = new ArrayList<byte[]>();
@@ -286,15 +319,19 @@
         return payload;
     }
 
+
     /**
-     * Generates a byte array of extension offsets and class number to be added
+     * Generates a byte array of extension offsets and class number to
+     * be added
      * into the payloads.
      * 
-     * @param start the start offset
-     * @param end the end offset
+     * @param start
+     *            the start offset
+     * @param end
+     *            the end offset
      * @return a byte array of extension offsets and class number
      */
-    private byte[] createExtensionPayloads(int start, int end) {
+    private byte[] createExtensionPayloads (int start, int end) {
         ByteBuffer buffer = ByteBuffer.allocate(9);
         buffer.putInt(start);
         buffer.putInt(end);
@@ -302,8 +339,9 @@
         return buffer.array();
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -314,8 +352,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return matchCost;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedSpans.java
index da70fd9..b378d43 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ExpandedSpans.java
@@ -14,12 +14,16 @@
 import de.ids_mannheim.korap.query.SpanExpansionQuery;
 
 /**
- * Enumeration of spans expanded with minimum <code>m</code> and maximum
- * <code>n</code> token positions to either left or right direction from the
+ * Enumeration of spans expanded with minimum <code>m</code> and
+ * maximum
+ * <code>n</code> token positions to either left or right direction
+ * from the
  * original spans. See examples in {@link SpanExpansionQuery}.
  * 
- * The expansion offsets, namely the start and end position of an expansion
- * part, can be stored in payloads. A class number is assigned to the offsets
+ * The expansion offsets, namely the start and end position of an
+ * expansion
+ * part, can be stored in payloads. A class number is assigned to the
+ * offsets
  * grouping them altogether.
  * 
  * @author margaretha
@@ -32,18 +36,22 @@
     private List<CandidateSpan> candidateSpans;
     private long matchCost;
 
+
     /**
-     * Constructs ExpandedSpans from the given {@link SpanExpansionQuery}.
+     * Constructs ExpandedSpans from the given
+     * {@link SpanExpansionQuery}.
      * 
-     * @param spanExpansionQuery a SpanExpansionQuery
+     * @param spanExpansionQuery
+     *            a SpanExpansionQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public ExpandedSpans(SpanExpansionQuery spanExpansionQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public ExpandedSpans (SpanExpansionQuery spanExpansionQuery,
+                          AtomicReaderContext context, Bits acceptDocs,
+                          Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanExpansionQuery, context, acceptDocs, termContexts);
         this.min = spanExpansionQuery.getMin();
         this.max = spanExpansionQuery.getMax();
@@ -54,8 +62,9 @@
         hasMoreSpans = true;
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         matchPayload.clear();
         isStartEnumeration = false;
         if (candidateSpans.size() == 0 && hasMoreSpans)
@@ -63,35 +72,43 @@
         return advance();
     }
 
+
     /**
-     * Advances the ExpandedSpans to the next match by setting the first element
-     * in the candidateList as the match. Set the candidateList, if it is empty
+     * Advances the ExpandedSpans to the next match by setting the
+     * first element
+     * in the candidateList as the match. Set the candidateList, if it
+     * is empty
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (candidateSpans.size() > 0 || hasMoreSpans) {
             if (candidateSpans.size() > 0) {
                 setMatch(candidateSpans.get(0));
                 candidateSpans.remove(0);
                 return true;
-            } else {
+            }
+            else {
                 setCandidateList();
             }
         }
         return false;
     }
 
+
     /**
-     * Sets the candidateList by adding new candidate match spans for all
-     * possible expansion with respect to the expansion length (min,max)
+     * Sets the candidateList by adding new candidate match spans for
+     * all
+     * possible expansion with respect to the expansion length
+     * (min,max)
      * variables.
      * 
      * @throws IOException
      */
-    private void setCandidateList() throws IOException {
+    private void setCandidateList () throws IOException {
         CandidateSpan cs;
         int counter, start, end;
 
@@ -106,7 +123,8 @@
                 candidateSpans.add(cs);
                 counter--;
             }
-        } else {
+        }
+        else {
             counter = min;
             while (counter <= max) {
                 // TODO: How do I know if the end is already too far (over the end of the doc)? 
@@ -120,9 +138,12 @@
         }
     }
 
+
     /**
-     * Prepares the payloads for a candidate match (ExpandedSpans). If the class
-     * number is set, the extension offsets with the given start and end
+     * Prepares the payloads for a candidate match (ExpandedSpans). If
+     * the class
+     * number is set, the extension offsets with the given start and
+     * end
      * positions are to be stored in the payloads.
      * 
      * @param start
@@ -130,7 +151,7 @@
      * @return the payloads for a candidaete match
      * @throws IOException
      */
-    private ArrayList<byte[]> createPayloads(int start, int end)
+    private ArrayList<byte[]> createPayloads (int start, int end)
             throws IOException {
 
         ArrayList<byte[]> payload = new ArrayList<byte[]>();
@@ -144,15 +165,17 @@
         return payload;
     }
 
+
     /**
-     * Prepares a byte array of extension offsets with the given start and end
+     * Prepares a byte array of extension offsets with the given start
+     * and end
      * positions and the class number, to be stored in payloads.
      * 
      * @param start
      * @param end
      * @return a byte array of extension offsets and the class number
      */
-    private byte[] createExtensionPayloads(int start, int end) {
+    private byte[] createExtensionPayloads (int start, int end) {
         ByteBuffer buffer = ByteBuffer.allocate(9);
         buffer.putInt(start);
         buffer.putInt(end);
@@ -160,13 +183,15 @@
         return buffer.array();
     }
 
+
     /**
-     * Sets the properties of the given candidate match span as the current
+     * Sets the properties of the given candidate match span as the
+     * current
      * match (state of ExpandedSpans).
      * 
      * @param candidateSpan
      */
-    private void setMatch(CandidateSpan candidateSpan) {
+    private void setMatch (CandidateSpan candidateSpan) {
         matchDocNumber = candidateSpan.getDoc();
         matchStartPosition = candidateSpan.getStart();
         matchEndPosition = candidateSpan.getEnd();
@@ -174,8 +199,9 @@
         matchCost = candidateSpan.getCost();
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -186,8 +212,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return matchCost;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
index f2aa2c8..eabb8c0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/FocusSpans.java
@@ -22,19 +22,22 @@
 
 /**
  * Spans, that can focus on the span boundaries of classed subqueries.
- * The boundaries of the classed subquery may exceed the boundaries of the
+ * The boundaries of the classed subquery may exceed the boundaries of
+ * the
  * nested query.
- *
- * In case multiple classes are found with the very same number, the span
- * is maximized to start on the first occurrence from the left and end on
+ * 
+ * In case multiple classes are found with the very same number, the
+ * span
+ * is maximized to start on the first occurrence from the left and end
+ * on
  * the last occurrence on the right.
- *
+ * 
  * In case the class to focus on is not found in the payloads,
  * the match is ignored.
- *
+ * 
  * <strong>Warning</strong>: Payloads other than class payloads won't
  * bubble up currently. That behaviour may change in the future
- *
+ * 
  * @author diewald
  */
 
@@ -50,36 +53,38 @@
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
 
-    private int start = -1,
-                end;
-    private int tempStart = 0,
-                tempEnd = 0;
+    private int start = -1, end;
+    private int tempStart = 0, tempEnd = 0;
+
 
     /**
      * Construct a FocusSpan for the given {@link SpanQuery}.
      * 
-     * @param wrapQuery A {@link SpanQuery}.
-     * @param context The {@link AtomicReaderContext}.
-     * @param acceptDocs Bit vector representing the documents
-     *        to be searched in.
-     * @param termContexts A map managing {@link TermState TermStates}.
-     * @param number The class number to focus on.
+     * @param wrapQuery
+     *            A {@link SpanQuery}.
+     * @param context
+     *            The {@link AtomicReaderContext}.
+     * @param acceptDocs
+     *            Bit vector representing the documents
+     *            to be searched in.
+     * @param termContexts
+     *            A map managing {@link TermState TermStates}.
+     * @param number
+     *            The class number to focus on.
      * @throws IOException
      */
-    public FocusSpans (SpanQuery wrapQuery,
-                                  AtomicReaderContext context,
-                                  Bits acceptDocs,
-                                  Map<Term,TermContext> termContexts,
-                                  byte number) throws IOException {
-        this.spans     = wrapQuery.getSpans(context, acceptDocs, termContexts);
-        this.number    = number;
+    public FocusSpans (SpanQuery wrapQuery, AtomicReaderContext context,
+                       Bits acceptDocs, Map<Term, TermContext> termContexts,
+                       byte number) throws IOException {
+        this.spans = wrapQuery.getSpans(context, acceptDocs, termContexts);
+        this.number = number;
         this.wrapQuery = wrapQuery;
         this.wrappedPayload = new ArrayList<byte[]>(6);
     };
 
 
     @Override
-    public Collection<byte[]> getPayload() throws IOException {
+    public Collection<byte[]> getPayload () throws IOException {
         return wrappedPayload;
     };
 
@@ -109,13 +114,14 @@
 
 
     @Override
-    public boolean next() throws IOException {
-        if (DEBUG) log.trace("Forward next match in {}",
-                             this.doc());
+    public boolean next () throws IOException {
+        if (DEBUG)
+            log.trace("Forward next match in {}", this.doc());
 
         // Next span
         while (spans.next()) {
-            if (DEBUG) log.trace("Forward next inner span");
+            if (DEBUG)
+                log.trace("Forward next inner span");
 
             // No classes stored
             wrappedPayload.clear();
@@ -130,7 +136,8 @@
                     // No class payload - ignore
                     // this may be problematic for other calculated payloads!
                     if (payload.length != 9) {
-                        if (DEBUG) log.trace("Ignore old payload {}", payload);
+                        if (DEBUG)
+                            log.trace("Ignore old payload {}", payload);
                         continue;
                     };
 
@@ -138,20 +145,17 @@
                     // and classes are matches!
                     if (payload[8] == this.number) {
                         tempStart = byte2int(payload, 0);
-                        tempEnd   = byte2int(payload, 4);
+                        tempEnd = byte2int(payload, 4);
 
                         if (DEBUG) {
-                            log.trace(
-                                "Found matching class {}-{}",
-                                tempStart,
-                                tempEnd
-                            );
+                            log.trace("Found matching class {}-{}", tempStart,
+                                    tempEnd);
                         };
 
                         // Set start position 
                         if (start == -1 || tempStart < start)
                             start = tempStart;
-			
+
                         // Set end position
                         if (tempEnd > end)
                             end = tempEnd;
@@ -168,12 +172,8 @@
                 continue;
 
             if (DEBUG) {
-                log.trace(
-                    "Start to focus on class {} from {} to {}",
-                    number,
-                    start,
-                    end
-                );
+                log.trace("Start to focus on class {} from {} to {}", number,
+                        start, end);
             };
             return true;
         };
@@ -187,11 +187,11 @@
     // Todo: Check for this on document boundaries!
     @Override
     public boolean skipTo (int target) throws IOException {
-        if (DEBUG) log.trace("Skip MatchSpans {} -> {}",
-                             this.doc(), target);
+        if (DEBUG)
+            log.trace("Skip MatchSpans {} -> {}", this.doc(), target);
 
         if (this.doc() < target && spans.skipTo(target)) {
-            
+
         };
         return false;
     };
@@ -199,10 +199,11 @@
 
     @Override
     public String toString () {
-        return getClass().getName() + "(" + this.wrapQuery.toString() + ")@" +
-            (doc() + ":" + start() + "-" + end());
+        return getClass().getName() + "(" + this.wrapQuery.toString() + ")@"
+                + (doc() + ":" + start() + "-" + end());
     };
 
+
     @Override
     public long cost () {
         return spans.cost();
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/MultipleDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/MultipleDistanceSpans.java
index f972fb2..63d355f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/MultipleDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/MultipleDistanceSpans.java
@@ -12,17 +12,21 @@
 import de.ids_mannheim.korap.query.SpanMultipleDistanceQuery;
 
 /**
- * Span enumeration of matches whose two sub-spans have exactly the same first
- * and second sub-sub-spans. To obtain these matches, the span matches of the
+ * Span enumeration of matches whose two sub-spans have exactly the
+ * same first
+ * and second sub-sub-spans. To obtain these matches, the span matches
+ * of the
  * child spans are filtered.
  * 
- * MultipleDistanceSpans accommodates distance constraint with exclusion. <br />
+ * MultipleDistanceSpans accommodates distance constraint with
+ * exclusion. <br />
  * <br />
  * 
  * This class deals with the following cases:
  * <ol>
  * <li>return the match from another non-exclusion constraint.</li>
- * <li>return only the first-span when all constraints are exclusions.</li>
+ * <li>return only the first-span when all constraints are
+ * exclusions.</li>
  * <li>spans are not in the same doc</li>
  * </ol>
  * 
@@ -33,26 +37,34 @@
     private DistanceSpans x, y;
     private boolean isOrdered;
 
+
     /**
-     * Constructs MultipleDistanceSpans for the two given Spans with the given
-     * {@link SpanMultipleDistanceQuery}.
+     * Constructs MultipleDistanceSpans for the two given Spans with
+     * the given {@link SpanMultipleDistanceQuery}.
      * 
-     * @param query a SpanMultipleDistanceQuery
+     * @param query
+     *            a SpanMultipleDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
-     * @param firstSpans the firstspans
-     * @param secondSpans the secondspans
-     * @param isOrdered <code>true</code> if the spans must occur in order,
-     *        <code>false</code> otherwise.
-     * @param exclusion <code>true</code> if the secondspans must <em>not</em>
-     *        occur together with the firstspans.
+     * @param firstSpans
+     *            the firstspans
+     * @param secondSpans
+     *            the secondspans
+     * @param isOrdered
+     *            <code>true</code> if the spans must occur in order,
+     *            <code>false</code> otherwise.
+     * @param exclusion
+     *            <code>true</code> if the secondspans must
+     *            <em>not</em>
+     *            occur together with the firstspans.
      * @throws IOException
      */
-    public MultipleDistanceSpans(SpanMultipleDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts, Spans firstSpans,
-            Spans secondSpans, boolean isOrdered, boolean exclusion)
+    public MultipleDistanceSpans (SpanMultipleDistanceQuery query,
+                                  AtomicReaderContext context, Bits acceptDocs,
+                                  Map<Term, TermContext> termContexts,
+                                  Spans firstSpans, Spans secondSpans,
+                                  boolean isOrdered, boolean exclusion)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
         this.isOrdered = isOrdered;
@@ -62,17 +74,19 @@
         hasMoreSpans = x.next() && y.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         matchPayload.clear();
         return advance();
     }
 
+
     /**
      * Finds the next match.
      * */
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
         while (hasMoreSpans && ensureSameDoc(x, y)) {
             if (findMatch()) {
                 moveForward();
@@ -83,12 +97,13 @@
         return false;
     }
 
+
     /**
      * Finds the next match of one of the sub/child-span.
      * 
      * @throws IOException
      */
-    private void moveForward() throws IOException {
+    private void moveForward () throws IOException {
         if (isOrdered) {
             if (x.end() < y.end()
                     || (x.end() == y.end() && x.start() < y.start()))
@@ -107,14 +122,16 @@
         }
     }
 
+
     /**
-     * Checks if the sub-spans of x and y having exactly the same position. This
+     * Checks if the sub-spans of x and y having exactly the same
+     * position. This
      * is basically an AND operation.
      * 
      * @return true iff the sub-spans are identical.
      * @throws IOException
      */
-    protected boolean findMatch() throws IOException {
+    protected boolean findMatch () throws IOException {
 
         CandidateSpan xf = x.getMatchFirstSpan();
         CandidateSpan xs = x.getMatchSecondSpan();
@@ -140,7 +157,8 @@
                 }
                 return true;
             }
-        } else if (xf.getStart() == yf.getStart() && xf.getEnd() == yf.getEnd()
+        }
+        else if (xf.getStart() == yf.getStart() && xf.getEnd() == yf.getEnd()
                 && xs.getStart() == ys.getStart() && xs.getEnd() == ys.getEnd()) {
             setMatchProperties(x, false);
             return true;
@@ -148,14 +166,19 @@
         return false;
     }
 
+
     /**
-     * Sets the properties of the given span as the current match properties.
+     * Sets the properties of the given span as the current match
+     * properties.
      * 
-     * @param span a DistanceSpan
-     * @param exclusion <code>true</code> if the spans must <em>not</em> occur
-     *        together, <code>false</code> otherwise.
+     * @param span
+     *            a DistanceSpan
+     * @param exclusion
+     *            <code>true</code> if the spans must <em>not</em>
+     *            occur
+     *            together, <code>false</code> otherwise.
      */
-    private void setMatchProperties(DistanceSpans span, boolean exclusion) {
+    private void setMatchProperties (DistanceSpans span, boolean exclusion) {
         matchStartPosition = span.start();
         matchEndPosition = span.end();
         matchDocNumber = span.doc();
@@ -166,8 +189,9 @@
             setMatchSecondSpan(span.getMatchSecondSpan());
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (y.doc() < target)) {
             if (!y.skipTo(target)) {
                 return false;
@@ -178,8 +202,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return x.cost() + y.cost();
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/NextSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/NextSpans.java
index cfd7694..9c8fa28 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/NextSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/NextSpans.java
@@ -16,10 +16,12 @@
 import de.ids_mannheim.korap.query.SpanNextQuery;
 
 /**
- * NextSpans is an enumeration of Span matches, which ensures that a span is
+ * NextSpans is an enumeration of Span matches, which ensures that a
+ * span is
  * immediately followed by another span.
  * 
- * The implementation allows multiple matches at the same firstspan position.
+ * The implementation allows multiple matches at the same firstspan
+ * position.
  * 
  * @author margaretha
  * @author diewald
@@ -33,17 +35,19 @@
 
     private Logger log = LoggerFactory.getLogger(NextSpans.class);
 
+
     /**
      * Constructs NextSpans for the given {@link SpanNextQuery}.
      * 
-     * @param spanNextQuery a SpanNextQuery
+     * @param spanNextQuery
+     *            a SpanNextQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public NextSpans(SpanNextQuery spanNextQuery, AtomicReaderContext context,
-            Bits acceptDocs, Map<Term, TermContext> termContexts)
+    public NextSpans (SpanNextQuery spanNextQuery, AtomicReaderContext context,
+                      Bits acceptDocs, Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanNextQuery, context, acceptDocs, termContexts);
         collectPayloads = spanNextQuery.isCollectPayloads();
@@ -52,22 +56,26 @@
         candidateList = new ArrayList<>();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         matchPayload.clear();
         return advance();
     }
 
+
     /**
-     * Advances the NextSpans to the next match by checking the matchList or
+     * Advances the NextSpans to the next match by checking the
+     * matchList or
      * setting the matchlist first, if it is empty.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
 
         while (hasMoreSpans || !matchList.isEmpty() || !candidateList.isEmpty()) {
             if (!matchList.isEmpty()) {
@@ -91,17 +99,20 @@
         return false;
     }
 
+
     /**
-     * Sets the matchlist by first searching the candidates and then find all
+     * Sets the matchlist by first searching the candidates and then
+     * find all
      * the matches.
      * 
      * @throws IOException
      */
-    private void setMatchList() throws IOException {
+    private void setMatchList () throws IOException {
         if (firstSpans.doc() == candidateListDocNum) {
             searchCandidates();
             searchMatches();
-        } else {
+        }
+        else {
             candidateList.clear();
             if (hasMoreSpans && ensureSameDoc(firstSpans, secondSpans)) {
                 candidateListDocNum = firstSpans.doc();
@@ -110,35 +121,43 @@
         }
     }
 
+
     /**
-     * Removes all second span candidates whose start position is not the same
-     * as the firstspan's end position, otherwise creates a match and add it to
+     * Removes all second span candidates whose start position is not
+     * the same
+     * as the firstspan's end position, otherwise creates a match and
+     * add it to
      * the matchlist.
      * 
      * @throws IOException
      */
-    private void searchCandidates() throws IOException {
+    private void searchCandidates () throws IOException {
         Iterator<CandidateSpan> i = candidateList.iterator();
         CandidateSpan cs;
         while (i.hasNext()) {
             cs = i.next();
             if (cs.getStart() == firstSpans.end()) {
                 addMatch(cs);
-            } else {
+            }
+            else {
                 i.remove();
             }
         }
     }
 
+
     /**
-     * Finds all secondspans whose start position is the same as the end
-     * position of the firstspans, until the secondspans' start position is
-     * bigger than the firstspans' end position. Adds those secondspans to the
+     * Finds all secondspans whose start position is the same as the
+     * end
+     * position of the firstspans, until the secondspans' start
+     * position is
+     * bigger than the firstspans' end position. Adds those
+     * secondspans to the
      * candidateList and creates matches.
      * 
      * @throws IOException
      */
-    private void searchMatches() throws IOException {
+    private void searchMatches () throws IOException {
 
         while (hasMoreSpans && candidateListDocNum == secondSpans.doc()) {
             if (secondSpans.start() > firstSpans.end()) {
@@ -152,15 +171,19 @@
         }
     }
 
+
     /**
-     * Creates a match from the given CandidateSpan representing a secondspan
-     * state whose start position is identical to the end position of the
+     * Creates a match from the given CandidateSpan representing a
+     * secondspan
+     * state whose start position is identical to the end position of
+     * the
      * current firstspan, and adds it to the matchlist.
      * 
-     * @param cs a CandidateSpan
+     * @param cs
+     *            a CandidateSpan
      * @throws IOException
      */
-    private void addMatch(CandidateSpan cs) throws IOException {
+    private void addMatch (CandidateSpan cs) throws IOException {
 
         int start = firstSpans.start();
         long cost = firstSpans.cost() + cs.getCost();
@@ -177,8 +200,9 @@
                 candidateListDocNum, cost, payloads));
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -189,8 +213,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost() + secondSpans.cost();
     }
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/NonPartialOverlappingSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/NonPartialOverlappingSpans.java
index 8e56ca7..d7f41da 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/NonPartialOverlappingSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/NonPartialOverlappingSpans.java
@@ -14,7 +14,8 @@
 import de.ids_mannheim.korap.query.SimpleSpanQuery;
 
 /**
- * An abstract class for Span enumeration whose two child spans are matched by
+ * An abstract class for Span enumeration whose two child spans are
+ * matched by
  * their positions and do not have a partial overlap.
  * 
  * @author margaretha
@@ -24,19 +25,23 @@
     private Logger log = LoggerFactory
             .getLogger(NonPartialOverlappingSpans.class);
 
+
     /**
      * Constructs NonPartialOverlappingSpans from the given
      * {@link SimpleSpanQuery}.
      * 
-     * @param simpleSpanQuery a SimpleSpanQuery
+     * @param simpleSpanQuery
+     *            a SimpleSpanQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public NonPartialOverlappingSpans(SimpleSpanQuery simpleSpanQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public NonPartialOverlappingSpans (SimpleSpanQuery simpleSpanQuery,
+                                       AtomicReaderContext context,
+                                       Bits acceptDocs,
+                                       Map<Term, TermContext> termContexts)
+            throws IOException {
         super(simpleSpanQuery, context, acceptDocs, termContexts);
 
         // Warning: not implemented, results in errors for SpanNextQuery 
@@ -46,8 +51,9 @@
 
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         // Warning: this does not work for overlapping spans 
         // e.g. get multiple second spans in a firstspan
         hasMoreSpans &= firstSpans.next();
@@ -56,14 +62,16 @@
         return advance();
     }
 
+
     /**
      * Advances to the next match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
         // The complexity is linear for searching in a document. 
         // It's better if we can skip to >= position in a document.
         while (hasMoreSpans && ensureSameDoc(firstSpans, secondSpans)) {
@@ -71,29 +79,35 @@
             if (matchCase == 0) {
                 doCollectPayloads();
                 return true;
-            } else if (matchCase == 1) {
+            }
+            else if (matchCase == 1) {
                 hasMoreSpans = secondSpans.next();
-            } else {
+            }
+            else {
                 hasMoreSpans = firstSpans.next();
             }
         }
         return false;
     }
 
+
     /**
      * Specifies the condition for a match.
      * 
-     * @return 0 iff match is found, -1 to advance the firstspan, 1 to advance
+     * @return 0 iff match is found, -1 to advance the firstspan, 1 to
+     *         advance
      *         the secondspan
      * */
-    protected abstract int findMatch();
+    protected abstract int findMatch ();
+
 
     /**
-     * Collects available payloads from the current first and second spans.
+     * Collects available payloads from the current first and second
+     * spans.
      * 
      * @throws IOException
      */
-    private void doCollectPayloads() throws IOException {
+    private void doCollectPayloads () throws IOException {
         Collection<byte[]> payload;
         if (collectPayloads) {
             if (firstSpans.isPayloadAvailable()) {
@@ -107,8 +121,9 @@
         }
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -119,8 +134,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost() + secondSpans.cost();
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/OrderedDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/OrderedDistanceSpans.java
index 761fa95..88d5bc3 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/OrderedDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/OrderedDistanceSpans.java
@@ -26,18 +26,22 @@
     protected int candidateListIndex;
     protected int candidateListDocNum;
 
+
     /**
-     * Constructs OrderedDistanceSpans based on the given SpanDistanceQuery.
+     * Constructs OrderedDistanceSpans based on the given
+     * SpanDistanceQuery.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public OrderedDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public OrderedDistanceSpans (SpanDistanceQuery query,
+                                 AtomicReaderContext context, Bits acceptDocs,
+                                 Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
 
         minDistance = query.getMinDistance();
@@ -50,11 +54,12 @@
         candidateListDocNum = firstSpans.doc();
     }
 
+
     /**
      * Finds a span match in the candidate list.
      * */
     @Override
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
         while (hasMoreSpans && candidateListIndex < candidateList.size()) {
             // Check candidates
             for (candidateListIndex++; candidateListIndex < candidateList
@@ -66,53 +71,70 @@
             do { // Forward secondspan
                 hasMoreSpans = secondSpans.next();
                 setCandidateList();
-            } while (hasMoreSpans && !isSecondSpanValid());
+            }
+            while (hasMoreSpans && !isSecondSpanValid());
         }
         return false;
     }
 
+
     /**
-     * Determines if the current second span is valid (i.e. within an element).
-     * It is always valid in TokenDistanceSpan, but it can be invalid in the
-     * ElementDistanceSpan, namely when it is not within a particular element (a
+     * Determines if the current second span is valid (i.e. within an
+     * element).
+     * It is always valid in TokenDistanceSpan, but it can be invalid
+     * in the
+     * ElementDistanceSpan, namely when it is not within a particular
+     * element (a
      * sentence or a paragraph depends on the element distance unit).
      * 
      * @return <code>true</code> of the current second span is valid,
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-    protected abstract boolean isSecondSpanValid() throws IOException;
+    protected abstract boolean isSecondSpanValid () throws IOException;
+
 
     /**
-     * Stores/collects the states of all possible firstspans as candidate spans
-     * for the current secondspan. The candidate spans must be within the
+     * Stores/collects the states of all possible firstspans as
+     * candidate spans
+     * for the current secondspan. The candidate spans must be within
+     * the
      * maximum distance from the current secondspan.
      * 
      * @throws IOException
      */
-    protected abstract void setCandidateList() throws IOException;
+    protected abstract void setCandidateList () throws IOException;
+
 
     /**
-     * Defines the conditions for a match and tells if a match is found.
+     * Defines the conditions for a match and tells if a match is
+     * found.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    protected abstract boolean findMatch() throws IOException;
+    protected abstract boolean findMatch () throws IOException;
+
 
     /**
-     * Defines the properties of a span match. The distance between the first
-     * and the second spans is zero, when there is an intersection between them
-     * in {@link TokenDistanceSpans}, or they occur in the same element in
-     * {@link ElementDistanceSpans}.
+     * Defines the properties of a span match. The distance between
+     * the first
+     * and the second spans is zero, when there is an intersection
+     * between them
+     * in {@link TokenDistanceSpans}, or they occur in the same
+     * element in {@link ElementDistanceSpans}.
      * 
-     * @param candidateSpan a match span
-     * @param isDistanceZero <code>true</code> if the distance between the first
-     *        and the second spans is zero, <code>false</code> otherwise.
+     * @param candidateSpan
+     *            a match span
+     * @param isDistanceZero
+     *            <code>true</code> if the distance between the first
+     *            and the second spans is zero, <code>false</code>
+     *            otherwise.
      * @throws IOException
      */
-    protected void setMatchProperties(CandidateSpan candidateSpan,
+    protected void setMatchProperties (CandidateSpan candidateSpan,
             boolean isDistanceZero) throws IOException {
 
         setMatchFirstSpan(candidateSpan);
@@ -123,7 +145,8 @@
                     secondSpans.start());
             matchEndPosition = Math.max(candidateSpan.getEnd(),
                     secondSpans.end());
-        } else {
+        }
+        else {
             matchStartPosition = candidateSpan.getStart();
             matchEndPosition = secondSpans.end();
         }
@@ -139,8 +162,9 @@
         }
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (secondSpans.doc() < target)) {
             if (!secondSpans.skipTo(target)) {
                 candidateList.clear();
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java
index 7897308..8f97f35 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationBaseSpans.java
@@ -13,9 +13,12 @@
 import de.ids_mannheim.korap.query.SpanWithIdQuery;
 
 /**
- * RelationBaseSpans is a base class for relation spans containing properties
- * about the start and end positions of right side of the relation. It can also
- * store information about the id of the left/right side, for instance, when it
+ * RelationBaseSpans is a base class for relation spans containing
+ * properties
+ * about the start and end positions of right side of the relation. It
+ * can also
+ * store information about the id of the left/right side, for
+ * instance, when it
  * is an element or another relation.
  * 
  * @author margaretha
@@ -23,114 +26,139 @@
  */
 public abstract class RelationBaseSpans extends SpansWithId {
 
-	protected short leftId, rightId;
-	protected int leftStart, leftEnd;
-	protected int rightStart, rightEnd;
+    protected short leftId, rightId;
+    protected int leftStart, leftEnd;
+    protected int rightStart, rightEnd;
 
-    public RelationBaseSpans(){};
+
+    public RelationBaseSpans () {};
+
 
     /**
-     * Constructs RelationBaseSpans based on the given SpanWithIdQuery.
+     * Constructs RelationBaseSpans based on the given
+     * SpanWithIdQuery.
      * 
-     * @param spanWithIdQuery a SpanWithIdQuery, for instance a
-     *        {@link SpanElementQuery} or {@link SpanRelationQuery}.
+     * @param spanWithIdQuery
+     *            a SpanWithIdQuery, for instance a
+     *            {@link SpanElementQuery} or
+     *            {@link SpanRelationQuery}.
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public RelationBaseSpans(SpanWithIdQuery spanWithIdQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public RelationBaseSpans (SpanWithIdQuery spanWithIdQuery,
+                              AtomicReaderContext context, Bits acceptDocs,
+                              Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanWithIdQuery, context, acceptDocs, termContexts);
     }
 
+
     /**
      * Returns the id of the left hand side of the relation.
      * 
      * @return an id
      */
-    public short getLeftId() {
+    public short getLeftId () {
         return leftId;
     }
 
+
     /**
      * Sets the id of the left hand side of the relation.
      * 
-     * @param leftId the id of the left hand side of the relation.
+     * @param leftId
+     *            the id of the left hand side of the relation.
      */
-    public void setLeftId(short leftId) {
+    public void setLeftId (short leftId) {
         this.leftId = leftId;
     }
 
-	public int getLeftStart() {
-		return leftStart;
-	}
 
-	public void setLeftStart(int leftStart) {
-		this.leftStart = leftStart;
-	}
+    public int getLeftStart () {
+        return leftStart;
+    }
 
-	public int getLeftEnd() {
-		return leftEnd;
-	}
 
-	public void setLeftEnd(int leftEnd) {
-		this.leftEnd = leftEnd;
-	}
+    public void setLeftStart (int leftStart) {
+        this.leftStart = leftStart;
+    }
 
-	/**
-	 * Returns the id of the right hand side of the relation.
-	 * 
-	 * @return an id
-	 */
-    public short getRightId() {
+
+    public int getLeftEnd () {
+        return leftEnd;
+    }
+
+
+    public void setLeftEnd (int leftEnd) {
+        this.leftEnd = leftEnd;
+    }
+
+
+    /**
+     * Returns the id of the right hand side of the relation.
+     * 
+     * @return an id
+     */
+    public short getRightId () {
         return rightId;
     }
 
+
     /**
      * Sets the id of the right hand side of the relation.
      * 
-     * @param rightId the id of the right hand side of the relation.
+     * @param rightId
+     *            the id of the right hand side of the relation.
      */
-    public void setRightId(short rightId) {
+    public void setRightId (short rightId) {
         this.rightId = rightId;
     }
 
+
     /**
-     * Returns the start position of the right hand side of the relation.
+     * Returns the start position of the right hand side of the
+     * relation.
      * 
      * @return the start position
      */
-    public int getRightStart() {
+    public int getRightStart () {
         return rightStart;
     }
 
+
     /**
      * Sets the start position of the right hand side of the relation.
      * 
-     * @param rightStart the start position of the right hand side of the
-     *        relation.
+     * @param rightStart
+     *            the start position of the right hand side of the
+     *            relation.
      */
-    public void setRightStart(int rightStart) {
+    public void setRightStart (int rightStart) {
         this.rightStart = rightStart;
     }
 
+
     /**
-     * Returns the end position of the right hand side of the relation.
+     * Returns the end position of the right hand side of the
+     * relation.
      * 
      * @return the end position
      */
-    public int getRightEnd() {
+    public int getRightEnd () {
         return rightEnd;
     }
 
+
     /**
      * Sets the start position of the right hand side of the relation.
      * 
-     * @param rightEnd the end position of the right hand side of the relation.
+     * @param rightEnd
+     *            the end position of the right hand side of the
+     *            relation.
      */
-    public void setRightEnd(int rightEnd) {
+    public void setRightEnd (int rightEnd) {
         this.rightEnd = rightEnd;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
index 9a1d578..38eb5fe 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RelationSpans.java
@@ -19,11 +19,14 @@
 import de.ids_mannheim.korap.query.SpanRelationQuery;
 
 /**
- * Enumeration of spans denoting relations between two tokens/elements. The
- * start and end of a RelationSpan always denote the start and end of the
+ * Enumeration of spans denoting relations between two
+ * tokens/elements. The
+ * start and end of a RelationSpan always denote the start and end of
+ * the
  * left-side token/element.
  * 
- * There are 4 types of relations, which is differentiated by the payload length
+ * There are 4 types of relations, which is differentiated by the
+ * payload length
  * in bytes.
  * <ol>
  * <li>Token to token relation (1 int & 3 short, length: 10)</li>
@@ -31,17 +34,24 @@
  * <li>Span to token (int, byte, int, 3 short, length: 15)</li>
  * <li>Span to Span (3 int & 3 short, length: 18)</li>
  * </ol>
- * Every integer value denotes the start/end position of the start/target of a
- * relation, in this format: (sourceEndPos?, startTargetPos, endTargetPos?). The
- * end position of a token is identical to its start position, and therefore not
+ * Every integer value denotes the start/end position of the
+ * start/target of a
+ * relation, in this format: (sourceEndPos?, startTargetPos,
+ * endTargetPos?). The
+ * end position of a token is identical to its start position, and
+ * therefore not
  * is saved in a payload.
  * 
- * The short values denote the relation id, left id, and right id. The byte in
- * relation #3 is just a dummy to create a different length from the relation
+ * The short values denote the relation id, left id, and right id. The
+ * byte in
+ * relation #3 is just a dummy to create a different length from the
+ * relation
  * #2.
  * 
- * NOTE: Sorting of the candidate spans can alternatively be done in indexing,
- * instead of here. (first by left positions and then by right positions)
+ * NOTE: Sorting of the candidate spans can alternatively be done in
+ * indexing,
+ * instead of here. (first by left positions and then by right
+ * positions)
  * 
  * @author margaretha
  * */
@@ -53,47 +63,56 @@
     protected Logger logger = LoggerFactory.getLogger(RelationSpans.class);
     private List<CandidateRelationSpan> candidateList;
 
+
     /**
-     * Constructs RelationSpans from the given {@link SpanRelationQuery}.
+     * Constructs RelationSpans from the given
+     * {@link SpanRelationQuery}.
      * 
-     * @param relationSpanQuery a SpanRelationQuery
+     * @param relationSpanQuery
+     *            a SpanRelationQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public RelationSpans(SpanRelationQuery relationSpanQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public RelationSpans (SpanRelationQuery relationSpanQuery,
+                          AtomicReaderContext context, Bits acceptDocs,
+                          Map<Term, TermContext> termContexts)
+            throws IOException {
         super(relationSpanQuery, context, acceptDocs, termContexts);
         candidateList = new ArrayList<>();
         relationTermSpan = (TermSpans) firstSpans;
         hasMoreSpans = relationTermSpan.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         return advance();
     }
 
+
     /**
-     * Returns true if there is a next match by checking if the CandidateList is
-     * not empty and set the first element of the list as the next match.
-     * Otherwise, if the RelationSpan has not ended yet, try to set the
+     * Returns true if there is a next match by checking if the
+     * CandidateList is
+     * not empty and set the first element of the list as the next
+     * match.
+     * Otherwise, if the RelationSpan has not ended yet, try to set
+     * the
      * CandidateList.
      * 
      * @return true if there is a next match.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (hasMoreSpans || !candidateList.isEmpty()) {
             if (!candidateList.isEmpty()) {
                 CandidateRelationSpan cs = candidateList.get(0);
                 this.matchDocNumber = cs.getDoc();
                 this.matchStartPosition = cs.getStart();
                 this.matchEndPosition = cs.getEnd();
-				this.matchPayload = cs.getPayloads();
+                this.matchPayload = cs.getPayloads();
                 this.setRightStart(cs.getRightStart());
                 this.setRightEnd(cs.getRightEnd());
                 this.spanId = cs.getSpanId(); // relation id
@@ -101,7 +120,7 @@
                 this.rightId = cs.getRightId();
                 candidateList.remove(0);
                 return true;
-            } 
+            }
             else {
                 setCandidateList();
                 currentDoc = relationTermSpan.doc();
@@ -111,33 +130,40 @@
         return false;
     }
 
+
     /**
-     * Setting the CandidateList by adding all relationTermSpan whose start
+     * Setting the CandidateList by adding all relationTermSpan whose
+     * start
      * position is the same as the current span position, and sort the
      * candidateList.
      * 
      * @throws IOException
      */
-    private void setCandidateList() throws IOException {
+    private void setCandidateList () throws IOException {
         while (hasMoreSpans && relationTermSpan.doc() == currentDoc
                 && relationTermSpan.start() == currentPosition) {
-            CandidateRelationSpan cs = new CandidateRelationSpan(relationTermSpan);
+            CandidateRelationSpan cs = new CandidateRelationSpan(
+                    relationTermSpan);
             readPayload(cs);
-			setPayload(cs);
+            setPayload(cs);
             candidateList.add(cs);
             hasMoreSpans = relationTermSpan.next();
         }
         Collections.sort(candidateList);
     }
 
+
     /**
-     * Identify the relation type of the given {@link CandidateRelationSpan} by
-     * checking the length of its payloads, and set some properties of the span
+     * Identify the relation type of the given
+     * {@link CandidateRelationSpan} by
+     * checking the length of its payloads, and set some properties of
+     * the span
      * based on the payloads.
      * 
-     * @param cs a CandidateRelationSpan
+     * @param cs
+     *            a CandidateRelationSpan
      */
-    private void readPayload(CandidateRelationSpan cs) {
+    private void readPayload (CandidateRelationSpan cs) {
         List<byte[]> payload = (List<byte[]>) cs.getPayloads();
         int length = payload.get(0).length;
         ByteBuffer bb = ByteBuffer.allocate(length);
@@ -176,28 +202,31 @@
         // Payload is cleared.		
     }
 
-	private void setPayload(CandidateRelationSpan cs) throws IOException {
-		ArrayList<byte[]> payload = new ArrayList<byte[]>();
-		if (relationTermSpan.isPayloadAvailable()) {
-			payload.addAll(relationTermSpan.getPayload());
-		}
-		payload.add(createClassPayload(cs.getLeftStart(), cs.getLeftEnd(),
-				(byte) 1));
-		payload.add(createClassPayload(cs.getRightStart(), cs.getRightEnd(),
-				(byte) 2));
-		cs.setPayloads(payload);
-	}
 
-	private byte[] createClassPayload(int start, int end, byte classNumber) {
-		ByteBuffer buffer = ByteBuffer.allocate(9);
-		buffer.putInt(start);
-		buffer.putInt(end);
-		buffer.put(classNumber);
-		return buffer.array();
-	}
+    private void setPayload (CandidateRelationSpan cs) throws IOException {
+        ArrayList<byte[]> payload = new ArrayList<byte[]>();
+        if (relationTermSpan.isPayloadAvailable()) {
+            payload.addAll(relationTermSpan.getPayload());
+        }
+        payload.add(createClassPayload(cs.getLeftStart(), cs.getLeftEnd(),
+                (byte) 1));
+        payload.add(createClassPayload(cs.getRightStart(), cs.getRightEnd(),
+                (byte) 2));
+        cs.setPayloads(payload);
+    }
+
+
+    private byte[] createClassPayload (int start, int end, byte classNumber) {
+        ByteBuffer buffer = ByteBuffer.allocate(9);
+        buffer.putInt(start);
+        buffer.putInt(end);
+        buffer.put(classNumber);
+        return buffer.array();
+    }
+
 
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 candidateList.clear();
@@ -210,90 +239,108 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost();
     }
 
+
     /**
      * Returns the right start position of the current RelationSpan.
      * 
      * @return the right start position of the current RelationSpan.
      */
-    public int getRightStart() {
+    public int getRightStart () {
         return rightStart;
     }
 
+
     /**
      * Sets the right start position of the current RelationSpan.
      * 
-     * @param rightStart the right start position of the current RelationSpan
+     * @param rightStart
+     *            the right start position of the current RelationSpan
      */
-    public void setRightStart(int rightStart) {
+    public void setRightStart (int rightStart) {
         this.rightStart = rightStart;
     }
 
+
     /**
      * Returns the right end position of the current RelationSpan.
      * 
      * @return the right end position of the current RelationSpan.
      */
-    public int getRightEnd() {
+    public int getRightEnd () {
         return rightEnd;
     }
 
+
     /**
      * Sets the right end position of the current RelationSpan.
      * 
-     * @param rightEnd the right end position of the current RelationSpan.
+     * @param rightEnd
+     *            the right end position of the current RelationSpan.
      */
-    public void setRightEnd(int rightEnd) {
+    public void setRightEnd (int rightEnd) {
         this.rightEnd = rightEnd;
     }
 
     /**
-	 * CandidateRelationSpan stores a state of RelationSpans. In a list,
-	 * CandidateRelationSpans are ordered first by the position of the relation
-	 * left side.
-	 */
-	class CandidateRelationSpan extends CandidateSpan {
+     * CandidateRelationSpan stores a state of RelationSpans. In a
+     * list,
+     * CandidateRelationSpans are ordered first by the position of the
+     * relation
+     * left side.
+     */
+    class CandidateRelationSpan extends CandidateSpan {
 
         private int rightStart, rightEnd;
         private short leftId, rightId;
 
-        public CandidateRelationSpan(Spans span) throws IOException {
+
+        public CandidateRelationSpan (Spans span) throws IOException {
             super(span);
         }
 
-        public int getRightEnd() {
+
+        public int getRightEnd () {
             return rightEnd;
         }
 
-        public void setRightEnd(int rightEnd) {
+
+        public void setRightEnd (int rightEnd) {
             this.rightEnd = rightEnd;
         }
 
-        public int getRightStart() {
+
+        public int getRightStart () {
             return rightStart;
         }
 
-        public void setRightStart(int rightStart) {
+
+        public void setRightStart (int rightStart) {
             this.rightStart = rightStart;
         }
 
-        public short getLeftId() {
+
+        public short getLeftId () {
             return leftId;
         }
 
-        public void setLeftId(short leftId) {
+
+        public void setLeftId (short leftId) {
             this.leftId = leftId;
         }
 
-        public short getRightId() {
+
+        public short getRightId () {
             return rightId;
         }
 
-        public void setRightId(short rightId) {
+
+        public void setRightId (short rightId) {
             this.rightId = rightId;
         }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/RepetitionSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/RepetitionSpans.java
index f66d78c..1809309 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/RepetitionSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/RepetitionSpans.java
@@ -15,7 +15,8 @@
 import de.ids_mannheim.korap.query.SpanRepetitionQuery;
 
 /**
- * Enumeration of spans occurring multiple times in a sequence. The number of
+ * Enumeration of spans occurring multiple times in a sequence. The
+ * number of
  * repetition depends on the min and max parameters.
  * 
  * @author margaretha
@@ -26,18 +27,22 @@
     private long matchCost;
     private List<CandidateSpan> matchList;
 
+
     /**
-     * Constructs RepetitionSpans from the given {@link SpanRepetitionQuery}.
+     * Constructs RepetitionSpans from the given
+     * {@link SpanRepetitionQuery}.
      * 
-     * @param query a SpanRepetitionQuery
+     * @param query
+     *            a SpanRepetitionQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public RepetitionSpans(SpanRepetitionQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public RepetitionSpans (SpanRepetitionQuery query,
+                            AtomicReaderContext context, Bits acceptDocs,
+                            Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
         this.min = query.getMin();
         this.max = query.getMax();
@@ -45,23 +50,28 @@
         hasMoreSpans = firstSpans.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         matchPayload.clear();
         return advance();
     }
 
+
     /**
-     * Advances the RepetitionSpans to the next match by setting the first
-     * element in the matchlist as the current match. When the matchlist is
+     * Advances the RepetitionSpans to the next match by setting the
+     * first
+     * element in the matchlist as the current match. When the
+     * matchlist is
      * empty, it has to be set first.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
 
         while (hasMoreSpans || !matchList.isEmpty()) {
             if (!matchList.isEmpty()) {
@@ -77,13 +87,14 @@
         return false;
     }
 
+
     /**
      * Collects all adjacent firstspans occurring in a sequence.
      * 
      * @return a list of the adjacent spans
      * @throws IOException
      */
-    private List<CandidateSpan> collectAdjacentSpans() throws IOException {
+    private List<CandidateSpan> collectAdjacentSpans () throws IOException {
 
         CandidateSpan startSpan = new CandidateSpan(firstSpans);
 
@@ -97,7 +108,8 @@
 
             if (firstSpans.start() > prevSpan.getEnd()) {
                 break;
-            } else if (firstSpans.start() == prevSpan.getEnd()) {
+            }
+            else if (firstSpans.start() == prevSpan.getEnd()) {
                 prevSpan = new CandidateSpan(firstSpans);
                 adjacentSpans.add(prevSpan);
             }
@@ -105,13 +117,15 @@
         return adjacentSpans;
     }
 
+
     /**
-     * Generates all possible repetition match spans from the given list of
+     * Generates all possible repetition match spans from the given
+     * list of
      * adjacent spans and add them to the match list.
      * 
      * @param adjacentSpans
      */
-    private void setMatchList(List<CandidateSpan> adjacentSpans) {
+    private void setMatchList (List<CandidateSpan> adjacentSpans) {
         CandidateSpan startSpan, endSpan, matchSpan;
         for (int i = min; i < max + 1; i++) {
             int j = 0;
@@ -124,10 +138,12 @@
                         matchSpan.setPayloads(computeMatchPayload(
                                 adjacentSpans, 0, endIndex - 1));
                         matchList.add(matchSpan);
-                    } catch (CloneNotSupportedException e) {
+                    }
+                    catch (CloneNotSupportedException e) {
                         e.printStackTrace();
                     }
-                } else {
+                }
+                else {
                     endSpan = adjacentSpans.get(endIndex);
                     matchSpan = new CandidateSpan(startSpan.getStart(),
                             endSpan.getEnd(), startSpan.getDoc(),
@@ -144,19 +160,27 @@
         Collections.sort(matchList);
     }
 
+
     /**
-     * Creates payloads by adding all the payloads of some adjacent spans, that
-     * are all spans in the given list whose index is between the start and end
+     * Creates payloads by adding all the payloads of some adjacent
+     * spans, that
+     * are all spans in the given list whose index is between the
+     * start and end
      * index (including those with these indexes).
      * 
-     * @param adjacentSpans a list of adjacentSpans
-     * @param start the start index representing the first adjacent span in the
-     *        list to be computed
-     * @param end the end index representing the last adjacent span in the list
-     *        to be computed
+     * @param adjacentSpans
+     *            a list of adjacentSpans
+     * @param start
+     *            the start index representing the first adjacent span
+     *            in the
+     *            list to be computed
+     * @param end
+     *            the end index representing the last adjacent span in
+     *            the list
+     *            to be computed
      * @return payloads
      */
-    private Collection<byte[]> computeMatchPayload(
+    private Collection<byte[]> computeMatchPayload (
             List<CandidateSpan> adjacentSpans, int start, int end) {
         Collection<byte[]> payload = new ArrayList<byte[]>();
         for (int i = start; i <= end; i++) {
@@ -165,17 +189,22 @@
         return payload;
     }
 
+
     /**
-     * Computes the matchcost by adding all the cost of the adjacent spans
+     * Computes the matchcost by adding all the cost of the adjacent
+     * spans
      * between the start and end index in the given list.
      * 
-     * @param adjacentSpans a list of adjacent spans
-     * @param start the start index
-     * @param end the end index
+     * @param adjacentSpans
+     *            a list of adjacent spans
+     * @param start
+     *            the start index
+     * @param end
+     *            the end index
      * @return
      */
-    private long computeMatchCost(List<CandidateSpan> adjacentSpans, int start,
-            int end) {
+    private long computeMatchCost (List<CandidateSpan> adjacentSpans,
+            int start, int end) {
         long matchCost = 0;
         for (int i = start; i <= end; i++) {
             matchCost += adjacentSpans.get(i).getCost();
@@ -183,13 +212,16 @@
         return matchCost;
     }
 
+
     /**
-     * Sets properties for the current match from the given candidate span.
+     * Sets properties for the current match from the given candidate
+     * span.
      * 
-     * @param candidateSpan the match candidate span
+     * @param candidateSpan
+     *            the match candidate span
      * @throws IOException
      */
-    private void setMatchProperties(CandidateSpan candidateSpan)
+    private void setMatchProperties (CandidateSpan candidateSpan)
             throws IOException {
         matchDocNumber = candidateSpan.getDoc();
         matchStartPosition = candidateSpan.getStart();
@@ -199,8 +231,9 @@
         }
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && firstSpans.doc() < target) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -211,8 +244,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return matchCost;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SegmentSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/SegmentSpans.java
index b601d28..79ef116 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SegmentSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SegmentSpans.java
@@ -11,74 +11,82 @@
 import de.ids_mannheim.korap.query.SpanSegmentQuery;
 
 /**
- * SegmentSpans is an enumeration of Span matches in which that two child spans
+ * SegmentSpans is an enumeration of Span matches in which that two
+ * child spans
  * have exactly the same start and end positions.
  * 
  * @author margaretha
  * */
 public class SegmentSpans extends NonPartialOverlappingSpans {
 
-	private boolean isRelation;
+    private boolean isRelation;
+
+
     /**
      * Creates SegmentSpans from the given {@link SpanSegmentQuery}.
      * 
-     * @param spanSegmentQuery a spanSegmentQuery.
+     * @param spanSegmentQuery
+     *            a spanSegmentQuery.
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public SegmentSpans(SpanSegmentQuery spanSegmentQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
-		super(spanSegmentQuery, context, acceptDocs, termContexts);
-		if (spanSegmentQuery.isRelation()) {
-			SpansWithId s2 = (SpansWithId) secondSpans;
-			// hacking for element query
-			s2.hasSpanId = true;
-			isRelation = true;
-		}
+    public SegmentSpans (SpanSegmentQuery spanSegmentQuery,
+                         AtomicReaderContext context, Bits acceptDocs,
+                         Map<Term, TermContext> termContexts)
+            throws IOException {
+        super(spanSegmentQuery, context, acceptDocs, termContexts);
+        if (spanSegmentQuery.isRelation()) {
+            SpansWithId s2 = (SpansWithId) secondSpans;
+            // hacking for element query
+            s2.hasSpanId = true;
+            isRelation = true;
+        }
     }
 
+
     /**
-     * Check weather the start and end positions of the current firstspan and
+     * Check weather the start and end positions of the current
+     * firstspan and
      * secondspan are identical.
      * 
      * */
     @Override
-    protected int findMatch() {
-		RelationSpans s1;
-		SpansWithId s2;
+    protected int findMatch () {
+        RelationSpans s1;
+        SpansWithId s2;
         if (firstSpans.start() == secondSpans.start()
                 && firstSpans.end() == secondSpans.end()) {
 
-			if (isRelation) {
-				s1 = (RelationSpans) firstSpans;
-				s2 = (SpansWithId) secondSpans;
+            if (isRelation) {
+                s1 = (RelationSpans) firstSpans;
+                s2 = (SpansWithId) secondSpans;
 
-				//System.out.println("segment: " + s1.getRightStart() + " "
-				// + s1.getRightEnd());
-				if (s1.getLeftId() == s2.getSpanId()) {
-					setMatch();
-					return 0;
-				}
-			}
-			else {
-				setMatch();
-				return 0;
-			}            
-		}
+                //System.out.println("segment: " + s1.getRightStart() + " "
+                // + s1.getRightEnd());
+                if (s1.getLeftId() == s2.getSpanId()) {
+                    setMatch();
+                    return 0;
+                }
+            }
+            else {
+                setMatch();
+                return 0;
+            }
+        }
 
-		if (firstSpans.start() < secondSpans.start()
+        if (firstSpans.start() < secondSpans.start()
                 || firstSpans.end() < secondSpans.end())
             return -1;
 
         return 1;
     }
 
-	private void setMatch() {
-		matchDocNumber = firstSpans.doc();
-		matchStartPosition = firstSpans.start();
-		matchEndPosition = firstSpans.end();
-	}
+
+    private void setMatch () {
+        matchDocNumber = firstSpans.doc();
+        matchStartPosition = firstSpans.start();
+        matchEndPosition = firstSpans.end();
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SimpleSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/SimpleSpans.java
index 5b141a6..f1ec996 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SimpleSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SimpleSpans.java
@@ -14,122 +14,141 @@
 
 import de.ids_mannheim.korap.query.SimpleSpanQuery;
 
-/** An abstract class for Span enumeration including span match properties
- * 	and basic methods.
- *  
- * 	@author margaretha 
+/**
+ * An abstract class for Span enumeration including span match
+ * properties
+ * and basic methods.
+ * 
+ * @author margaretha
  * */
-public abstract class SimpleSpans extends Spans{
-	private SimpleSpanQuery query;
-	protected boolean isStartEnumeration;
-	protected boolean collectPayloads;
-	
-	protected boolean hasMoreSpans;
-	// Warning: enumeration of Spans
-	protected Spans firstSpans, secondSpans;
-	
-	protected int matchDocNumber, matchStartPosition, matchEndPosition;	
-	protected Collection<byte[]> matchPayload;	
-      
-	public SimpleSpans() {
-		collectPayloads = true;
-		matchDocNumber = -1;
-		matchStartPosition = -1;
-		matchEndPosition = -1;
-		matchPayload = new ArrayList<byte[]>();
-		isStartEnumeration = true;
-	};
-	
+public abstract class SimpleSpans extends Spans {
+    private SimpleSpanQuery query;
+    protected boolean isStartEnumeration;
+    protected boolean collectPayloads;
+
+    protected boolean hasMoreSpans;
+    // Warning: enumeration of Spans
+    protected Spans firstSpans, secondSpans;
+
+    protected int matchDocNumber, matchStartPosition, matchEndPosition;
+    protected Collection<byte[]> matchPayload;
+
+
+    public SimpleSpans () {
+        collectPayloads = true;
+        matchDocNumber = -1;
+        matchStartPosition = -1;
+        matchEndPosition = -1;
+        matchPayload = new ArrayList<byte[]>();
+        isStartEnumeration = true;
+    };
+
+
     public SimpleSpans (SimpleSpanQuery simpleSpanQuery,
-			AtomicReaderContext context,
-			Bits acceptDocs,
-			Map<Term,TermContext> termContexts) throws IOException {
-		this();
-    	query = simpleSpanQuery;
-    	collectPayloads = query.isCollectPayloads();
-  		// Get the enumeration of the two spans to match
-		SpanQuery sq;
-		if ((sq = simpleSpanQuery.getFirstClause()) != null)
-			firstSpans = sq.getSpans(context, acceptDocs, termContexts);
-  		
-		if ((sq = simpleSpanQuery.getSecondClause()) != null)
-			secondSpans = sq.getSpans(context, acceptDocs, termContexts);
-  		
-      }
-  	
-  	/** If the current x and y are not in the same document, to skip the 
-  	 * 	span with the smaller document number, to the same OR a greater 
-  	 * 	document number than, the document number of the other span. Do 
-  	 * 	this until the x and the y are in the same doc, OR until the last 
-  	 * 	document.	
-  	 *	@return true iff such a document exists.
-  	 * */
-  	protected boolean ensureSameDoc(Spans x, Spans y) throws IOException {		
-  		while (x.doc() != y.doc()) {
-  			if (x.doc() < y.doc()){
-  				if (!x.skipTo(y.doc())){
-  					hasMoreSpans = false;
-  					return false;
-  				}				
-  			}		
-  			else {
-  				if (!y.skipTo(x.doc())){
-  					hasMoreSpans = false;
-  					return false;
-  				}	
-  			}			
-  		}		
-  		return true;
-  	} 	
-  	
-	/** Find the same doc shared by element, firstspan and secondspan.
-	 *  @return true iff such a doc is found.
-	 * */
-	protected boolean findSameDoc(Spans x, 
-			Spans y, Spans e) throws IOException{
-		
-		while (hasMoreSpans) {
-			if (ensureSameDoc(x, y) &&
-					e.doc() == x.doc()){
-				return true;
-			}			
-			if (!ensureSameDoc(e,y)){
-				return false;
-			};
-		}		
-  		return false;
-	}
-  	
-  	@Override
-  	public int doc() {
-  		return matchDocNumber;
-  	}
+                        AtomicReaderContext context, Bits acceptDocs,
+                        Map<Term, TermContext> termContexts) throws IOException {
+        this();
+        query = simpleSpanQuery;
+        collectPayloads = query.isCollectPayloads();
+        // Get the enumeration of the two spans to match
+        SpanQuery sq;
+        if ((sq = simpleSpanQuery.getFirstClause()) != null)
+            firstSpans = sq.getSpans(context, acceptDocs, termContexts);
 
-  	@Override
-  	public int start() {
-  		return matchStartPosition;
-  	}
+        if ((sq = simpleSpanQuery.getSecondClause()) != null)
+            secondSpans = sq.getSpans(context, acceptDocs, termContexts);
 
-  	@Override
-  	public int end() {
-  		return matchEndPosition;
-  	}
+    }
 
-	@Override
-  	public Collection<byte[]> getPayload() throws IOException {
-  		return matchPayload;
-  	}
 
-  	@Override
-  	public boolean isPayloadAvailable() throws IOException {
-  		return !matchPayload.isEmpty();
-  	}
-  	
-  	@Override
-  	public String toString() {				
-  		return getClass().getName() + "("+query.toString()+")@"+
-  		    (isStartEnumeration?"START":(hasMoreSpans?(doc()+":"+
-  		    start()+"-"+end()):"END"));
-  	}
-    
+    /**
+     * If the current x and y are not in the same document, to skip
+     * the
+     * span with the smaller document number, to the same OR a greater
+     * document number than, the document number of the other span. Do
+     * this until the x and the y are in the same doc, OR until the
+     * last
+     * document.
+     * 
+     * @return true iff such a document exists.
+     * */
+    protected boolean ensureSameDoc (Spans x, Spans y) throws IOException {
+        while (x.doc() != y.doc()) {
+            if (x.doc() < y.doc()) {
+                if (!x.skipTo(y.doc())) {
+                    hasMoreSpans = false;
+                    return false;
+                }
+            }
+            else {
+                if (!y.skipTo(x.doc())) {
+                    hasMoreSpans = false;
+                    return false;
+                }
+            }
+        }
+        return true;
+    }
+
+
+    /**
+     * Find the same doc shared by element, firstspan and secondspan.
+     * 
+     * @return true iff such a doc is found.
+     * */
+    protected boolean findSameDoc (Spans x, Spans y, Spans e)
+            throws IOException {
+
+        while (hasMoreSpans) {
+            if (ensureSameDoc(x, y) && e.doc() == x.doc()) {
+                return true;
+            }
+            if (!ensureSameDoc(e, y)) {
+                return false;
+            };
+        }
+        return false;
+    }
+
+
+    @Override
+    public int doc () {
+        return matchDocNumber;
+    }
+
+
+    @Override
+    public int start () {
+        return matchStartPosition;
+    }
+
+
+    @Override
+    public int end () {
+        return matchEndPosition;
+    }
+
+
+    @Override
+    public Collection<byte[]> getPayload () throws IOException {
+        return matchPayload;
+    }
+
+
+    @Override
+    public boolean isPayloadAvailable () throws IOException {
+        return !matchPayload.isEmpty();
+    }
+
+
+    @Override
+    public String toString () {
+        return getClass().getName()
+                + "("
+                + query.toString()
+                + ")@"
+                + (isStartEnumeration ? "START" : (hasMoreSpans ? (doc() + ":"
+                        + start() + "-" + end()) : "END"));
+    }
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
index 4446555..d7fa03f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithAttribute.java
@@ -18,12 +18,16 @@
 import de.ids_mannheim.korap.query.SpanWithAttributeQuery;
 
 /**
- * Span enumeration of element or relation spans (referent spans) having and/or
- * <em>not</em> having some attributes. This class only handles <em>and</em>
+ * Span enumeration of element or relation spans (referent spans)
+ * having and/or
+ * <em>not</em> having some attributes. This class only handles
+ * <em>and</em>
  * operation on attributes.
  * 
- * Use SpanOrQuery to perform <em>or</em> operation on attributes, i.e. choose
- * between two elements with some attribute constraints. Note that the attribute
+ * Use SpanOrQuery to perform <em>or</em> operation on attributes,
+ * i.e. choose
+ * between two elements with some attribute constraints. Note that the
+ * attribute
  * constraints have to be formulated in Conjunctive Normal Form (CNF).
  * 
  * @author margaretha
@@ -36,150 +40,169 @@
 
     protected Logger logger = LoggerFactory.getLogger(SpansWithAttribute.class);
 
+
     /**
      * Constructs SpansWithAttribute from the given
      * {@link SpanWithAttributeQuery} and {@link SpansWithId}, such as
      * elementSpans and relationSpans.
      * 
-     * @param spanWithAttributeQuery a spanWithAttributeQuery
-     * @param spansWithId a SpansWithId
+     * @param spanWithAttributeQuery
+     *            a spanWithAttributeQuery
+     * @param spansWithId
+     *            a SpansWithId
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public SpansWithAttribute(SpanWithAttributeQuery spanWithAttributeQuery,
-            SpansWithId spansWithId, AtomicReaderContext context,
-            Bits acceptDocs, Map<Term, TermContext> termContexts)
+    public SpansWithAttribute (SpanWithAttributeQuery spanWithAttributeQuery,
+                               SpansWithId spansWithId,
+                               AtomicReaderContext context, Bits acceptDocs,
+                               Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanWithAttributeQuery, context, acceptDocs, termContexts);
         referentSpans = spansWithId;
         referentSpans.hasSpanId = true; // dummy setting enabling reading elementRef
         hasMoreSpans = referentSpans.next();
-		setAttributeList(spanWithAttributeQuery, context, acceptDocs,
-				termContexts);
+        setAttributeList(spanWithAttributeQuery, context, acceptDocs,
+                termContexts);
     }
 
-	// if there is no (positive) attributes, but there are *not attributes*
-	// hasmorespan = true
-	public SpansWithAttribute(SpanWithAttributeQuery spanWithAttributeQuery,
-			AtomicReaderContext context,
-			Bits acceptDocs, Map<Term, TermContext> termContexts)
-			throws IOException {
-		super(spanWithAttributeQuery, context, acceptDocs, termContexts);
-		hasMoreSpans = true;
-		setAttributeList(spanWithAttributeQuery, context, acceptDocs,
-				termContexts);
-		if (attributeList.size() == 0){
-			throw new IllegalArgumentException("No (positive) attribute is defined."); 
-		}
-		else if (attributeList.size() > 1) {
-			referentSpans = attributeList.get(0);
-			attributeList.remove(0);
-		}
-	}
 
-	public void setAttributeList(SpanWithAttributeQuery swaq,
-			AtomicReaderContext context, Bits acceptDocs,
-			Map<Term, TermContext> termContexts) throws IOException {
-		
-		attributeList = new ArrayList<AttributeSpans>();
-		notAttributeList = new ArrayList<AttributeSpans>();
+    // if there is no (positive) attributes, but there are *not attributes*
+    // hasmorespan = true
+    public SpansWithAttribute (SpanWithAttributeQuery spanWithAttributeQuery,
+                               AtomicReaderContext context, Bits acceptDocs,
+                               Map<Term, TermContext> termContexts)
+            throws IOException {
+        super(spanWithAttributeQuery, context, acceptDocs, termContexts);
+        hasMoreSpans = true;
+        setAttributeList(spanWithAttributeQuery, context, acceptDocs,
+                termContexts);
+        if (attributeList.size() == 0) {
+            throw new IllegalArgumentException(
+                    "No (positive) attribute is defined.");
+        }
+        else if (attributeList.size() > 1) {
+            referentSpans = attributeList.get(0);
+            attributeList.remove(0);
+        }
+    }
 
-		List<SpanQuery> attributeList = swaq.getClauseList();
-		if (swaq.isMultipleAttributes) {
-			if (attributeList != null) {
-				for (SpanQuery sq : attributeList) {
-					addAttributes((SpanAttributeQuery) sq, context, acceptDocs,
-							termContexts);
-				}
-			}
-			else {
-				throw new NullPointerException("Attribute list is null.");
-			}
-		} 
-		else if (swaq.getSecondClause() != null) {
-			addAttributes((SpanAttributeQuery) swaq.getSecondClause(),
-					context, acceptDocs, termContexts);
-		}
-		else if (swaq.getType().equals("spanWithAttribute") &&
-				swaq.getFirstClause() != null) {
-			addAttributes((SpanAttributeQuery) swaq.getFirstClause(),
-					context, acceptDocs, termContexts);
-		}
-		else {
-			throw new NullPointerException("No attribute is defined.");
-		}
-	}
+
+    public void setAttributeList (SpanWithAttributeQuery swaq,
+            AtomicReaderContext context, Bits acceptDocs,
+            Map<Term, TermContext> termContexts) throws IOException {
+
+        attributeList = new ArrayList<AttributeSpans>();
+        notAttributeList = new ArrayList<AttributeSpans>();
+
+        List<SpanQuery> attributeList = swaq.getClauseList();
+        if (swaq.isMultipleAttributes) {
+            if (attributeList != null) {
+                for (SpanQuery sq : attributeList) {
+                    addAttributes((SpanAttributeQuery) sq, context, acceptDocs,
+                            termContexts);
+                }
+            }
+            else {
+                throw new NullPointerException("Attribute list is null.");
+            }
+        }
+        else if (swaq.getSecondClause() != null) {
+            addAttributes((SpanAttributeQuery) swaq.getSecondClause(), context,
+                    acceptDocs, termContexts);
+        }
+        else if (swaq.getType().equals("spanWithAttribute")
+                && swaq.getFirstClause() != null) {
+            addAttributes((SpanAttributeQuery) swaq.getFirstClause(), context,
+                    acceptDocs, termContexts);
+        }
+        else {
+            throw new NullPointerException("No attribute is defined.");
+        }
+    }
+
 
     /**
-     * Adds the given {@link SpanAttributeQuery} to the attributeList or
-     * notAttributeList depending on the query, whether it is a negation or not.
+     * Adds the given {@link SpanAttributeQuery} to the attributeList
+     * or
+     * notAttributeList depending on the query, whether it is a
+     * negation or not.
      * 
-     * @param sq a SpanAttributeQuery
+     * @param sq
+     *            a SpanAttributeQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    private void addAttributes(SpanAttributeQuery sq,
+    private void addAttributes (SpanAttributeQuery sq,
             AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
-    	
+
         AttributeSpans as = (AttributeSpans) sq.getSpans(context, acceptDocs,
                 termContexts);
         if (sq.isNegation()) {
             notAttributeList.add(as);
             as.next();
-        } 
+        }
         else {
             attributeList.add(as);
             hasMoreSpans &= as.next();
         }
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
-		if (referentSpans == null) { // only one (positive) attribute
-			return advanceAttribute();
-		}
-		else { return advance(); }
+        if (referentSpans == null) { // only one (positive) attribute
+            return advanceAttribute();
+        }
+        else {
+            return advance();
+        }
     }
 
-	private boolean advanceAttribute() throws IOException {
-		while(hasMoreSpans){
-			SpansWithId referentSpans = attributeList.get(0);
-			advanceNotAttributes(referentSpans);
-			if (checkNotReferentId(referentSpans)) {
-				this.matchDocNumber = referentSpans.doc();
-				this.matchStartPosition = referentSpans.start();
-				this.matchEndPosition = referentSpans.end();
-				this.matchPayload = referentSpans.getPayload();
-				this.spanId = referentSpans.getSpanId();
-				hasMoreSpans = referentSpans.next();
-				return true;
-			}
-		}
-		return false;
-	}
 
-	/**
-	 * Searches for the next match by first identify a possible element
-	 * position, and then ensuring that the element contains all the attributes
-	 * and <em>do not</em> contain any of the not attributes.
-	 * 
-	 * @return <code>true</code> if the a match is found, <code>false</code>
-	 *         otherwise.
-	 * @throws IOException
-	 */
-    private boolean advance() throws IOException {
+    private boolean advanceAttribute () throws IOException {
+        while (hasMoreSpans) {
+            SpansWithId referentSpans = attributeList.get(0);
+            advanceNotAttributes(referentSpans);
+            if (checkNotReferentId(referentSpans)) {
+                this.matchDocNumber = referentSpans.doc();
+                this.matchStartPosition = referentSpans.start();
+                this.matchEndPosition = referentSpans.end();
+                this.matchPayload = referentSpans.getPayload();
+                this.spanId = referentSpans.getSpanId();
+                hasMoreSpans = referentSpans.next();
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+     * Searches for the next match by first identify a possible
+     * element
+     * position, and then ensuring that the element contains all the
+     * attributes
+     * and <em>do not</em> contain any of the not attributes.
+     * 
+     * @return <code>true</code> if the a match is found,
+     *         <code>false</code>
+     *         otherwise.
+     * @throws IOException
+     */
+    private boolean advance () throws IOException {
 
         while (hasMoreSpans && searchSpanPosition()) {
-//			System.out.println("element: " + referentSpans.start() + ","
-//					+ referentSpans.end() + " ref:"+ referentSpans.getSpanId());
+            //			System.out.println("element: " + referentSpans.start() + ","
+            //					+ referentSpans.end() + " ref:"+ referentSpans.getSpanId());
 
-			if (checkReferentId() && checkNotReferentId(referentSpans)) {
+            if (checkReferentId() && checkNotReferentId(referentSpans)) {
                 this.matchDocNumber = referentSpans.doc();
                 this.matchStartPosition = referentSpans.start();
                 this.matchEndPosition = referentSpans.end();
@@ -196,23 +219,27 @@
         return false;
     }
 
+
     /**
-     * Searches for a possible referentSpan having the same document number and
-     * start position as the attributes', and the position is different from the
+     * Searches for a possible referentSpan having the same document
+     * number and
+     * start position as the attributes', and the position is
+     * different from the
      * <em>not attributes'</em> positions.
      * 
-     * @return <code>true</code> if the referentSpan position is valid,
+     * @return <code>true</code> if the referentSpan position is
+     *         valid,
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean searchSpanPosition() throws IOException {
+    private boolean searchSpanPosition () throws IOException {
         while (hasMoreSpans) {
             if (referentSpans.getSpanId() < 1) { // the element does not have an attribute
                 hasMoreSpans = referentSpans.next();
                 continue;
             }
             if (checkAttributeListPosition()) {
-				advanceNotAttributes(referentSpans);
+                advanceNotAttributes(referentSpans);
                 // logger.info("element is found: "+ withAttributeSpans.start());
                 return true;
             }
@@ -220,15 +247,18 @@
         return false;
     }
 
+
     /**
-     * Advances the attributes to be in the same document and start position as
+     * Advances the attributes to be in the same document and start
+     * position as
      * the referentSpan.
      * 
-     * @return <code>true</code> if the attributes are in the same document and
+     * @return <code>true</code> if the attributes are in the same
+     *         document and
      *         start position as the referentSpan.
      * @throws IOException
      */
-    private boolean checkAttributeListPosition() throws IOException {
+    private boolean checkAttributeListPosition () throws IOException {
         int currentPosition = referentSpans.start();
         boolean isSame = true;
         boolean isFirst = true;
@@ -240,7 +270,8 @@
             if (isFirst) {
                 isFirst = false;
                 currentPosition = referentSpans.start();
-            } else if (currentPosition != referentSpans.start()) {
+            }
+            else if (currentPosition != referentSpans.start()) {
                 currentPosition = referentSpans.start();
                 isSame = false;
 
@@ -250,18 +281,20 @@
         return isSame;
     }
 
+
     /**
-     * Advances the element or attribute spans to be in the same document and
+     * Advances the element or attribute spans to be in the same
+     * document and
      * start position.
      * */
-    private boolean ensureSamePosition(SpansWithId spans,
+    private boolean ensureSamePosition (SpansWithId spans,
             AttributeSpans attributes) throws IOException {
 
         while (hasMoreSpans && ensureSameDoc(spans, attributes)) {
-			if (attributes.start() == spans.start()
-					&& attributes.end() == spans.end())
+            if (attributes.start() == spans.start()
+                    && attributes.end() == spans.end())
                 return true;
-			else if (attributes.start() >= spans.start())
+            else if (attributes.start() >= spans.start())
                 hasMoreSpans = spans.next();
             else
                 hasMoreSpans = attributes.next();
@@ -270,15 +303,19 @@
         return false;
     }
 
+
     /**
-     * Advances the <em>not-attributes</em> to be in the same or greater
+     * Advances the <em>not-attributes</em> to be in the same or
+     * greater
      * document number than referentSpans' document number. If a
-     * <em>not-attribute</em> is in the same document, it is advanced to be in
-     * the same as or greater start position than the current referentSpan.
+     * <em>not-attribute</em> is in the same document, it is advanced
+     * to be in
+     * the same as or greater start position than the current
+     * referentSpan.
      * 
      * @throws IOException
      */
-	private void advanceNotAttributes(Spans referentSpans) throws IOException {
+    private void advanceNotAttributes (Spans referentSpans) throws IOException {
 
         for (AttributeSpans a : notAttributeList) {
             // advance the doc# of not AttributeSpans
@@ -295,19 +332,23 @@
         }
     }
 
+
     /**
-     * Ensures that the referent id of each attributeSpans in the attributeList
+     * Ensures that the referent id of each attributeSpans in the
+     * attributeList
      * is the same as the spanId of the actual referentSpans.
      * 
-     * @return <code>true</code> if the spanId of the current referentSpans is
-     *         the same as all the referentId of all the attributeSpans in the
+     * @return <code>true</code> if the spanId of the current
+     *         referentSpans is
+     *         the same as all the referentId of all the
+     *         attributeSpans in the
      *         attributeList, <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean checkReferentId() throws IOException {
+    private boolean checkReferentId () throws IOException {
         for (AttributeSpans attribute : attributeList) {
-			if (referentSpans.getSpanId() != attribute.getSpanId()) {
-				if (referentSpans.getSpanId() < attribute.getSpanId())
+            if (referentSpans.getSpanId() != attribute.getSpanId()) {
+                if (referentSpans.getSpanId() < attribute.getSpanId())
                     hasMoreSpans = attribute.next();
                 else {
                     hasMoreSpans = referentSpans.next();
@@ -319,22 +360,25 @@
         return true;
     }
 
+
     /**
      * Ensures that the referentSpans do <em>not</em> contain the
-     * <em>not attributes</em> (with negation). In other words, the spanId must
+     * <em>not attributes</em> (with negation). In other words, the
+     * spanId must
      * not the same as the <em>not attribute</em>'s referentId.
      * 
-     * @return <code>true</code> if the referentSpan does not have the same
+     * @return <code>true</code> if the referentSpan does not have the
+     *         same
      *         spanId as the referentIds of all the not attributes,
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-	private boolean checkNotReferentId(SpansWithId referentSpans) throws IOException {
+    private boolean checkNotReferentId (SpansWithId referentSpans)
+            throws IOException {
         for (AttributeSpans notAttribute : notAttributeList) {
             if (!notAttribute.isFinish()
                     && referentSpans.start() == notAttribute.start()
-                    && referentSpans.getSpanId() == notAttribute
-                            .getSpanId()) {
+                    && referentSpans.getSpanId() == notAttribute.getSpanId()) {
                 hasMoreSpans = referentSpans.next();
                 return false;
             }
@@ -342,8 +386,9 @@
         return true;
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (referentSpans.doc() < target)) {
             if (!referentSpans.skipTo(target)) {
                 return false;
@@ -353,8 +398,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
 
         long cost = 0;
         for (AttributeSpans as : attributeList) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
index 77c975e..9b54565 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SpansWithId.java
@@ -11,7 +11,8 @@
 import de.ids_mannheim.korap.query.SpanWithIdQuery;
 
 /**
- * Base class for enumeration of span requiring an id, such as elements and
+ * Base class for enumeration of span requiring an id, such as
+ * elements and
  * relations.
  * 
  * @author margaretha
@@ -21,38 +22,44 @@
     protected short spanId;
     protected boolean hasSpanId = false; // A dummy flag
 
+
     /**
      * Constructs SpansWithId for the given {@link SpanWithIdQuery}.
      * 
-     * @param spanWithIdQuery a SpanWithIdQuery
+     * @param spanWithIdQuery
+     *            a SpanWithIdQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public SpansWithId(SpanWithIdQuery spanWithIdQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public SpansWithId (SpanWithIdQuery spanWithIdQuery,
+                        AtomicReaderContext context, Bits acceptDocs,
+                        Map<Term, TermContext> termContexts) throws IOException {
         super(spanWithIdQuery, context, acceptDocs, termContexts);
     }
 
-	public SpansWithId() {}
 
-	/**
-	 * Returns the span id of the current span
-	 * 
-	 * @return the span id of the current span
-	 */
-    public short getSpanId() {
+    public SpansWithId () {}
+
+
+    /**
+     * Returns the span id of the current span
+     * 
+     * @return the span id of the current span
+     */
+    public short getSpanId () {
         return spanId;
     }
 
+
     /**
      * Sets the span id of the current span
      * 
-     * @param spanId span id
+     * @param spanId
+     *            span id
      */
-    public void setSpanId(short spanId) {
+    public void setSpanId (short spanId) {
         this.spanId = spanId;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
index c95afcc..6abec55 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/SubSpans.java
@@ -23,6 +23,7 @@
 
     private int startOffset, length;
 
+
     /**
      * Constructs SubSpans for the given {@link SpanSubspanQuery}
      * specifiying the start offset and the length of the subspans.
@@ -35,20 +36,22 @@
      * @throws IOException
      */
     public SubSpans (SpanSubspanQuery subspanQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+                     AtomicReaderContext context, Bits acceptDocs,
+                     Map<Term, TermContext> termContexts) throws IOException {
         super(subspanQuery, context, acceptDocs, termContexts);
         this.startOffset = subspanQuery.getStartOffset();
         this.length = subspanQuery.getLength();
         hasMoreSpans = firstSpans.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         return advance();
     }
 
+
     /**
      * Advances the SubSpans to the next match.
      * 
@@ -56,7 +59,7 @@
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (hasMoreSpans) {
             if (findMatch()) {
                 hasMoreSpans = firstSpans.next();
@@ -67,12 +70,13 @@
         return false;
     }
 
+
     /**
      * Sets the properties of the current match/subspan.
      * 
      * @throws IOException
      */
-    public boolean findMatch() throws IOException {
+    public boolean findMatch () throws IOException {
         if (this.startOffset < 0) {
             matchStartPosition = firstSpans.end() + startOffset;
             if (matchStartPosition < firstSpans.start()) {
@@ -100,8 +104,9 @@
         return true;
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -112,8 +117,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost() + 1;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/TermSpansWithId.java b/src/main/java/de/ids_mannheim/korap/query/spans/TermSpansWithId.java
index b34a3f5..cf12aa0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/TermSpansWithId.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/TermSpansWithId.java
@@ -14,9 +14,12 @@
 import de.ids_mannheim.korap.query.SpanTermWithIdQuery;
 
 /**
- * Enumeration of termSpans having an id. This class just wraps the usual Lucene
- * TermSpans, and adds spanid property. It reads the term-id from a term span
- * payload. The term-id is encoded in a short, starting from (offset) 0 in the
+ * Enumeration of termSpans having an id. This class just wraps the
+ * usual Lucene
+ * TermSpans, and adds spanid property. It reads the term-id from a
+ * term span
+ * payload. The term-id is encoded in a short, starting from (offset)
+ * 0 in the
  * payload.
  * 
  * @author margaretha
@@ -25,37 +28,43 @@
 
     private TermSpans termSpans;
 
+
     /**
      * Creates TermSpansWithId from the given spanTermWithIdQuery.
      * 
-     * @param spanTermWithIdQuery a spanTermWithIdQuery
+     * @param spanTermWithIdQuery
+     *            a spanTermWithIdQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public TermSpansWithId(SpanTermWithIdQuery spanTermWithIdQuery,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public TermSpansWithId (SpanTermWithIdQuery spanTermWithIdQuery,
+                            AtomicReaderContext context, Bits acceptDocs,
+                            Map<Term, TermContext> termContexts)
+            throws IOException {
         super(spanTermWithIdQuery, context, acceptDocs, termContexts);
         termSpans = (TermSpans) firstSpans;
         hasMoreSpans = termSpans.next();
     }
 
+
     @Override
-    public boolean next() throws IOException {
+    public boolean next () throws IOException {
         isStartEnumeration = false;
         return advance();
     }
 
+
     /**
      * Advances to the next match and set it as the current match.
      * 
-     * @return <code>true</code> if a match is found, <code>false</code>
+     * @return <code>true</code> if a match is found,
+     *         <code>false</code>
      *         otherwise.
      * @throws IOException
      */
-    private boolean advance() throws IOException {
+    private boolean advance () throws IOException {
         while (hasMoreSpans) {
             readPayload();
             matchDocNumber = firstSpans.doc();
@@ -67,21 +76,24 @@
         return false;
     }
 
+
     /**
-     * Read the payloads of the current firstspan and set the term id info from
+     * Read the payloads of the current firstspan and set the term id
+     * info from
      * the payloads.
      * 
      * @throws IOException
      */
-    private void readPayload() throws IOException {
+    private void readPayload () throws IOException {
         List<byte[]> payload = (List<byte[]>) firstSpans.getPayload();
         ByteBuffer bb = ByteBuffer.allocate(payload.get(0).length);
         bb.put(payload.get(0));
         setSpanId(bb.getShort(0)); //term id
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (firstSpans.doc() < target)) {
             if (!firstSpans.skipTo(target)) {
                 return false;
@@ -92,8 +104,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return firstSpans.cost(); // plus cost from reading payload
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
index 99a83a4..9044c5e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/TokenDistanceSpans.java
@@ -13,10 +13,14 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Enumeration of token-based distance span matches consisting of two child
- * spans having an actual distance in the range of the minimum and maximum
- * distance parameters specified in the corresponding query. A TokenDistanceSpan
- * starts from the minimum start positions of its child spans and ends at the
+ * Enumeration of token-based distance span matches consisting of two
+ * child
+ * spans having an actual distance in the range of the minimum and
+ * maximum
+ * distance parameters specified in the corresponding query. A
+ * TokenDistanceSpan
+ * starts from the minimum start positions of its child spans and ends
+ * at the
  * maximum end positions of the child spans.
  * 
  * @author margaretha
@@ -26,26 +30,30 @@
     /**
      * Constructs TokenDistanceSpans from the given query.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public TokenDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public TokenDistanceSpans (SpanDistanceQuery query,
+                               AtomicReaderContext context, Bits acceptDocs,
+                               Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
         hasMoreSpans = hasMoreFirstSpans;
     }
 
+
     @Override
-    protected void setCandidateList() throws IOException {
+    protected void setCandidateList () throws IOException {
         if (candidateListDocNum == secondSpans.doc()) {
             copyPossibleCandidates();
             addNewCandidates();
             candidateListIndex = -1;
-        } else {
+        }
+        else {
             candidateList.clear();
             if (hasMoreFirstSpans && ensureSameDoc(firstSpans, secondSpans)) {
                 candidateListDocNum = firstSpans.doc();
@@ -55,13 +63,16 @@
         }
     }
 
+
     /**
-     * Restructures the candidateList to contain only candidate (first) spans
-     * which are still possible to create a match, from the candidate list
+     * Restructures the candidateList to contain only candidate
+     * (first) spans
+     * which are still possible to create a match, from the candidate
+     * list
      * prepared for the previous second spans.
      * 
      * */
-    private void copyPossibleCandidates() {
+    private void copyPossibleCandidates () {
         List<CandidateSpan> temp = new ArrayList<>();
         for (CandidateSpan cs : candidateList) {
             if (cs.getEnd() + maxDistance > secondSpans.start())
@@ -70,10 +81,12 @@
         candidateList = temp;
     }
 
+
     /**
-     * Add new possible firstspan candidates for the current secondspan.
+     * Add new possible firstspan candidates for the current
+     * secondspan.
      * */
-    private void addNewCandidates() throws IOException {
+    private void addNewCandidates () throws IOException {
         while (hasMoreFirstSpans && firstSpans.doc() == candidateListDocNum
                 && firstSpans.start() < secondSpans.end()) {
 
@@ -84,8 +97,9 @@
         }
     }
 
+
     @Override
-    protected boolean findMatch() throws IOException {
+    protected boolean findMatch () throws IOException {
         CandidateSpan candidateSpan = candidateList.get(candidateListIndex);
         if (minDistance == 0
                 &&
@@ -108,14 +122,16 @@
         return false;
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         CandidateSpan candidateSpan = candidateList.get(candidateListIndex);
         return candidateSpan.getCost() + secondSpans.cost();
     }
 
+
     @Override
-    protected boolean isSecondSpanValid() throws IOException {
+    protected boolean isSecondSpanValid () throws IOException {
         return true;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedDistanceSpans.java
index 0d29645..2b93ece 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedDistanceSpans.java
@@ -16,8 +16,10 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Enumeration of span matches, whose two child spans have a specific range of
- * distance (within a minimum and a maximum distance) and can occur in any
+ * Enumeration of span matches, whose two child spans have a specific
+ * range of
+ * distance (within a minimum and a maximum distance) and can occur in
+ * any
  * order.
  * 
  * @author margaretha
@@ -32,19 +34,23 @@
     private int matchListSpanNum;
     protected int currentDocNum;
 
+
     /**
-     * Constructs UnorderedDistanceSpans for the given {@link SpanDistanceQuery}
-     * .
+     * Constructs UnorderedDistanceSpans for the given
+     * {@link SpanDistanceQuery} .
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public UnorderedDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public UnorderedDistanceSpans (SpanDistanceQuery query,
+                                   AtomicReaderContext context,
+                                   Bits acceptDocs,
+                                   Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
         minDistance = query.getMinDistance();
         maxDistance = query.getMaxDistance();
@@ -58,8 +64,9 @@
         hasMoreSpans = hasMoreFirstSpans && hasMoreSecondSpans;
     }
 
+
     @Override
-    protected boolean advance() throws IOException {
+    protected boolean advance () throws IOException {
         while (hasMoreSpans || !matchList.isEmpty()) {
             if (!matchList.isEmpty()) {
                 setMatchProperties();
@@ -71,28 +78,38 @@
         return false;
     }
 
+
     /**
-     * Updates the firstSpanList and secondSpanList by adding the next possible
-     * first and second spans. Both the spans must be in the same document. In
-     * UnorderedElementDistanceSpans, a span that is not in an element (distance
-     * unit), is not added to its candidate list. The element must also be in
+     * Updates the firstSpanList and secondSpanList by adding the next
+     * possible
+     * first and second spans. Both the spans must be in the same
+     * document. In
+     * UnorderedElementDistanceSpans, a span that is not in an element
+     * (distance
+     * unit), is not added to its candidate list. The element must
+     * also be in
      * the same document.
      * 
-     * @return <code>true</code> if at least one of the candidate lists can be
+     * @return <code>true</code> if at least one of the candidate
+     *         lists can be
      *         filled, <code>false</code> otherwise.
      * @throws IOException
      */
-    protected abstract boolean prepareLists() throws IOException;
+    protected abstract boolean prepareLists () throws IOException;
+
 
     /**
-     * Sets the list of matches for the span having the smallest position (i.e.
-     * between the first and the second spans), and its candidates (i.e. its
-     * counterparts). The candidates also must have smaller positions. Simply
+     * Sets the list of matches for the span having the smallest
+     * position (i.e.
+     * between the first and the second spans), and its candidates
+     * (i.e. its
+     * counterparts). The candidates also must have smaller positions.
+     * Simply
      * remove the span if it does not have any candidates.
      * 
      * @throws IOException
      */
-    protected void setMatchList() throws IOException {
+    protected void setMatchList () throws IOException {
 
         hasMoreFirstSpans = setCandidateList(firstSpanList, firstSpans,
                 hasMoreFirstSpans, secondSpanList);
@@ -130,7 +147,8 @@
                 setMatchFirstSpan(currentFirstSpan);
                 matchListSpanNum = 2;
                 updateList(firstSpanList);
-            } else {
+            }
+            else {
                 // log.trace("current target: "
                 // + secondSpanList.get(0).getStart() + " "
                 // + secondSpanList.get(0).getEnd());
@@ -144,12 +162,14 @@
                 matchListSpanNum = 1;
                 updateList(secondSpanList);
             }
-        } else if (firstSpanList.isEmpty()) {
+        }
+        else if (firstSpanList.isEmpty()) {
             // log.trace("current target: " + secondSpanList.get(0).getStart()
             // + " " + secondSpanList.get(0).getEnd());
             // log.trace("candidates: empty");
             updateList(secondSpanList);
-        } else {
+        }
+        else {
             // log.trace("current target: " + firstSpanList.get(0).getStart()
             // + " " + firstSpanList.get(0).getEnd());
             // log.trace("candidates: empty");
@@ -157,18 +177,25 @@
         }
     }
 
+
     /**
-     * Tells if the last candidate from the secondSpanList has a smaller end
-     * position than the end position of the the last candidate from the
+     * Tells if the last candidate from the secondSpanList has a
+     * smaller end
+     * position than the end position of the the last candidate from
+     * the
      * firstSpanList.
      * 
-     * @param currentFirstSpan the current firstspan
-     * @param currentSecondSpan the current secondspan
-     * @return <code>true</code> if the end position of the last candidate from
-     *         the secondSpanList is smaller than that from the firstSpanList,
+     * @param currentFirstSpan
+     *            the current firstspan
+     * @param currentSecondSpan
+     *            the current secondspan
+     * @return <code>true</code> if the end position of the last
+     *         candidate from
+     *         the secondSpanList is smaller than that from the
+     *         firstSpanList,
      *         <code>false</code> otherwise.
      */
-    private boolean isLastCandidateSmaller(CandidateSpan currentFirstSpan,
+    private boolean isLastCandidateSmaller (CandidateSpan currentFirstSpan,
             CandidateSpan currentSecondSpan) {
         if (currentFirstSpan.getEnd() == currentSecondSpan.getEnd()) {
             int secondEnd = secondSpanList.get(secondSpanList.size() - 1)
@@ -180,51 +207,68 @@
         return false;
     }
 
+
     /**
      * Performs an update based on the given candidateList. In
      * {@link UnorderedTokenDistanceSpans}, the first candidate in the
-     * candidateList is simply removed. In {@link UnorderedElementDistanceSpans}
-     * , the elementList is also updated.
+     * candidateList is simply removed. In
+     * {@link UnorderedElementDistanceSpans} , the elementList is also
+     * updated.
      * 
-     * @param candidateList a candidateList
+     * @param candidateList
+     *            a candidateList
      */
-    protected abstract void updateList(List<CandidateSpan> candidateList);
+    protected abstract void updateList (List<CandidateSpan> candidateList);
+
 
     /**
-     * Sets the candidate list for the first element in the target list and
+     * Sets the candidate list for the first element in the target
+     * list and
      * tells if the the specified spans has finished or not.
      * 
-     * @param candidateList a list of candidate spans
-     * @param candidate a Spans
-     * @param hasMoreCandidates a boolean
-     * @param targetList a list of target spans
-     * @return <code>true</code> if the span enumeration still has a next
-     *         element to be a candidate, <code>false</code> otherwise.
+     * @param candidateList
+     *            a list of candidate spans
+     * @param candidate
+     *            a Spans
+     * @param hasMoreCandidates
+     *            a boolean
+     * @param targetList
+     *            a list of target spans
+     * @return <code>true</code> if the span enumeration still has a
+     *         next
+     *         element to be a candidate, <code>false</code>
+     *         otherwise.
      * @throws IOException
      */
-    protected abstract boolean setCandidateList(
+    protected abstract boolean setCandidateList (
             List<CandidateSpan> candidateList, Spans candidate,
             boolean hasMoreCandidates, List<CandidateSpan> targetList)
             throws IOException;
 
-    /**
-     * Finds all matches between the target span and its candidates in the
-     * candidate list.
-     * 
-     * @param target a target span
-     * @param candidateList a candidate list
-     * @return the matches in a list
-     */
-    protected abstract List<CandidateSpan> findMatches(CandidateSpan target,
-            List<CandidateSpan> candidateList);
 
     /**
-     * Computes match properties and creates a candidate span match to be added
+     * Finds all matches between the target span and its candidates in
+     * the
+     * candidate list.
+     * 
+     * @param target
+     *            a target span
+     * @param candidateList
+     *            a candidate list
+     * @return the matches in a list
+     */
+    protected abstract List<CandidateSpan> findMatches (CandidateSpan target,
+            List<CandidateSpan> candidateList);
+
+
+    /**
+     * Computes match properties and creates a candidate span match to
+     * be added
      * to the match list.
      * 
      * @return a candidate span match
      * */
-    protected CandidateSpan createMatchCandidate(CandidateSpan target,
+    protected CandidateSpan createMatchCandidate (CandidateSpan target,
             CandidateSpan cs, boolean isDistanceZero) {
 
         int start = Math.min(target.getStart(), cs.getStart());
@@ -247,11 +291,13 @@
         return match;
     }
 
+
     /**
-     * Assigns the first candidate span in the match list as the current span
+     * Assigns the first candidate span in the match list as the
+     * current span
      * match, and removes it from the matchList.
      * */
-    private void setMatchProperties() {
+    private void setMatchProperties () {
         CandidateSpan cs = matchList.get(0);
         matchDocNumber = cs.getDoc();
         matchStartPosition = cs.getStart();
@@ -273,8 +319,9 @@
         // + getMatchSecondSpan().getEnd());
     }
 
+
     @Override
-    public boolean skipTo(int target) throws IOException {
+    public boolean skipTo (int target) throws IOException {
         if (hasMoreSpans && (secondSpans.doc() < target)) {
             if (!secondSpans.skipTo(target)) {
                 hasMoreSpans = false;
@@ -289,8 +336,9 @@
         return advance();
     }
 
+
     @Override
-    public long cost() {
+    public long cost () {
         return matchCost;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedElementDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedElementDistanceSpans.java
index f0df28e..8489970 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedElementDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedElementDistanceSpans.java
@@ -15,10 +15,14 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Enumeration of span matches, whose two child spans have a specific range of
- * distance (within a min and a max distance) and can be in any order. The unit
- * distance is an element, which can be a sentence or a paragraph for instance.
- * The distance is the difference between the positions of elements containing
+ * Enumeration of span matches, whose two child spans have a specific
+ * range of
+ * distance (within a min and a max distance) and can be in any order.
+ * The unit
+ * distance is an element, which can be a sentence or a paragraph for
+ * instance.
+ * The distance is the difference between the positions of elements
+ * containing
  * the spans.
  * 
  * @author margaretha
@@ -33,19 +37,23 @@
     // target span
     private List<CandidateSpan> elementList;
 
+
     /**
      * Constructs UnorderedElementDistanceSpans for the given
      * {@link SpanDistanceQuery}.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public UnorderedElementDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public UnorderedElementDistanceSpans (SpanDistanceQuery query,
+                                          AtomicReaderContext context,
+                                          Bits acceptDocs,
+                                          Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
         elements = query.getElementQuery().getSpans(context, acceptDocs,
                 termContexts);
@@ -54,8 +62,9 @@
         elementList = new ArrayList<CandidateSpan>();
     }
 
+
     @Override
-    protected boolean prepareLists() throws IOException {
+    protected boolean prepareLists () throws IOException {
 
         if (firstSpanList.isEmpty() && secondSpanList.isEmpty()) {
             if (hasMoreFirstSpans && hasMoreSecondSpans && hasMoreElements
@@ -70,15 +79,18 @@
                         hasMoreFirstSpans);
                 hasMoreSecondSpans = addSpan(secondSpans, secondSpanList,
                         hasMoreSecondSpans);
-            } else {
+            }
+            else {
                 hasMoreSpans = false;
                 return false;
             }
-        } else if (firstSpanList.isEmpty() && hasMoreFirstSpans
+        }
+        else if (firstSpanList.isEmpty() && hasMoreFirstSpans
                 && firstSpans.doc() == currentDocNum) {
             hasMoreFirstSpans = addSpan(firstSpans, firstSpanList,
                     hasMoreFirstSpans);
-        } else if (secondSpanList.isEmpty() && hasMoreSecondSpans
+        }
+        else if (secondSpanList.isEmpty() && hasMoreSecondSpans
                 && secondSpans.doc() == currentDocNum) {
             hasMoreSecondSpans = addSpan(secondSpans, secondSpanList,
                     hasMoreSecondSpans);
@@ -87,20 +99,27 @@
         return true;
     }
 
+
     /**
-     * Adds all the spans occurring in the current document, as CandidateSpans
-     * to the specified candidate list, and tells if the enumeration of the
+     * Adds all the spans occurring in the current document, as
+     * CandidateSpans
+     * to the specified candidate list, and tells if the enumeration
+     * of the
      * spans has finished, or not.
      * 
-     * @param span a Span
-     * @param list a candidateList
-     * @param hasMoreSpan a boolean describing if the span enumeration has
-     *        finished or not.
-     * @return <code>true</code> if the the span enumeration has finished,
+     * @param span
+     *            a Span
+     * @param list
+     *            a candidateList
+     * @param hasMoreSpan
+     *            a boolean describing if the span enumeration has
+     *            finished or not.
+     * @return <code>true</code> if the the span enumeration has
+     *         finished,
      *         <code>false</code> otherwise.
      * @throws IOException
      */
-    private boolean addSpan(Spans span, List<CandidateSpan> list,
+    private boolean addSpan (Spans span, List<CandidateSpan> list,
             boolean hasMoreSpan) throws IOException {
         int position;
         while (hasMoreSpan && span.doc() == currentDocNum) {
@@ -115,15 +134,18 @@
         return hasMoreSpan;
     }
 
+
     /**
-     * Finds the element position of the specified span in the element list or
+     * Finds the element position of the specified span in the element
+     * list or
      * by advancing the element spans until encountering the span.
      * 
-     * @param span a Span
+     * @param span
+     *            a Span
      * @return the element position
      * @throws IOException
      */
-    private int findElementPosition(Spans span) throws IOException {
+    private int findElementPosition (Spans span) throws IOException {
         // Check in the element list
         if (!elementList.isEmpty()
                 && span.end() <= elementList.get(elementList.size() - 1)
@@ -139,15 +161,17 @@
         return (advanceElementTo(span) ? elementPosition : -1);
     }
 
+
     /**
      * Advances the element spans until encountering the given span.
      * 
      * @param span
-     * @return <code>true</code> if such an element is found, <code>false</code>
+     * @return <code>true</code> if such an element is found,
+     *         <code>false</code>
      *         if the span is not in an element.
      * @throws IOException
      */
-    private boolean advanceElementTo(Spans span) throws IOException {
+    private boolean advanceElementTo (Spans span) throws IOException {
         while (hasMoreElements && elements.doc() == currentDocNum
                 && elements.start() < span.end()) {
 
@@ -163,8 +187,9 @@
         return false; // invalid
     }
 
+
     @Override
-    protected boolean setCandidateList(List<CandidateSpan> candidateList,
+    protected boolean setCandidateList (List<CandidateSpan> candidateList,
             Spans candidate, boolean hasMoreCandidates,
             List<CandidateSpan> targetList) throws IOException {
 
@@ -179,7 +204,8 @@
 
                     if (isWithinMaxDistance(target, cs)) {
                         candidateList.add(cs);
-                    } else
+                    }
+                    else
                         break;
                 }
                 hasMoreCandidates = candidate.next();
@@ -188,14 +214,17 @@
         return hasMoreCandidates;
     }
 
+
     /**
-     * Tells if the target and candidate spans are not too far from each other
+     * Tells if the target and candidate spans are not too far from
+     * each other
      * (within the maximum distance).
      * 
-     * @return <code>true</code> if the target and candidate spans are within
+     * @return <code>true</code> if the target and candidate spans are
+     *         within
      *         the maximum distance, <code>false</code> otherwise.
      * */
-    protected boolean isWithinMaxDistance(CandidateSpan target,
+    protected boolean isWithinMaxDistance (CandidateSpan target,
             CandidateSpan candidate) {
         int candidatePos = candidate.getPosition();
         int targetPos = target.getPosition();
@@ -211,8 +240,9 @@
         return true;
     }
 
+
     @Override
-    protected List<CandidateSpan> findMatches(CandidateSpan target,
+    protected List<CandidateSpan> findMatches (CandidateSpan target,
             List<CandidateSpan> candidateList) {
 
         List<CandidateSpan> matches = new ArrayList<>();
@@ -234,20 +264,25 @@
         return matches;
     }
 
+
     @Override
-    protected void updateList(List<CandidateSpan> candidateList) {
+    protected void updateList (List<CandidateSpan> candidateList) {
         updateElementList(candidateList.get(0).getPosition());
         candidateList.remove(0);
     }
 
+
     /**
-     * Reduces the number of elements kept in the element list by removing the
-     * elements whose position is smaller than or identical to the position of
+     * Reduces the number of elements kept in the element list by
+     * removing the
+     * elements whose position is smaller than or identical to the
+     * position of
      * the last target span.
      * 
-     * @param position the last target span position
+     * @param position
+     *            the last target span position
      */
-    private void updateElementList(int position) {
+    private void updateElementList (int position) {
         Iterator<CandidateSpan> i = elementList.iterator();
         CandidateSpan e;
         while (i.hasNext()) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedTokenDistanceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedTokenDistanceSpans.java
index c5061d3..3e50e76 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedTokenDistanceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/UnorderedTokenDistanceSpans.java
@@ -14,8 +14,10 @@
 import de.ids_mannheim.korap.query.SpanDistanceQuery;
 
 /**
- * Enumeration of span matches, whose two child spans have a specific range of
- * distance (within a min and a max distance) and can be in any order. The unit
+ * Enumeration of span matches, whose two child spans have a specific
+ * range of
+ * distance (within a min and a max distance) and can be in any order.
+ * The unit
  * distance is a token position.
  * 
  * @author margaretha
@@ -23,22 +25,27 @@
 public class UnorderedTokenDistanceSpans extends UnorderedDistanceSpans {
 
     /**
-     * Constructs UnorderedTokenDistanceSpans for the given SpanDistanceQuery.
+     * Constructs UnorderedTokenDistanceSpans for the given
+     * SpanDistanceQuery.
      * 
-     * @param query a SpanDistanceQuery
+     * @param query
+     *            a SpanDistanceQuery
      * @param context
      * @param acceptDocs
      * @param termContexts
      * @throws IOException
      */
-    public UnorderedTokenDistanceSpans(SpanDistanceQuery query,
-            AtomicReaderContext context, Bits acceptDocs,
-            Map<Term, TermContext> termContexts) throws IOException {
+    public UnorderedTokenDistanceSpans (SpanDistanceQuery query,
+                                        AtomicReaderContext context,
+                                        Bits acceptDocs,
+                                        Map<Term, TermContext> termContexts)
+            throws IOException {
         super(query, context, acceptDocs, termContexts);
     }
 
+
     @Override
-    protected boolean prepareLists() throws IOException {
+    protected boolean prepareLists () throws IOException {
 
         if (firstSpanList.isEmpty() && secondSpanList.isEmpty()) {
             if (hasMoreFirstSpans && hasMoreSecondSpans
@@ -48,15 +55,18 @@
                 currentDocNum = firstSpans.doc();
                 hasMoreFirstSpans = firstSpans.next();
                 hasMoreSecondSpans = secondSpans.next();
-            } else {
+            }
+            else {
                 hasMoreSpans = false;
                 return false;
             }
-        } else if (firstSpanList.isEmpty() && hasMoreFirstSpans
+        }
+        else if (firstSpanList.isEmpty() && hasMoreFirstSpans
                 && firstSpans.doc() == currentDocNum) {
             firstSpanList.add(new CandidateSpan(firstSpans));
             hasMoreFirstSpans = firstSpans.next();
-        } else if (secondSpanList.isEmpty() && hasMoreSecondSpans
+        }
+        else if (secondSpanList.isEmpty() && hasMoreSecondSpans
                 && secondSpans.doc() == currentDocNum) {
             secondSpanList.add(new CandidateSpan(secondSpans));
             hasMoreSecondSpans = secondSpans.next();
@@ -64,8 +74,9 @@
         return true;
     }
 
+
     @Override
-    protected boolean setCandidateList(List<CandidateSpan> candidateList,
+    protected boolean setCandidateList (List<CandidateSpan> candidateList,
             Spans candidate, boolean hasMoreCandidates,
             List<CandidateSpan> targetList) throws IOException {
 
@@ -80,16 +91,21 @@
         return hasMoreCandidates;
     }
 
+
     /**
-     * Tells if the target and candidate spans are not too far from each other
+     * Tells if the target and candidate spans are not too far from
+     * each other
      * (within the maximum distance).
      * 
-     * @param target a target span
-     * @param candidate a candidate span
-     * @return <code>true</code> if the target and candidate spans are within
+     * @param target
+     *            a target span
+     * @param candidate
+     *            a candidate span
+     * @return <code>true</code> if the target and candidate spans are
+     *         within
      *         the maximum distance, <code>false</code> otherwise.
      */
-    protected boolean isWithinMaxDistance(CandidateSpan target, Spans candidate) {
+    protected boolean isWithinMaxDistance (CandidateSpan target, Spans candidate) {
         // left candidate
         if (candidate.end() < target.getStart()
                 && candidate.end() + maxDistance <= target.getStart()) {
@@ -103,8 +119,9 @@
         return true;
     }
 
+
     @Override
-    protected List<CandidateSpan> findMatches(CandidateSpan target,
+    protected List<CandidateSpan> findMatches (CandidateSpan target,
             List<CandidateSpan> candidateList) {
 
         List<CandidateSpan> matches = new ArrayList<>();
@@ -132,8 +149,9 @@
         return matches;
     }
 
+
     @Override
-    protected void updateList(List<CandidateSpan> candidateList) {
+    protected void updateList (List<CandidateSpan> candidateList) {
         candidateList.remove(0);
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/WithinSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/WithinSpans.java
index 5240580..4358f45 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/WithinSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/WithinSpans.java
@@ -28,7 +28,7 @@
 
 /**
  * Compare two spans and check how they relate positionally.
- *
+ * 
  * @author diewald
  */
 public class WithinSpans extends Spans {
@@ -38,7 +38,7 @@
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
-    
+
     private boolean more = false;
 
     // Boolean value indicating if span B
@@ -46,20 +46,13 @@
     // or span A (false);
     boolean nextSpanB = true;
 
-    private int
-        wrapStart     = -1,
-        wrapEnd       = -1,
-        embeddedStart = -1,
-        embeddedEnd   = -1,
-        wrapDoc       = -1,
-        embeddedDoc   = -1,
-        matchDoc      = -1,
-        matchStart    = -1,
-        matchEnd      = -1;
-    
+    private int wrapStart = -1, wrapEnd = -1, embeddedStart = -1,
+            embeddedEnd = -1, wrapDoc = -1, embeddedDoc = -1, matchDoc = -1,
+            matchStart = -1, matchEnd = -1;
+
     private Collection<byte[]> matchPayload;
     private Collection<byte[]> embeddedPayload;
-    
+
     // Indicates that the wrap and the embedded spans are in the same doc
     private boolean inSameDoc = false;
 
@@ -78,14 +71,9 @@
                                  A.end = B.end
       m   -> 12 |                A = B
     */
-    public static final byte
-        OVERLAP      = (byte) 0,
-        REAL_OVERLAP = (byte) 2,
-        WITHIN       = (byte) 4,
-        REAL_WITHIN  = (byte) 6,
-        ENDSWITH     = (byte) 8,
-        STARTSWITH   = (byte) 10,
-        MATCH        = (byte) 12;
+    public static final byte OVERLAP = (byte) 0, REAL_OVERLAP = (byte) 2,
+            WITHIN = (byte) 4, REAL_WITHIN = (byte) 6, ENDSWITH = (byte) 8,
+            STARTSWITH = (byte) 10, MATCH = (byte) 12;
 
     private byte flag;
 
@@ -103,25 +91,29 @@
     private boolean tryMatch = true;
 
     // Two buffers for storing candidates
-    private LinkedList<WithinSpan>
-        spanStore1,
-        spanStore2;
+    private LinkedList<WithinSpan> spanStore1, spanStore2;
+
 
     /**
      * Construct a new WithinSpans object.
-     *
-     * @param spanWithinQuery The parental {@link SpanWithinQuery}.
-     * @param context The {@link AtomicReaderContext}.
-     * @param acceptDocs Bit vector representing the documents
-     *        to be searched in.
-     * @param termContexts A map managing {@link TermState TermStates}.
-     * @param flag A byte flag indicating the positional condition of the sub spans.
+     * 
+     * @param spanWithinQuery
+     *            The parental {@link SpanWithinQuery}.
+     * @param context
+     *            The {@link AtomicReaderContext}.
+     * @param acceptDocs
+     *            Bit vector representing the documents
+     *            to be searched in.
+     * @param termContexts
+     *            A map managing {@link TermState TermStates}.
+     * @param flag
+     *            A byte flag indicating the positional condition of
+     *            the sub spans.
      */
     public WithinSpans (SpanWithinQuery spanWithinQuery,
-                        AtomicReaderContext context,
-                        Bits acceptDocs,
-                        Map<Term,TermContext> termContexts,
-                        byte flag) throws IOException {
+                        AtomicReaderContext context, Bits acceptDocs,
+                        Map<Term, TermContext> termContexts, byte flag)
+            throws IOException {
 
         if (DEBUG)
             log.trace("Construct WithinSpans");
@@ -130,16 +122,10 @@
         this.matchPayload = new LinkedList<byte[]>();
 
         // Get spans
-        this.wrapSpans = spanWithinQuery.wrap().getSpans(
-            context,
-            acceptDocs,
-            termContexts
-        );
-        this.embeddedSpans = spanWithinQuery.embedded().getSpans(
-            context,
-            acceptDocs,
-            termContexts
-        );
+        this.wrapSpans = spanWithinQuery.wrap().getSpans(context, acceptDocs,
+                termContexts);
+        this.embeddedSpans = spanWithinQuery.embedded().getSpans(context,
+                acceptDocs, termContexts);
 
         this.flag = flag;
 
@@ -150,7 +136,7 @@
         // kept for toString() only.
         this.query = spanWithinQuery;
     };
-    
+
 
     // Move to next match, returning true iff any such exists.
     @Override
@@ -161,32 +147,34 @@
 
         // Initialize spans
         if (!this.init()) {
-            this.more        = false;
-            this.inSameDoc   = false;
-            this.wrapDoc     = DocIdSetIterator.NO_MORE_DOCS;
+            this.more = false;
+            this.inSameDoc = false;
+            this.wrapDoc = DocIdSetIterator.NO_MORE_DOCS;
             this.embeddedDoc = DocIdSetIterator.NO_MORE_DOCS;
-            this.matchDoc    = DocIdSetIterator.NO_MORE_DOCS;
+            this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
             return false;
         };
 
         // There are more spans and they are in the same document
 
         while (this.more && (wrapDoc == embeddedDoc ||
-                             // this.inSameDoc ||
-                             this.toSameDoc())) {
+        // this.inSameDoc ||
+                this.toSameDoc())) {
             if (DEBUG)
-                log.trace("We are in the same doc: {}, {}", wrapDoc, embeddedDoc);
+                log.trace("We are in the same doc: {}, {}", wrapDoc,
+                        embeddedDoc);
 
             // Both spans match according to the flag
             // Silently the next operations are prepared
             if (this.tryMatch && this.doesMatch()) {
-                
+
                 if (this.wrapEnd == -1)
                     this.wrapEnd = this.wrapSpans.end();
-		
-                this.matchStart = embeddedStart < wrapStart ? embeddedStart : wrapStart;
-                this.matchEnd   = embeddedEnd   > wrapEnd   ? embeddedEnd   : wrapEnd;
-                this.matchDoc   = embeddedDoc;
+
+                this.matchStart = embeddedStart < wrapStart ? embeddedStart
+                        : wrapStart;
+                this.matchEnd = embeddedEnd > wrapEnd ? embeddedEnd : wrapEnd;
+                this.matchDoc = embeddedDoc;
                 this.matchPayload.clear();
 
                 if (this.embeddedPayload != null)
@@ -196,12 +184,8 @@
                     this.matchPayload.addAll(wrapSpans.getPayload());
 
                 if (DEBUG)
-                    log.trace(
-                              "   ---- MATCH ---- {}-{} ({})",
-                              matchStart,
-                              matchEnd,
-                              matchDoc
-                              );
+                    log.trace("   ---- MATCH ---- {}-{} ({})", matchStart,
+                            matchEnd, matchDoc);
 
                 this.tryMatch = false;
                 return true;
@@ -212,10 +196,10 @@
 
                 // Next time try the match
                 this.tryMatch = true;
-		
+
                 if (DEBUG)
                     log.trace("In the next embedded branch");
-		
+
                 WithinSpan current = null;
 
                 // New - fetch until theres a span in the correct doc or bigger
@@ -230,7 +214,7 @@
                 if (current == null) {
                     if (DEBUG)
                         log.trace("SpanStore 2 is empty");
-                    
+
                     // Forward with embedding
                     if (!this.embeddedSpans.next()) {
                         this.nextSpanA();
@@ -240,20 +224,20 @@
                     else if (DEBUG) {
                         log.trace("Fetch next embedded span");
                     };
-		    
+
                     this.embeddedStart = this.embeddedSpans.start();
                     this.embeddedEnd = -1;
                     this.embeddedPayload = null;
                     this.embeddedDoc = this.embeddedSpans.doc();
 
                     if (this.embeddedDoc != this.wrapDoc) {
-                        
+
                         if (DEBUG) {
                             log.trace("Embedded span is in a new document {}",
-                                      _currentEmbedded().toString());
+                                    _currentEmbedded().toString());
                             log.trace("Reset current embedded doc");
-                        };	
-	
+                        };
+
                         /*
                         if (DEBUG)
                             log.trace("Clear all span stores");
@@ -271,15 +255,13 @@
                         this.nextSpanA();
                         continue;
                     };
-		    
+
                     if (DEBUG)
-                        log.trace(
-                            "   Forward embedded span to {}",
-                            _currentEmbedded().toString()
-                        );
-                    
+                        log.trace("   Forward embedded span to {}",
+                                _currentEmbedded().toString());
+
                     if (this.embeddedDoc != this.wrapDoc) {
-                     
+
                         // Is this always a good idea?
                         /*
                         this.spanStore1.clear();
@@ -289,7 +271,7 @@
                         this.embeddedStart = -1;
                         this.embeddedEnd = -1;
                         this.embeddedPayload = null;
-			
+
                         if (!this.toSameDoc()) {
                             this.more = false;
                             this.inSameDoc = false;
@@ -304,7 +286,7 @@
                     this.nextSpanB();
                     continue;
                 }
-		
+
                 // Fetch from second store?
                 else {
                     /** TODO: Change this to a single embedded object! */
@@ -313,7 +295,8 @@
                     this.embeddedDoc = current.doc;
 
                     if (current.payload != null) {
-                        this.embeddedPayload = new ArrayList<byte[]>(current.payload.size());
+                        this.embeddedPayload = new ArrayList<byte[]>(
+                                current.payload.size());
                         this.embeddedPayload.addAll(current.payload);
                     }
                     else {
@@ -321,8 +304,9 @@
                     };
 
                     if (DEBUG)
-                        log.trace("Fetch current from SpanStore 2: {}", current.toString());
-		    
+                        log.trace("Fetch current from SpanStore 2: {}",
+                                current.toString());
+
                     this.tryMatch = true;
                 };
                 continue;
@@ -347,10 +331,8 @@
                 };
 
                 // Move everything to spanStore2
-                this.spanStore2.addAll(
-                    0,
-                    (LinkedList<WithinSpan>) this.spanStore1.clone()
-                );
+                this.spanStore2.addAll(0,
+                        (LinkedList<WithinSpan>) this.spanStore1.clone());
                 this.spanStore1.clear();
 
                 if (DEBUG) {
@@ -359,7 +341,7 @@
                         log.trace("     | {}", i.toString());
                     };
                 };
-                
+
             }
             else if (DEBUG) {
                 log.trace("spanStore 1 is empty");
@@ -371,15 +353,13 @@
                 // Reset wrapping information
                 this.wrapStart = this.wrapSpans.start();
                 this.wrapEnd = -1;
-		
+
                 // Retrieve doc information
                 this.wrapDoc = this.wrapSpans.doc();
 
                 if (DEBUG)
-                    log.trace(
-                        "   Forward wrap span to {}",
-                        _currentWrap().toString()
-                    );
+                    log.trace("   Forward wrap span to {}", _currentWrap()
+                            .toString());
 
                 if (this.embeddedDoc != this.wrapDoc) {
                     if (DEBUG)
@@ -403,7 +383,7 @@
                     // Do not match with the current state
                     this.tryMatch = false;
                 };
-                
+
                 this.nextSpanB();
                 continue;
             }
@@ -439,7 +419,7 @@
         this.more = true;
         this.inSameDoc = true;
 
-        this.wrapDoc     = this.wrapSpans.doc();
+        this.wrapDoc = this.wrapSpans.doc();
         this.embeddedDoc = this.embeddedSpans.doc();
 
         // Clear all spanStores
@@ -455,13 +435,13 @@
 
         // Last doc was reached
         else if (this.wrapDoc == DocIdSetIterator.NO_MORE_DOCS) {
-            this.more      = false;
-            this.matchDoc  = DocIdSetIterator.NO_MORE_DOCS;
+            this.more = false;
+            this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
             this.inSameDoc = false;
             return false;
         }
         else {
-            if (DEBUG)  {
+            if (DEBUG) {
                 log.trace("Current position already is in the same doc");
                 log.trace("Embedded: {}", _currentEmbedded().toString());
             };
@@ -480,15 +460,15 @@
                 if (!wrapSpans.skipTo(this.embeddedDoc)) {
                     this.more = false;
                     this.inSameDoc = false;
-                    this.matchDoc  = DocIdSetIterator.NO_MORE_DOCS;
+                    this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
                     return false;
                 };
-                
+
                 if (DEBUG)
                     log.trace("Skip wrap to doc {}", this.embeddedDoc);
-		
+
                 this.wrapDoc = this.wrapSpans.doc();
-                
+
                 if (wrapDoc == DocIdSetIterator.NO_MORE_DOCS) {
                     this.more = false;
                     this.inSameDoc = false;
@@ -505,57 +485,57 @@
 
                 this.spanStore1.clear();
                 this.spanStore2.clear();
-		              
+
                 if (wrapDoc == embeddedDoc) {
                     this.wrapStart = this.wrapSpans.start();
                     this.embeddedStart = this.embeddedSpans.start();
                     this.matchDoc = this.embeddedDoc;
                     return true;
                 };
-                
+
                 this.wrapStart = -1;
                 this.embeddedStart = -1;
             }
-	
+
             // Forward embedInfo
             else if (this.wrapDoc > this.embeddedDoc) {
-                
+
                 // Set document information
                 if (!this.embeddedSpans.skipTo(this.wrapDoc)) {
                     this.more = false;
                     this.inSameDoc = false;
-                    this.matchDoc  = DocIdSetIterator.NO_MORE_DOCS;
+                    this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
                     return false;
                 };
-                               
+
                 this.embeddedDoc = this.embeddedSpans.doc();
-                
+
                 if (this.embeddedDoc == DocIdSetIterator.NO_MORE_DOCS) {
-                    this.more      = false;
+                    this.more = false;
                     this.inSameDoc = false;
-                    this.wrapDoc   = DocIdSetIterator.NO_MORE_DOCS;
-                    this.matchDoc  = DocIdSetIterator.NO_MORE_DOCS;
+                    this.wrapDoc = DocIdSetIterator.NO_MORE_DOCS;
+                    this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
                     return false;
                 };
 
                 if (DEBUG)
                     log.trace("Skip embedded to doc {}", this.embeddedDoc);
-                
+
                 this.embeddedStart = this.embeddedSpans.start();
                 this.embeddedEnd = -1;
                 this.embeddedPayload = null;
-                
+
                 if (this.wrapDoc == this.embeddedDoc) {
                     this.matchDoc = this.embeddedDoc;
                     return true;
                 };
             }
             else {
-                this.matchDoc  = DocIdSetIterator.NO_MORE_DOCS;
+                this.matchDoc = DocIdSetIterator.NO_MORE_DOCS;
                 return false;
             };
         };
-        
+
         this.matchDoc = this.wrapDoc;
         return true;
     };
@@ -576,7 +556,7 @@
 
             if (DEBUG)
                 log.trace("No spans initialized");
-	    
+
             this.embeddedDoc = -1;
             this.more = false;
             return false;
@@ -584,39 +564,38 @@
         this.more = true;
 
         // Store current positions for wrapping and embedded spans
-        this.wrapDoc     = this.wrapSpans.doc();
+        this.wrapDoc = this.wrapSpans.doc();
         this.embeddedDoc = this.embeddedSpans.doc();
 
         // Set inSameDoc to true, if it is true
         if (this.embeddedDoc == this.wrapDoc)
             this.inSameDoc = true;
-	
+
         return true;
     };
 
 
-    /** Skips to the first match beyond the current, whose document number is
-     * greater than or equal to <i>target</i>. <p>Returns true iff there is such
-     * a match.  <p>Behaves as if written: <pre class="prettyprint">
-     *   boolean skipTo(int target) {
-     *     do {
-     *       if (!next())
-     *         return false;
-     *     } while (target > doc());
-     *     return true;
-     *   }
+    /**
+     * Skips to the first match beyond the current, whose document
+     * number is
+     * greater than or equal to <i>target</i>. <p>Returns true iff
+     * there is such
+     * a match. <p>Behaves as if written: <pre class="prettyprint">
+     * boolean skipTo(int target) {
+     * do {
+     * if (!next())
+     * return false;
+     * } while (target > doc());
+     * return true;
+     * }
      * </pre>
      * Most implementations are considerably more efficient than that.
      */
     public boolean skipTo (int target) throws IOException {
 
         if (DEBUG)
-            log.trace(
-                "skipTo document {}/{} -> {}",
-                this.embeddedDoc,
-                this.wrapDoc,
-                target
-            );
+            log.trace("skipTo document {}/{} -> {}", this.embeddedDoc,
+                    this.wrapDoc, target);
 
         // Initialize spans
         if (!this.init())
@@ -646,6 +625,7 @@
         return this.toSameDoc();
     };
 
+
     private void nextSpanA () {
         if (DEBUG)
             log.trace("Try wrap next time");
@@ -653,6 +633,7 @@
         this.nextSpanB = false;
     };
 
+
     private void nextSpanB () {
         if (DEBUG)
             log.trace("Try embedded next time");
@@ -668,14 +649,14 @@
 
         if (this.wrapStart == -1)
             this.wrapStart = this.wrapSpans.start();
-	
+
         if (this.embeddedStart == -1) {
             this.embeddedStart = this.embeddedSpans.start();
-            this.embeddedEnd   = this.embeddedSpans.end();
+            this.embeddedEnd = this.embeddedSpans.end();
         };
 
         this.wrapEnd = -1;
-	
+
         // Shortcut to prevent lazyloading of .end()
         if (this.wrapStart > this.embeddedStart) {
             // Can't match for in, rin, ew, sw, and m
@@ -711,44 +692,41 @@
         if (currentCase >= (byte) 3 && currentCase <= (byte) 11) {
             switch (flag) {
 
-            case WITHIN:
-                if (currentCase >= 6  && currentCase <= 10 && currentCase != 8)
-                    match = true;
-                break;
+                case WITHIN:
+                    if (currentCase >= 6 && currentCase <= 10
+                            && currentCase != 8)
+                        match = true;
+                    break;
 
-            case REAL_WITHIN:
-                if (currentCase == 6 ||
-                    currentCase == 9 ||
-                    currentCase == 10)
-                    match = true;
-                break;
-        
-            case MATCH:
-                if (currentCase == 7)
-                    match = true;
-                break;
+                case REAL_WITHIN:
+                    if (currentCase == 6 || currentCase == 9
+                            || currentCase == 10)
+                        match = true;
+                    break;
 
-            case STARTSWITH:
-                if (currentCase == 7 ||
-                    currentCase == 6)
-                    match = true;
-                break;
+                case MATCH:
+                    if (currentCase == 7)
+                        match = true;
+                    break;
 
-            case ENDSWITH:
-                if (currentCase == 7 ||
-                    currentCase == 10)
-                    match = true;
-                break;
+                case STARTSWITH:
+                    if (currentCase == 7 || currentCase == 6)
+                        match = true;
+                    break;
 
-            case OVERLAP:
-                match = true;
-                break;
+                case ENDSWITH:
+                    if (currentCase == 7 || currentCase == 10)
+                        match = true;
+                    break;
 
-            case REAL_OVERLAP:
-                if (currentCase == 3 ||
-                    currentCase == 11)
+                case OVERLAP:
                     match = true;
-                break;
+                    break;
+
+                case REAL_OVERLAP:
+                    if (currentCase == 3 || currentCase == 11)
+                        match = true;
+                    break;
             };
         };
 
@@ -764,173 +742,176 @@
 
     private void _logCurrentCase (byte currentCase) {
         log.trace("Current Case is {}", currentCase);
-	
+
         String _e = _currentEmbedded().toString();
-	    
+
         log.trace("    |---|    {}", _currentWrap().toString());
 
         switch (currentCase) {
-        case 1:
-            log.trace("|-|          {}", _e);
-            break;
-        case 2:
-            log.trace("|---|        {}", _e);
-	    break;
-        case 3:
-            log.trace("  |---|      {}", _e);
-            break;
-        case 4:
-            log.trace("  |-----|    {}", _e);
-            break;
-        case 5:
-            log.trace("  |-------|  {}", _e);
-            break;
-        case 6:
-            log.trace("    |-|      {}", _e);
-            break;
-        case 7:
-            log.trace("    |---|    {}", _e);
-            break;
-        case 8:
-            log.trace("    |-----|  {}", _e);
-            break;
-        case 9:
-            log.trace("     |-|     {}", _e);
-            break;
-        case 10:
-            log.trace("      |-|    {}", _e);
-            break;
-        case 11:
-            log.trace("      |---|  {}", _e);
-            break;
-        case 12:
-            log.trace("        |-|  {}", _e);
-            break;
-        case 13:
-            log.trace("         |-| {}", _e);
-            break;
-	    
-        case 15:
-            // Fake case
-            log.trace("      |---?  {}", _e);
-            break;
+            case 1:
+                log.trace("|-|          {}", _e);
+                break;
+            case 2:
+                log.trace("|---|        {}", _e);
+                break;
+            case 3:
+                log.trace("  |---|      {}", _e);
+                break;
+            case 4:
+                log.trace("  |-----|    {}", _e);
+                break;
+            case 5:
+                log.trace("  |-------|  {}", _e);
+                break;
+            case 6:
+                log.trace("    |-|      {}", _e);
+                break;
+            case 7:
+                log.trace("    |---|    {}", _e);
+                break;
+            case 8:
+                log.trace("    |-----|  {}", _e);
+                break;
+            case 9:
+                log.trace("     |-|     {}", _e);
+                break;
+            case 10:
+                log.trace("      |-|    {}", _e);
+                break;
+            case 11:
+                log.trace("      |---|  {}", _e);
+                break;
+            case 12:
+                log.trace("        |-|  {}", _e);
+                break;
+            case 13:
+                log.trace("         |-| {}", _e);
+                break;
 
-        case 16:
-            // Fake case
-            log.trace("  |---?      {}", _e);
-            break;
+            case 15:
+                // Fake case
+                log.trace("      |---?  {}", _e);
+                break;
+
+            case 16:
+                // Fake case
+                log.trace("  |---?      {}", _e);
+                break;
         };
     };
-    
+
 
     private WithinSpan _currentWrap () {
         WithinSpan _wrap = new WithinSpan();
-        _wrap.start = this.wrapStart != -1 ? this.wrapStart : this.wrapSpans.start();
-        _wrap.end   = this.wrapEnd   != -1 ? this.wrapEnd   : this.wrapSpans.end();
-        _wrap.doc   = this.wrapDoc   != -1 ? this.wrapDoc   : this.wrapSpans.doc();
+        _wrap.start = this.wrapStart != -1 ? this.wrapStart : this.wrapSpans
+                .start();
+        _wrap.end = this.wrapEnd != -1 ? this.wrapEnd : this.wrapSpans.end();
+        _wrap.doc = this.wrapDoc != -1 ? this.wrapDoc : this.wrapSpans.doc();
         return _wrap;
     };
-	    
+
+
     private WithinSpan _currentEmbedded () {
         WithinSpan _embedded = new WithinSpan();
-        _embedded.start = this.embeddedStart != -1 ?
-                          this.embeddedStart : this.embeddedSpans.start();
-        _embedded.end   = this.embeddedEnd   != -1 ?
-                          this.embeddedEnd   : this.embeddedSpans.end();
-        _embedded.doc   = this.embeddedDoc   != -1 ?
-                          this.embeddedDoc   : this.embeddedSpans.doc();
+        _embedded.start = this.embeddedStart != -1 ? this.embeddedStart
+                : this.embeddedSpans.start();
+        _embedded.end = this.embeddedEnd != -1 ? this.embeddedEnd
+                : this.embeddedSpans.end();
+        _embedded.doc = this.embeddedDoc != -1 ? this.embeddedDoc
+                : this.embeddedSpans.doc();
         return _embedded;
     };
-    
+
 
     private void todo (byte currentCase) throws IOException {
-	/*
-	  Check what to do next with the spans.
-	  
-	  The different follow up steps are:
-	  - storeEmbedded -> store span B for later checks
-	  - nextSpanA     -> forward a
-	  - nextSpanB     -> forward b
+        /*
+          Check what to do next with the spans.
+          
+          The different follow up steps are:
+          - storeEmbedded -> store span B for later checks
+          - nextSpanA     -> forward a
+          - nextSpanB     -> forward b
 
-	  These rules were automatically generated
-	*/
+          These rules were automatically generated
+        */
 
-	// Case 1, 2
-	if (currentCase <= (byte) 2) {
-	    this.nextSpanB();
-	}
-
-	// Case 12, 13
-	else if (currentCase >= (byte) 12) {
-	    this.storeEmbedded();
-	    this.nextSpanA();
-	}
-
-	// Case 3, 4, 5, 8
-	else if (currentCase <= (byte) 5 ||
-             currentCase == (byte) 8) {
-	    if (flag <= 2)
-            this.storeEmbedded();
-	    this.nextSpanB();
-	}
-
-	// Case 11
-	else if (currentCase == (byte) 11) {
-	    if (this.flag == REAL_WITHIN) {
+        // Case 1, 2
+        if (currentCase <= (byte) 2) {
             this.nextSpanB();
-	    }
-	    else if (this.flag >= STARTSWITH) {
+        }
+
+        // Case 12, 13
+        else if (currentCase >= (byte) 12) {
+            this.storeEmbedded();
             this.nextSpanA();
-	    }
-	    else {
-            this.storeEmbedded();
+        }
+
+        // Case 3, 4, 5, 8
+        else if (currentCase <= (byte) 5 || currentCase == (byte) 8) {
+            if (flag <= 2)
+                this.storeEmbedded();
             this.nextSpanB();
-	    };
-	}
+        }
+
+        // Case 11
+        else if (currentCase == (byte) 11) {
+            if (this.flag == REAL_WITHIN) {
+                this.nextSpanB();
+            }
+            else if (this.flag >= STARTSWITH) {
+                this.nextSpanA();
+            }
+            else {
+                this.storeEmbedded();
+                this.nextSpanB();
+            };
+        }
 
 
-	// Case 6, 7, 9, 10
-	else {
-	    
-	    if (
-		// Case 6
-		(currentCase == (byte) 6 && this.flag == MATCH) ||
+        // Case 6, 7, 9, 10
+        else {
 
-		// Case 7
-		(currentCase == (byte) 7 && this.flag == REAL_WITHIN) ||
+            if (
+            // Case 6
+            (currentCase == (byte) 6 && this.flag == MATCH) ||
 
-		// Case 9, 10
-		(currentCase >= (byte) 9 && this.flag >= STARTSWITH)) {
-	    
-		this.nextSpanA();
-	    }
-	    else {
-		this.storeEmbedded();
-		this.nextSpanB();
-	    };
-	};
+            // Case 7
+                    (currentCase == (byte) 7 && this.flag == REAL_WITHIN) ||
+
+                    // Case 9, 10
+                    (currentCase >= (byte) 9 && this.flag >= STARTSWITH)) {
+
+                this.nextSpanA();
+            }
+            else {
+                this.storeEmbedded();
+                this.nextSpanB();
+            };
+        };
     };
 
+
     // Store the current embedded span in the first spanStore
     private void storeEmbedded () throws IOException {
 
         // Create a current copy
         WithinSpan embedded = new WithinSpan();
-        embedded.start = this.embeddedStart != -1 ?
-                         this.embeddedStart : this.embeddedSpans.start();
-        embedded.end   = this.embeddedEnd   != -1 ?
-                         this.embeddedEnd : this.embeddedSpans.end();
-        embedded.doc   = this.embeddedDoc;
+        embedded.start = this.embeddedStart != -1 ? this.embeddedStart
+                : this.embeddedSpans.start();
+        embedded.end = this.embeddedEnd != -1 ? this.embeddedEnd
+                : this.embeddedSpans.end();
+        embedded.doc = this.embeddedDoc;
 
         // Copy payloads
         if (this.embeddedPayload != null) {
-            embedded.payload = new ArrayList<byte[]>(this.embeddedPayload.size());
+            embedded.payload = new ArrayList<byte[]>(
+                    this.embeddedPayload.size());
             embedded.payload.addAll(this.embeddedPayload);
         }
         else if (this.embeddedSpans.isPayloadAvailable()) {
             embedded.payload = new ArrayList<byte[]>(3);
             Collection<byte[]> payload = this.embeddedSpans.getPayload();
-            
+
             this.embeddedPayload = new ArrayList<byte[]>(payload.size());
             this.embeddedPayload.addAll(payload);
             embedded.payload.addAll(payload);
@@ -939,9 +920,10 @@
         this.spanStore1.add(embedded);
 
         if (DEBUG)
-            log.trace("Pushed to spanStore 1 {} (in storeEmbedded)", embedded.toString());
+            log.trace("Pushed to spanStore 1 {} (in storeEmbedded)",
+                    embedded.toString());
     };
-    
+
 
     // Return case number
     private byte withinCase () {
@@ -955,17 +937,17 @@
             if (this.wrapStart > this.embeddedEnd) {
                 return (byte) 1;
             }
-            
+
             // Case 2
             //   |-|
             // |-|
             else if (this.wrapStart == this.embeddedEnd) {
                 return (byte) 2;
             };
-            
+
             // Load wrapEnd
             this.wrapEnd = this.wrapSpans.end();
-            
+
             // Case 3
             //   |---|
             // |---|
@@ -979,13 +961,13 @@
             else if (this.wrapEnd == this.embeddedEnd) {
                 return (byte) 4;
             };
-            
+
             // Case 5
             //  |-|
             // |---|
             return (byte) 5;
         }
-        
+
         // case 6-8
         else if (this.wrapStart == this.embeddedStart) {
 
@@ -1011,7 +993,7 @@
             // |---|
             return (byte) 8;
         }
-        
+
         // wrapStart < embeddedStart
 
         // Load wrapEnd
@@ -1023,56 +1005,65 @@
         if (this.wrapEnd < this.embeddedStart) {
             return (byte) 13;
         }
-        
+
         // Case 9
         // |---|
         //  |-|
         else if (this.wrapEnd > this.embeddedEnd) {
             return (byte) 9;
         }
-        
+
         // Case 10
         // |---|
         //   |-|
         else if (this.wrapEnd == this.embeddedEnd) {
             return (byte) 10;
         }
-        
+
         // Case 11
         // |---|
         //   |---|
         else if (this.wrapEnd > this.embeddedStart) {
             return (byte) 11;
         }
-	
+
         // case 12
         // |-|
         //   |-|
         return (byte) 12;
-    };   
+    };
 
 
-    /** Returns the document number of the current match.  Initially invalid. */
+    /**
+     * Returns the document number of the current match. Initially
+     * invalid.
+     */
     @Override
     public int doc () {
         return matchDoc;
     };
 
-    
-    /** Returns the start position of the embedding wrap.  Initially invalid. */
+
+    /**
+     * Returns the start position of the embedding wrap. Initially
+     * invalid.
+     */
     @Override
     public int start () {
         return matchStart;
     };
 
-    
-    /** Returns the end position of the embedding wrap.  Initially invalid. */
+
+    /**
+     * Returns the end position of the embedding wrap. Initially
+     * invalid.
+     */
     @Override
     public int end () {
-	return matchEnd;
+        return matchEnd;
     };
 
-    
+
     /**
      * Returns the payload data for the current span.
      * This is invalid until {@link #next()} is called for
@@ -1080,72 +1071,82 @@
      * This method must not be called more than once after each call
      * of {@link #next()}. However, most payloads are loaded lazily,
      * so if the payload data for the current position is not needed,
-     * this method may not be called at all for performance reasons. An ordered
-     * SpanQuery does not lazy load, so if you have payloads in your index and
-     * you do not want ordered SpanNearQuerys to collect payloads, you can
+     * this method may not be called at all for performance reasons.
+     * An ordered
+     * SpanQuery does not lazy load, so if you have payloads in your
+     * index and
+     * you do not want ordered SpanNearQuerys to collect payloads, you
+     * can
      * disable collection with a constructor option.<br>
      * <br>
-     * Note that the return type is a collection, thus the ordering should not be relied upon.
+     * Note that the return type is a collection, thus the ordering
+     * should not be relied upon.
      * <br/>
+     * 
      * @lucene.experimental
-     *
-     * @return a List of byte arrays containing the data of this payload, otherwise null if isPayloadAvailable is false
-     * @throws IOException if there is a low-level I/O error
+     * 
+     * @return a List of byte arrays containing the data of this
+     *         payload, otherwise null if isPayloadAvailable is false
+     * @throws IOException
+     *             if there is a low-level I/O error
      */
     // public abstract Collection<byte[]> getPayload() throws IOException;
     @Override
-    public Collection<byte[]> getPayload() throws IOException {
-	return matchPayload;
+    public Collection<byte[]> getPayload () throws IOException {
+        return matchPayload;
     };
-    
+
 
     /**
      * Checks if a payload can be loaded at this position.
      * <p/>
-     * Payloads can only be loaded once per call to
-     * {@link #next()}.
-     *
-     * @return true if there is a payload available at this position that can be loaded
+     * Payloads can only be loaded once per call to {@link #next()}.
+     * 
+     * @return true if there is a payload available at this position
+     *         that can be loaded
      */
     @Override
-    public boolean isPayloadAvailable() {
-	return matchPayload.isEmpty() == false;
+    public boolean isPayloadAvailable () {
+        return matchPayload.isEmpty() == false;
     };
 
-    
+
     // Todo: This may be in the wrong version
     @Override
-    public long cost() {
-	return wrapSpans.cost() + embeddedSpans.cost();
+    public long cost () {
+        return wrapSpans.cost() + embeddedSpans.cost();
     };
 
-    
+
     @Override
-    public String toString() {
-	return getClass().getName() + "("+query.toString()+")@"+
-	    (embeddedDoc <= 0?"START":(more?(doc()+":"+start()+"-"+end()):"END"));
+    public String toString () {
+        return getClass().getName()
+                + "("
+                + query.toString()
+                + ")@"
+                + (embeddedDoc <= 0 ? "START" : (more ? (doc() + ":" + start()
+                        + "-" + end()) : "END"));
     };
 
 
     // This was formerly the default candidate span class,
     // before it was refactored out
-    private class WithinSpan implements Comparable<WithinSpan>, Cloneable  {
-        public int
-            start = -1,
-            end   = -1,
-            doc   = -1;
+    private class WithinSpan implements Comparable<WithinSpan>, Cloneable {
+        public int start = -1, end = -1, doc = -1;
 
         public Collection<byte[]> payload;
 
         public short elementRef = -1;
-    
+
+
         public void clear () {
             this.start = -1;
             this.end = -1;
             this.doc = -1;
             clearPayload();
         };
-    
+
+
         @Override
         public int compareTo (WithinSpan o) {
             /* optimizable for short numbers to return o.end - this.end */
@@ -1164,16 +1165,19 @@
             return 1;
         };
 
-        public short getElementRef() {
+
+        public short getElementRef () {
             return elementRef;
         }
 
-        public void setElementRef(short elementRef) {
+
+        public void setElementRef (short elementRef) {
             this.elementRef = elementRef;
         };
-    
+
+
         @Override
-        public Object clone() {
+        public Object clone () {
             WithinSpan span = new WithinSpan();
             span.start = this.start;
             span.end = this.end;
@@ -1182,6 +1186,7 @@
             return span;
         };
 
+
         public WithinSpan copyFrom (WithinSpan o) {
             this.start = o.start;
             this.end = o.end;
@@ -1190,19 +1195,19 @@
             this.payload.addAll(o.payload);
             return this;
         };
-        
+
+
         public void clearPayload () {
             if (this.payload != null)
                 this.payload.clear();
         };
 
+
         public String toString () {
             StringBuilder sb = new StringBuilder("[");
-            return sb.append(this.start).append('-')
-                .append(this.end)
-                .append('(').append(this.doc).append(')')
-                .append(']')
-                .toString();
+            return sb.append(this.start).append('-').append(this.end)
+                    .append('(').append(this.doc).append(')').append(']')
+                    .toString();
         };
     };
 };
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 e60ca21..6503b3f 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
@@ -20,19 +20,20 @@
     private SpanQuery query;
     private List<SpanQueryWrapper> alternatives;
 
+
     public SpanAlterQueryWrapper (String field) {
         this.field = field;
         this.alternatives = new ArrayList<>();
     };
 
+
     public SpanAlterQueryWrapper (String field, SpanQuery query) {
         this.field = field;
         this.alternatives = new ArrayList<>();
-        this.alternatives.add(
-            new SpanSimpleQueryWrapper(query)
-        );
+        this.alternatives.add(new SpanSimpleQueryWrapper(query));
     };
 
+
     public SpanAlterQueryWrapper (String field, SpanQueryWrapper query) {
         this.field = field;
         this.alternatives = new ArrayList<>();
@@ -41,35 +42,30 @@
         this.alternatives.add(query);
     };
 
+
     public SpanAlterQueryWrapper (String field, String ... terms) {
         this.field = field;
         this.alternatives = new ArrayList<>();
         for (String term : terms) {
             this.isNull = false;
-            this.alternatives.add(
-                new SpanSimpleQueryWrapper(
-                    new SpanTermQuery(
-                        new Term(this.field, term)
-                    )
-                )
-            );
+            this.alternatives.add(new SpanSimpleQueryWrapper(new SpanTermQuery(
+                    new Term(this.field, term))));
         };
     };
 
+
     public SpanAlterQueryWrapper or (String term) {
-        return this.or(
-            new SpanTermQuery(new Term(this.field, term))
-        );
+        return this.or(new SpanTermQuery(new Term(this.field, term)));
     };
 
+
     public SpanAlterQueryWrapper or (SpanQuery query) {
-        this.alternatives.add(
-            new SpanSimpleQueryWrapper(query)
-        );
+        this.alternatives.add(new SpanSimpleQueryWrapper(query));
         this.isNull = false;
         return this;
     };
 
+
     public SpanAlterQueryWrapper or (SpanQueryWrapper term) {
         if (term.isNull())
             return this;
@@ -82,7 +78,7 @@
         if (term.isOptional())
             this.isOptional = true;
 
-        this.alternatives.add( term );
+        this.alternatives.add(term);
 
         if (term.maybeUnsorted())
             this.maybeUnsorted = true;
@@ -92,37 +88,37 @@
         return this;
     };
 
+
     public SpanAlterQueryWrapper or (SpanRegexQueryWrapper term) {
-        this.alternatives.add( term );
+        this.alternatives.add(term);
         this.isNull = false;
         return this;
     };
 
+
     public SpanAlterQueryWrapper or (SpanWildcardQueryWrapper wc) {
-        this.alternatives.add( wc );
+        this.alternatives.add(wc);
         this.isNull = false;
         return this;
     };
 
+
     @Override
-    public SpanQuery toQuery() throws QueryException {
+    public SpanQuery toQuery () throws QueryException {
         if (this.isNull || this.alternatives.size() == 0)
             return (SpanQuery) null;
-	    
+
         if (this.alternatives.size() == 1) {
-            return (SpanQuery) this.alternatives.get(0).
-                retrieveNode(this.retrieveNode).
-                toQuery();
+            return (SpanQuery) this.alternatives.get(0)
+                    .retrieveNode(this.retrieveNode).toQuery();
         };
 
         Iterator<SpanQueryWrapper> clause = this.alternatives.iterator();
-        SpanOrQuery soquery = new SpanOrQuery(
-            clause.next().retrieveNode(this.retrieveNode).toQuery()
-        );
+        SpanOrQuery soquery = new SpanOrQuery(clause.next()
+                .retrieveNode(this.retrieveNode).toQuery());
         while (clause.hasNext()) {
-            soquery.addClause(
-                clause.next().retrieveNode(this.retrieveNode).toQuery()
-            );
+            soquery.addClause(clause.next().retrieveNode(this.retrieveNode)
+                    .toQuery());
         };
         return (SpanQuery) soquery;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
index 87c9d90..90e9a2b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanAttributeQueryWrapper.java
@@ -13,40 +13,44 @@
 
     private SpanQueryWrapper subquery;
 
-	public SpanAttributeQueryWrapper(SpanQueryWrapper sqw) {
-		if (sqw == null) {
-			isNull = true;
-			return;
-		}
-		if (sqw.isEmpty()) {
-			isEmpty = true;
-			return;
-		}
+
+    public SpanAttributeQueryWrapper (SpanQueryWrapper sqw) {
+        if (sqw == null) {
+            isNull = true;
+            return;
+        }
+        if (sqw.isEmpty()) {
+            isEmpty = true;
+            return;
+        }
 
         this.subquery = sqw;
-		if (sqw.isNegative) {
-			this.isNegative = true;
+        if (sqw.isNegative) {
+            this.isNegative = true;
         };
 
         if (sqw.maybeUnsorted())
             this.maybeUnsorted = true;
     };
 
+
     @Override
-	public SpanQuery toQuery() throws QueryException {
-    	if (isNull || isEmpty) return null;
-    		
+    public SpanQuery toQuery () throws QueryException {
+        if (isNull || isEmpty)
+            return null;
+
         SpanQuery sq = subquery.retrieveNode(this.retrieveNode).toQuery();
-		if (sq == null) {
-			isNull = true;
-			return null;
-		}
-		
+        if (sq == null) {
+            isNull = true;
+            return null;
+        }
+
         if (sq instanceof SpanTermQuery) {
-			return new SpanAttributeQuery((SpanTermQuery) sq, isNegative, true);
+            return new SpanAttributeQuery((SpanTermQuery) sq, isNegative, true);
         }
         else {
-        	throw new IllegalArgumentException("The subquery is not a SpanTermQuery.");
-        }		
+            throw new IllegalArgumentException(
+                    "The subquery is not a SpanTermQuery.");
+        }
     }
 }
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 96c9a3b..05edf76 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
@@ -12,21 +12,25 @@
 public class SpanClassQueryWrapper extends SpanQueryWrapper {
     private SpanQueryWrapper subquery;
 
+
     public SpanClassQueryWrapper (SpanQueryWrapper subquery, byte number) {
         this.subquery = subquery;
-        this.number   = number;
+        this.number = number;
         if (number != (byte) 0)
             this.hasClass = true;
     };
 
+
     public SpanClassQueryWrapper (SpanQueryWrapper subquery, short number) {
         this(subquery, (byte) number);
     };
 
+
     public SpanClassQueryWrapper (SpanQueryWrapper subquery, int number) {
         this(subquery, (byte) number);
     };
 
+
     public SpanClassQueryWrapper (SpanQueryWrapper subquery) {
         this(subquery, (byte) 0);
     };
@@ -63,13 +67,15 @@
 
 
     public SpanQuery toQuery () throws QueryException {
-		if (this.subquery.isNull())
+        if (this.subquery.isNull())
             return (SpanQuery) null;
 
-        SpanQuery sq = (SpanQuery) this.subquery.retrieveNode(this.retrieveNode).toQuery();
+        SpanQuery sq = (SpanQuery) this.subquery
+                .retrieveNode(this.retrieveNode).toQuery();
 
-        if (sq == null) return (SpanQuery) null;
-	
+        if (sq == null)
+            return (SpanQuery) null;
+
         if (this.number == (byte) 0) {
             return new SpanClassQuery(sq);
         };
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 c12f1dd..bb9ddc2 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
@@ -18,6 +18,7 @@
     String element;
     String field;
 
+
     public SpanElementQueryWrapper (String field, String element) {
         this.field = field;
         this.element = element;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
index 19269ae..adcce08 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanFocusQueryWrapper.java
@@ -24,43 +24,50 @@
     private SpanQueryWrapper subquery;
     private byte number;
 
+
     public SpanFocusQueryWrapper (SpanQueryWrapper subquery, byte number) {
-	this.subquery = subquery;
-	this.number = number;
+        this.subquery = subquery;
+        this.number = number;
     };
 
+
     public SpanFocusQueryWrapper (SpanQueryWrapper subquery, short number) {
-	this.subquery = subquery;
-	this.number = (byte) number;
+        this.subquery = subquery;
+        this.number = (byte) number;
     };
 
+
     public SpanFocusQueryWrapper (SpanQueryWrapper subquery, int number) {
-	this.subquery = subquery;
-	this.number = (byte) number;
+        this.subquery = subquery;
+        this.number = (byte) number;
     };
 
+
     public SpanFocusQueryWrapper (SpanQueryWrapper subquery) {
-	this.subquery = subquery;
-	this.number = (byte) 1;
+        this.subquery = subquery;
+        this.number = (byte) 1;
     };
 
+
     public SpanQuery toQuery () throws QueryException {
         if (this.subquery.isNull())
             return (SpanQuery) null;
-        return new SpanFocusQuery(
-            this.subquery.retrieveNode(this.retrieveNode).toQuery(), this.number
-        );
+        return new SpanFocusQuery(this.subquery.retrieveNode(this.retrieveNode)
+                .toQuery(), this.number);
     };
 
+
     public boolean isOptional () {
-	return this.subquery.isOptional();
+        return this.subquery.isOptional();
     };
 
+
     public boolean isNull () {
-	return this.subquery.isNull();
+        return this.subquery.isNull();
     };
 
+
     public boolean isNegative () {
-	return this.subquery.isNegative();
+        return this.subquery.isNegative();
     };
 };
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 dd6bac6..987d21a 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
@@ -11,14 +11,14 @@
  * that add certain information,
  * necessary for the correct and optimized
  * deserialization of nested queries.
- *
+ * 
  * This class is meant to be extended by
  * wrapper classes.
- *
+ * 
  * <strong>Warning</strong>: SpanQueryWrapper
- * will probably be merged with {@link KrillQuery}
- * in near future. Use of this API is on your own risk.
- *
+ * will probably be merged with {@link KrillQuery} in near future. Use
+ * of this API is on your own risk.
+ * 
  * @author diewald
  */
 public class SpanQueryWrapper {
@@ -30,21 +30,16 @@
     protected byte number = (byte) 0;
 
     // Boolean properties
-    protected boolean
-        hasClass   = false,
-        isNull     = true,
-        isOptional = false,
-        isNegative = false,
-        isEmpty    = false,
-        isExtended = false,
-        isExtendedToTheRight = false,
-        maybeUnsorted = false,
-        retrieveNode = false;
+    protected boolean hasClass = false, isNull = true, isOptional = false,
+            isNegative = false, isEmpty = false, isExtended = false,
+            isExtendedToTheRight = false, maybeUnsorted = false,
+            retrieveNode = false;
+
 
     /**
      * Serialize the wrapped query and return a SpanQuery.
      * This should be overwritten.
-     *
+     * 
      * @return A {@link SpanQuery} object.
      * @throws QueryException
      */
@@ -56,14 +51,14 @@
     /**
      * Boolean value indicating that the wrapped query
      * is optional.
-     *
+     * 
      * For example the segment denoting an adjective
      * in the following Poliqarp expression is optional.
-     *
+     * 
      * <blockquote><pre>
-     *   the [pos=ADJ]? tree
+     * the [pos=ADJ]? tree
      * </pre></blockquote>
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query is
      *         optional and <tt>false</tt> in case it is
      *         mandatory.
@@ -77,15 +72,15 @@
      * Boolean value indicating that the wrapped query is
      * <tt>null</tt>, meaning it doesn't match anything at
      * all.
-     *
+     * 
      * For example the segment denoting an adjective
      * in the following Poliqarp expression doen't match
      * anything.
-     *
+     * 
      * <blockquote><pre>
-     *   the [pos=ADJ]{0} tree
+     * the [pos=ADJ]{0} tree
      * </pre></blockquote>
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query can't
      *         match anything, otherwise <tt>false</tt>.
      */
@@ -99,14 +94,14 @@
     /**
      * Boolean value indicating that the wrapped query matches
      * in case the condition of the query is not true.
-     *
+     * 
      * For example the segment denoting an adjective
      * in the following Poliqarp expression is negative.
-     *
+     * 
      * <blockquote><pre>
-     *   the [pos!=ADJ]
+     * the [pos!=ADJ]
      * </pre></blockquote>
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query is
      *         negative, otherwise <tt>false</tt>.
      */
@@ -114,18 +109,19 @@
         return this.isNegative;
     };
 
+
     /**
      * Boolean value indicating that the wrapped query has
      * no further condition for matching and therefore
      * matches everywhere.
-     *
+     * 
      * For example the empty segment in the following
      * Poliqarp expression matches without any condition.
-     *
+     * 
      * <blockquote><pre>
-     *   the []
+     * the []
      * </pre></blockquote>
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query is
      *         empty, otherwise <tt>false</tt>.
      */
@@ -137,14 +133,14 @@
     /**
      * Boolean value indicating that the wrapped query
      * is extended by subquery.
-     *
+     * 
      * For example the segment denoting an adjective may
      * be wrapped as having an extension to the left.
-     *
+     * 
      * <blockquote><pre>
-     *   []{3,4}[base=tree]
+     * []{3,4}[base=tree]
      * </pre></blockquote>
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query is
      *         extended, otherwise <tt>false</tt>.
      */
@@ -156,18 +152,18 @@
     /**
      * Boolean value indicating that the wrapped query
      * is extended by a subquery to the right.
-     *
+     * 
      * For example the segment denoting the lemma tree
      * may be wrapped as being extended to the right
      * in the following Poliqarp expression.
-     *
+     * 
      * <blockquote><pre>
-     *   [base=tree][]{3,4}
+     * [base=tree][]{3,4}
      * </pre></blockquote>
-     *
+     * 
      * This information is necessary to ensure a match
      * is valid even at the end of a document.
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query is
      *         extended to the right, otherwise <tt>false</tt>.
      */
@@ -180,21 +176,25 @@
      * Check, if the wrapped query can be used as an
      * anchor query in a sequence, i.e. a query that
      * has a condition that must be positively evaluated.
-     *
+     * 
      * Wrapped queries with positive conditions are neither
      * negative, optional, nor empty.
-     *
+     * 
      * This is the opposite of {@link #maybeExtension}.
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query
      *         can be used as an anchor in a sequence,
      *         otherwise <tt>false</tt>.
      * @see SpanSequenceQueryWrapper
      */
     public boolean maybeAnchor () {
-        if (this.isNegative()) return false;
-        if (this.isOptional()) return false;
-		if (this.isEmpty()) { return false;}		
+        if (this.isNegative())
+            return false;
+        if (this.isOptional())
+            return false;
+        if (this.isEmpty()) {
+            return false;
+        }
         return true;
     };
 
@@ -203,12 +203,12 @@
      * Check, if the wrapped query can't be used as an
      * anchor query in a sequence, meaning it has to be
      * constructed as an extension to an anchor query.
-     *
+     * 
      * Wrapped queries with negative conditions are either
      * negative, optional, or empty.
-     *
+     * 
      * This is the opposite of {@link #maybeAnchor}.
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query
      *         has to be used as an extension in a sequence,
      *         otherwise <tt>false</tt>.
@@ -222,12 +222,12 @@
     /**
      * Check, if the wrapped query may need to be sorted
      * on focussing on a specific class.
-     *
+     * 
      * Normally spans are always sorted, but in case of
      * a wrapped relation query, classed operands may
      * be in arbitrary order. When focussing on these
      * classes, the span has to me reordered.
-     *
+     * 
      * @return <tt>true</tt> in case the wrapped query
      *         has to be sorted on focussing,
      *         otherwise <tt>false</tt>.
@@ -240,7 +240,7 @@
     /**
      * Get the minimum number of repetitions of the
      * wrapped query.
-     *
+     * 
      * @return The minimum number of repetions.
      * @see SpanRepetitionQueryWrapper
      */
@@ -252,8 +252,9 @@
     /**
      * Set the minimum number of repetitions of the
      * wrapped query.
-     *
-     * @param min The minimum number of repetions.
+     * 
+     * @param min
+     *            The minimum number of repetions.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper setMin (int min) {
@@ -265,7 +266,7 @@
     /**
      * Get the maximum number of repetitions of the
      * wrapped query.
-     *
+     * 
      * @return The maximum number of repetions.
      * @see SpanRepetitionQueryWrapper
      */
@@ -277,8 +278,9 @@
     /**
      * Set the maximum number of repetitions of the
      * wrapped query.
-     *
-     * @param max The maximum number of repetions.
+     * 
+     * @param max
+     *            The maximum number of repetions.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper setMax (int max) {
@@ -290,9 +292,10 @@
     /**
      * Make the query request node information in addition to
      * span information.
-     *
-     * @param retrieve Boolean value saying the wrapper
-     *        has or has not to respect node information.
+     * 
+     * @param retrieve
+     *            Boolean value saying the wrapper
+     *            has or has not to respect node information.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper retrieveNode (boolean retrieve) {
@@ -314,7 +317,7 @@
     /**
      * Get the class number, if set.
      * Returns <tt>0</tt> in case no class is set.
-     *
+     * 
      * @return The class number.
      */
     public byte getClassNumber () {
@@ -324,8 +327,9 @@
 
     /**
      * Set the class number.
-     *
-     * @param number The class number as a byte value.
+     * 
+     * @param number
+     *            The class number as a byte value.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper setClassNumber (byte number) {
@@ -337,8 +341,9 @@
 
     /**
      * Set the class number.
-     *
-     * @param number The class number as a short value.
+     * 
+     * @param number
+     *            The class number as a short value.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper setClassNumber (short number) {
@@ -348,8 +353,9 @@
 
     /**
      * Set the class number.
-     *
-     * @param number The class number as an integer value.
+     * 
+     * @param number
+     *            The class number as an integer value.
      * @return The {@link SpanQueryWrapper} object for chaining.
      */
     public SpanQueryWrapper setClassNumber (int number) {
@@ -359,18 +365,15 @@
 
     /**
      * Serialize the wrapped query to a string representation.
-     *
+     * 
      * This is meant to be overwritten.
-     *
+     * 
      * @return A string containg the query representation.
      */
     public String toString () {
-        String string = "" +
-            (this.isNull() ? "isNull" : "notNull") +
-            "-" +
-            (this.isEmpty() ? "isEmpty" : "notEmpty") +
-            "-" +
-            (this.isOptional() ? "isOptional" : "notOptional");
+        String string = "" + (this.isNull() ? "isNull" : "notNull") + "-"
+                + (this.isEmpty() ? "isEmpty" : "notEmpty") + "-"
+                + (this.isOptional() ? "isOptional" : "notOptional");
         return string;
     };
 };
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 d39a960..24317ad 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
@@ -16,35 +16,43 @@
 public class SpanRegexQueryWrapper extends SpanQueryWrapper {
     private SpanQuery query;
 
+
     public SpanRegexQueryWrapper (String field, String re) {
-	this(field, re, RegExp.ALL, false);
+        this(field, re, RegExp.ALL, false);
     };
 
+
     public SpanRegexQueryWrapper (String field, String re, int flags) {
-	this(field, re, flags, false);
+        this(field, re, flags, false);
     };
 
-    public SpanRegexQueryWrapper (String field, String re, boolean caseinsensitive) {
-	this(field, re, RegExp.ALL, caseinsensitive);
+
+    public SpanRegexQueryWrapper (String field, String re,
+                                  boolean caseinsensitive) {
+        this(field, re, RegExp.ALL, caseinsensitive);
     };
 
-    public SpanRegexQueryWrapper (String field, String re, int flags, boolean caseinsensitive) {
-	if (caseinsensitive) {
-	    if (re.startsWith("s:")) {
-		re = re.replaceFirst("s:", "i:");
-	    };
-	    re = re.toLowerCase();
-	};
-	RegexpQuery requery = new RegexpQuery(new Term(field, re), flags);
-	query = new SpanMultiTermQueryWrapper<RegexpQuery>( requery );
+
+    public SpanRegexQueryWrapper (String field, String re, int flags,
+                                  boolean caseinsensitive) {
+        if (caseinsensitive) {
+            if (re.startsWith("s:")) {
+                re = re.replaceFirst("s:", "i:");
+            };
+            re = re.toLowerCase();
+        };
+        RegexpQuery requery = new RegexpQuery(new Term(field, re), flags);
+        query = new SpanMultiTermQueryWrapper<RegexpQuery>(requery);
 
     };
 
-    public SpanQuery toQuery() {
-	return this.query;
+
+    public SpanQuery toQuery () {
+        return this.query;
     };
 
+
     public boolean isNull () {
-	return false;
+        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 8785098..8a8a008 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
@@ -15,13 +15,16 @@
     private SpanQueryWrapper subquery;
 
     // Logger
-    private final static Logger log = LoggerFactory.getLogger(SpanSequenceQueryWrapper.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(SpanSequenceQueryWrapper.class);
+
 
     public SpanRepetitionQueryWrapper () {
         this.isEmpty = true;
         this.isNull = false;
     };
 
+
     // This is for exact enumbered repetition, like in a{3}
     public SpanRepetitionQueryWrapper (SpanQueryWrapper subquery, int exact) {
         if (!subquery.isEmpty()) {
@@ -39,13 +42,15 @@
             this.max = 0;
             return;
         };
-	
+
         this.min = exact;
         this.max = exact;
     };
 
+
     // 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) {
+    public SpanRepetitionQueryWrapper (SpanQueryWrapper subquery, int min,
+                                       int max) {
 
         if (!subquery.isEmpty()) {
             this.subquery = subquery;
@@ -64,14 +69,14 @@
         else {
             this.isNull = false;
         };
-	
+
         if (min == 0) {
             this.isOptional = true;
             min = 1;
             if (max == 0)
                 this.isNull = true;
         };
-        
+
         this.min = min;
         this.max = max;
     };
@@ -83,7 +88,7 @@
         // The query is null
         if (this.isNull)
             return (SpanQuery) null;
-        
+
         if (this.isEmpty) {
             log.error("You can't queryize an empty query");
             return (SpanQuery) null;
@@ -94,14 +99,11 @@
             return this.subquery.retrieveNode(this.retrieveNode).toQuery();
 
         // That's a fine repetition query
-        return new SpanRepetitionQuery(
-            this.subquery.retrieveNode(this.retrieveNode).toQuery(),
-            this.min,
-            this.max,
-            true
-        );
+        return new SpanRepetitionQuery(this.subquery.retrieveNode(
+                this.retrieveNode).toQuery(), this.min, this.max, true);
     };
 
+
     public boolean isNegative () {
         if (this.subquery == null)
             return false;
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 3265e15..f89c5b7 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
@@ -18,10 +18,13 @@
 
 /**
  * @author Nils Diewald
- *
- * Creates a query object for segments, i.e. terms in a term vector
- * sharing the same position. A SpanSegment can include simple string terms,
- * regular expressions and alternatives. These elements can also be excluded.
+ * 
+ *         Creates a query object for segments, i.e. terms in a term
+ *         vector
+ *         sharing the same position. A SpanSegment can include simple
+ *         string terms,
+ *         regular expressions and alternatives. These elements can
+ *         also be excluded.
  */
 
 public class SpanSegmentQueryWrapper extends SpanQueryWrapper {
@@ -29,218 +32,243 @@
     public ArrayList<SpanQueryWrapper> exclusive;
     private String field;
 
+
     /**
      * Constructor.
-     *
-     * @param field The field name
+     * 
+     * @param field
+     *            The field name
      */
     public SpanSegmentQueryWrapper (String field) {
-	this.field = field;
-	this.inclusive = new ArrayList<SpanQueryWrapper>();
-	this.exclusive = new ArrayList<SpanQueryWrapper>();
+        this.field = field;
+        this.inclusive = new ArrayList<SpanQueryWrapper>();
+        this.exclusive = new ArrayList<SpanQueryWrapper>();
     };
 
+
     /**
      * Constructor.
-     *
-     * @param field The field name
-     * @param terms An arbitrary number of terms
+     * 
+     * @param field
+     *            The field name
+     * @param terms
+     *            An arbitrary number of terms
      */
     public SpanSegmentQueryWrapper (String field, String ... terms) {
-	this(field);
-	for (int i = 0; i < terms.length; i++) {
-	    this.inclusive.add(new SpanSimpleQueryWrapper(field, terms[i]));
-	    this.isNull = false;
-	};
+        this(field);
+        for (int i = 0; i < terms.length; i++) {
+            this.inclusive.add(new SpanSimpleQueryWrapper(field, terms[i]));
+            this.isNull = false;
+        };
     };
 
+
     public SpanSegmentQueryWrapper (String field, SpanRegexQueryWrapper re) {
-	this(field);
-	this.inclusive.add(re);
-	this.isNull = false;
+        this(field);
+        this.inclusive.add(re);
+        this.isNull = false;
     };
 
+
     public SpanSegmentQueryWrapper (String field, SpanAlterQueryWrapper alter) {
-	this(field);
-	if (!alter.isNull()) {
-	    if (alter.isNegative())
-		this.isNegative = true;
-	    this.inclusive.add(alter);
-	    this.isNull = false;
-	};
+        this(field);
+        if (!alter.isNull()) {
+            if (alter.isNegative())
+                this.isNegative = true;
+            this.inclusive.add(alter);
+            this.isNull = false;
+        };
     };
 
+
     public SpanSegmentQueryWrapper (String field, SpanSegmentQueryWrapper ssq) {
-	this(field);
+        this(field);
 
-	if (!ssq.isNull()) {
-	    Iterator<SpanQueryWrapper> clause = ssq.inclusive.iterator();
-	    while (clause.hasNext()) {
-		this.inclusive.add( (SpanQueryWrapper) clause.next() ); 
-		// .clone()
-	    };
+        if (!ssq.isNull()) {
+            Iterator<SpanQueryWrapper> clause = ssq.inclusive.iterator();
+            while (clause.hasNext()) {
+                this.inclusive.add((SpanQueryWrapper) clause.next());
+                // .clone()
+            };
 
-	    clause = ssq.exclusive.iterator();
-	    while (clause.hasNext()) {
-		this.exclusive.add( (SpanQueryWrapper) clause.next() );  
-		// .clone()
-	    };
-	    this.isNull = false;
-	};
+            clause = ssq.exclusive.iterator();
+            while (clause.hasNext()) {
+                this.exclusive.add((SpanQueryWrapper) clause.next());
+                // .clone()
+            };
+            this.isNull = false;
+        };
     };
 
+
     public SpanSegmentQueryWrapper with (String term) {
-	this.inclusive.add(new SpanSimpleQueryWrapper(field, term));
-	this.isNull = false;
-	return this;
+        this.inclusive.add(new SpanSimpleQueryWrapper(field, term));
+        this.isNull = false;
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper with (SpanQueryWrapper re) {
-	this.inclusive.add((SpanQueryWrapper) re);
-	this.isNull = false;
-	return this;
+        this.inclusive.add((SpanQueryWrapper) re);
+        this.isNull = false;
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper with (SpanWildcardQueryWrapper wc) {
-	this.inclusive.add((SpanQueryWrapper) wc);
-	this.isNull = false;
-	return this;
+        this.inclusive.add((SpanQueryWrapper) wc);
+        this.isNull = false;
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper with (SpanAlterQueryWrapper alter) {
-	if (!alter.isNull()) {
-	    if (alter.isNegative())
-		this.isNegative = true;
-	    this.inclusive.add(alter);
-	    this.isNull = false;
-	};
-	return this;
+        if (!alter.isNull()) {
+            if (alter.isNegative())
+                this.isNegative = true;
+            this.inclusive.add(alter);
+            this.isNull = false;
+        };
+        return this;
     };
 
+
     // Identical to without
     public SpanSegmentQueryWrapper with (SpanSegmentQueryWrapper seg) {
-	if (!seg.isNull()) {
-	    for (SpanQueryWrapper sq : seg.inclusive) {
-		this.inclusive.add(sq);
-	    };
-	    for (SpanQueryWrapper sq : seg.exclusive) {
-		this.exclusive.add(sq);
-	    };
-	    this.isNull = false;
-	};
-	return this;
+        if (!seg.isNull()) {
+            for (SpanQueryWrapper sq : seg.inclusive) {
+                this.inclusive.add(sq);
+            };
+            for (SpanQueryWrapper sq : seg.exclusive) {
+                this.exclusive.add(sq);
+            };
+            this.isNull = false;
+        };
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper without (String term) {
-	this.exclusive.add(new SpanSimpleQueryWrapper(field, term));
-	this.isNull = false;
-	return this;
+        this.exclusive.add(new SpanSimpleQueryWrapper(field, term));
+        this.isNull = false;
+        return this;
     };
 
+
     // TODO: THESE MAYBE NOT NECESSARY:
 
     public SpanSegmentQueryWrapper without (SpanRegexQueryWrapper re) {
-	this.exclusive.add(re);
-	this.isNull = false;
-	return this;
+        this.exclusive.add(re);
+        this.isNull = false;
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper without (SpanWildcardQueryWrapper wc) {
-	this.exclusive.add(wc);
-	this.isNull = false;
-	return this;
+        this.exclusive.add(wc);
+        this.isNull = false;
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper without (SpanAlterQueryWrapper alter) {
-	if (!alter.isNull()) {
-	    if (alter.isNegative()) {
-		this.inclusive.add(alter);
-	    }
-	    else {
-		this.exclusive.add(alter);
-	    };
-	    this.isNull = false;
-	};
-	return this;
+        if (!alter.isNull()) {
+            if (alter.isNegative()) {
+                this.inclusive.add(alter);
+            }
+            else {
+                this.exclusive.add(alter);
+            };
+            this.isNull = false;
+        };
+        return this;
     };
 
+
     public SpanSegmentQueryWrapper without (SpanSegmentQueryWrapper seg) {
-	if (!seg.isNull()) {
-	    this.with(seg);
-	    this.isNull = false;
-	};
-	isNegative = true;
-	return this;
+        if (!seg.isNull()) {
+            this.with(seg);
+            this.isNull = false;
+        };
+        isNegative = true;
+        return this;
     };
 
+
     public SpanQuery toQuery () throws QueryException {
-	if (this.isNull || (this.inclusive.size() + this.exclusive.size() == 0)) {
-	    return (SpanQuery) null;
-	}
-	else if (this.inclusive.size() >= 1 && this.exclusive.size() >= 1) {
-	    return (SpanQuery) new SpanNotQuery(
-		this._listToQuery(this.inclusive),
-	        this._listToOrQuery(this.exclusive)
-            );
-	}
+        if (this.isNull || (this.inclusive.size() + this.exclusive.size() == 0)) {
+            return (SpanQuery) null;
+        }
+        else if (this.inclusive.size() >= 1 && this.exclusive.size() >= 1) {
+            return (SpanQuery) new SpanNotQuery(
+                    this._listToQuery(this.inclusive),
+                    this._listToOrQuery(this.exclusive));
+        }
 
-	// These are now identical but may be negative
-	else if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
-	    return (SpanQuery) this._listToQuery(this.exclusive);
-	}
-	else if (this.inclusive.size() >= 1 && this.exclusive.size() == 0) {
-	    return (SpanQuery) this._listToQuery(this.inclusive);
-	};
+        // These are now identical but may be negative
+        else if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
+            return (SpanQuery) this._listToQuery(this.exclusive);
+        }
+        else if (this.inclusive.size() >= 1 && this.exclusive.size() == 0) {
+            return (SpanQuery) this._listToQuery(this.inclusive);
+        };
 
-	return (SpanQuery) null;
+        return (SpanQuery) null;
     };
 
-    private SpanQuery _listToQuery (ArrayList<SpanQueryWrapper> list) throws QueryException {
-	SpanQuery query = list.get(0).toQuery();
 
-	for (int i = 1; i < list.size(); i++) {
-	    query = new SpanSegmentQuery(query, list.get(i).toQuery());
-	};
+    private SpanQuery _listToQuery (ArrayList<SpanQueryWrapper> list)
+            throws QueryException {
+        SpanQuery query = list.get(0).toQuery();
 
-	return (SpanQuery) query;
+        for (int i = 1; i < list.size(); i++) {
+            query = new SpanSegmentQuery(query, list.get(i).toQuery());
+        };
+
+        return (SpanQuery) query;
     };
 
-    private SpanQuery _listToOrQuery (ArrayList<SpanQueryWrapper> list) throws QueryException {
-	if (list.size() == 1) {
-	    return (SpanQuery) list.get(0).toQuery();
-	};
 
-	Iterator<SpanQueryWrapper> clause = list.iterator();
-	SpanOrQuery soquery = new SpanOrQuery( clause.next().toQuery() );
-	while (clause.hasNext()) {
-	    soquery.addClause( clause.next().toQuery() );
-	};
-	return (SpanQuery) soquery;
+    private SpanQuery _listToOrQuery (ArrayList<SpanQueryWrapper> list)
+            throws QueryException {
+        if (list.size() == 1) {
+            return (SpanQuery) list.get(0).toQuery();
+        };
+
+        Iterator<SpanQueryWrapper> clause = list.iterator();
+        SpanOrQuery soquery = new SpanOrQuery(clause.next().toQuery());
+        while (clause.hasNext()) {
+            soquery.addClause(clause.next().toQuery());
+        };
+        return (SpanQuery) soquery;
     };
 
+
     public SpanSegmentQueryWrapper clone () {
-	return new SpanSegmentQueryWrapper(this.field, this);
+        return new SpanSegmentQueryWrapper(this.field, this);
     };
 
+
     public boolean isOptional () {
-	return false;
+        return false;
     };
 
+
     public boolean isNegative () {
-	if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
-	    return true;
-	};
-	return false;
+        if (this.inclusive.size() == 0 && this.exclusive.size() >= 1) {
+            return true;
+        };
+        return false;
     };
 
+
     public void makeNegative () {
-	/*
-	  TODO: THIS IS A BIT MORE COMPLICATED!
-	  and and or groups have to be switched
-	 */
+        /*
+          TODO: THIS IS A BIT MORE COMPLICATED!
+          and and or groups have to be switched
+         */
 
-	this.exclusive.addAll(this.inclusive);
-	this.inclusive.clear();
+        this.exclusive.addAll(this.inclusive);
+        this.inclusive.clear();
     };
 };
-
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 97cb24f..78a80db 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,11 +28,11 @@
 /**
  * Deserialize complexe sequence queries to SpanQueries.
  * This will try to make queries work, that by simple nesting won't
- * (like queries with empty sequences), and will optimize queries 
+ * (like queries with empty sequences), and will optimize queries
  * if possible.
- *
+ * 
  * Todo: Synopsis
- *
+ * 
  * @author diewald
  */
 public class SpanSequenceQueryWrapper extends SpanQueryWrapper {
@@ -41,14 +41,13 @@
     private ArrayList<DistanceConstraint> constraints;
 
     private QueryException constraintException = null;
-    
-    private final String limitationError =
-        "Distance constraints not supported with " +
-        "empty or negative operands";
+
+    private final String limitationError = "Distance constraints not supported with "
+            + "empty or negative operands";
 
     // Logger
-    private final static Logger log =
-        LoggerFactory.getLogger(SpanSequenceQueryWrapper.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(SpanSequenceQueryWrapper.class);
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
@@ -61,9 +60,10 @@
 
     /**
      * Constructs a new object for sequence deserialization.
-     *
-     * @param field The fields the nested SpanQueries should
-     *        search in.
+     * 
+     * @param field
+     *            The fields the nested SpanQueries should
+     *            search in.
      */
     public SpanSequenceQueryWrapper (String field) {
         this.field = field;
@@ -74,26 +74,25 @@
     /**
      * Constructs a new object for sequence deserialization
      * by passing a sequence of terms.
-     *
+     * 
      * <blockquote><pre>
-     *   SpanSequenceQueryWrapper ssqw =
-     *     new SpanSequenceQueryWrapper("tokens", "der", "Baum");
-     *   System.out.println(ssqw.toQuery());
-     *   // spanNext(tokens:der, tokens:Baum)
+     * SpanSequenceQueryWrapper ssqw =
+     * new SpanSequenceQueryWrapper("tokens", "der", "Baum");
+     * System.out.println(ssqw.toQuery());
+     * // spanNext(tokens:der, tokens:Baum)
      * </pre></blockquote>
-     *
-     * @param field The fields the nested SpanQueries should
-     *        search in.
-     * @param terms[] Arbitrary list of terms to search for.
+     * 
+     * @param field
+     *            The fields the nested SpanQueries should
+     *            search in.
+     * @param terms
+     *            [] Arbitrary list of terms to search for.
      */
     public SpanSequenceQueryWrapper (String field, String ... terms) {
         this(field);
         for (int i = 0; i < terms.length; i++) {
-            this.segments.add(
-                new SpanSimpleQueryWrapper(
-                    new SpanTermQuery(new Term(field, terms[i]))
-                )
-            );
+            this.segments.add(new SpanSimpleQueryWrapper(new SpanTermQuery(
+                    new Term(field, terms[i]))));
         };
         // Query can't be null anymore
         this.isNull = false;
@@ -103,8 +102,9 @@
     /**
      * Constructs a new object for sequence deserialization
      * by passing a single {@link SpanQuery} object.
-     *
-     * @param query Initial {@link SpanQuery} to search for.
+     * 
+     * @param query
+     *            Initial {@link SpanQuery} to search for.
      */
     public SpanSequenceQueryWrapper (SpanQuery query) {
         this(query.getField());
@@ -117,8 +117,9 @@
      * Constructs a new object for sequence deserialization
      * by passing a single {@link SpanQueryWrapper} object.
      * These wrapper queries may be optional, negative, or empty.
-     *
-     * @param query Initial {@link SpanQueryWrapper} to search for.
+     * 
+     * @param query
+     *            Initial {@link SpanQueryWrapper} to search for.
      */
     public SpanSequenceQueryWrapper (String field, SpanQueryWrapper sswq) {
         this(field);
@@ -153,17 +154,19 @@
 
     /**
      * Append a new term to the sequence.
-     *
+     * 
      * <blockquote><pre>
-     *   SpanSequenceQueryWrapper ssqw =
-     *     new SpanSequenceQueryWrapper("tokens");
-     *   ssqw.append("der").append("Baum");
-     *   System.out.println(ssqw.toQuery());
-     *   // spanNext(tokens:der, tokens:Baum)
+     * SpanSequenceQueryWrapper ssqw =
+     * new SpanSequenceQueryWrapper("tokens");
+     * ssqw.append("der").append("Baum");
+     * System.out.println(ssqw.toQuery());
+     * // spanNext(tokens:der, tokens:Baum)
      * </pre></blockquote>
-     *
-     * @param term A new string to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param term
+     *            A new string to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
     public SpanSequenceQueryWrapper append (String term) {
         return this.append(new SpanTermQuery(new Term(field, term)));
@@ -172,9 +175,11 @@
 
     /**
      * Append a new {@link SpanQuery} object to the sequence.
-     *
-     * @param query A new {@link SpanQuery} to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param query
+     *            A new {@link SpanQuery} to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
     public SpanSequenceQueryWrapper append (SpanQuery query) {
         return this.append(new SpanSimpleQueryWrapper(query));
@@ -183,11 +188,13 @@
 
     /**
      * Append a new {@link SpanQueryWrapper} object to the sequence.
-     *
-     * @param query A new {@link SpanQueryWrapper} to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param query
+     *            A new {@link SpanQueryWrapper} to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
-	public SpanSequenceQueryWrapper append(SpanQueryWrapper ssq) {
+    public SpanSequenceQueryWrapper append (SpanQueryWrapper ssq) {
 
         // The wrapper is null - ignore this in the sequence
         if (ssq.isNull())
@@ -213,8 +220,8 @@
             SpanSequenceQueryWrapper ssqw = (SpanSequenceQueryWrapper) ssq;
 
             // There are no constraints and the order is equal - Flatten!
-            if (!this.hasConstraints() && !ssqw.hasConstraints() &&
-                this.isInOrder() == ssqw.isInOrder()) {
+            if (!this.hasConstraints() && !ssqw.hasConstraints()
+                    && this.isInOrder() == ssqw.isInOrder()) {
                 for (int i = 0; i < ssqw.segments.size(); i++) {
                     this.append(ssqw.segments.get(i));
                 };
@@ -237,17 +244,19 @@
 
     /**
      * Prepend a new term to the sequence.
-     *
+     * 
      * <blockquote><pre>
-     *   SpanSequenceQueryWrapper ssqw =
-     *     new SpanSequenceQueryWrapper("tokens", "Baum");
-     *   ssqw.prepend("der");
-     *   System.out.println(ssqw.toQuery());
-     *   // spanNext(tokens:der, tokens:Baum)
+     * SpanSequenceQueryWrapper ssqw =
+     * new SpanSequenceQueryWrapper("tokens", "Baum");
+     * ssqw.prepend("der");
+     * System.out.println(ssqw.toQuery());
+     * // spanNext(tokens:der, tokens:Baum)
      * </pre></blockquote>
-     *
-     * @param term A new string to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param term
+     *            A new string to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
     public SpanSequenceQueryWrapper prepend (String term) {
         return this.prepend(new SpanTermQuery(new Term(field, term)));
@@ -256,9 +265,11 @@
 
     /**
      * Prepend a new {@link SpanQuery} object to the sequence.
-     *
-     * @param query A new {@link SpanQuery} to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param query
+     *            A new {@link SpanQuery} to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
     public SpanSequenceQueryWrapper prepend (SpanQuery query) {
         return this.prepend(new SpanSimpleQueryWrapper(query));
@@ -267,9 +278,11 @@
 
     /**
      * Prepend a new {@link SpanQueryWrapper} object to the sequence.
-     *
-     * @param query A new {@link SpanQueryWrapper} to search for.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param query
+     *            A new {@link SpanQueryWrapper} to search for.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      */
     public SpanSequenceQueryWrapper prepend (SpanQueryWrapper ssq) {
 
@@ -292,9 +305,8 @@
 
             // There are no constraints and the order is equal - Flatten!
             SpanSequenceQueryWrapper ssqw = (SpanSequenceQueryWrapper) ssq;
-            if (!this.hasConstraints() &&
-                !ssqw.hasConstraints() &&
-                this.isInOrder() == ssqw.isInOrder()) {
+            if (!this.hasConstraints() && !ssqw.hasConstraints()
+                    && this.isInOrder() == ssqw.isInOrder()) {
                 for (int i = ssqw.segments.size() - 1; i >= 0; i--) {
                     this.prepend(ssqw.segments.get(i));
                 };
@@ -318,21 +330,27 @@
     /**
      * Add a token based sequence constraint (aka distance constraint)
      * to the sequence.
-     *
+     * 
      * Multiple constraints are supported.
-     *
+     * 
      * A minimum value of zero means, there may be an overlap,
-     * a minimum value of 1 means, there is no token between the spans.
-     * It's weird - we know and dislike that. That's why we have to say:
-     *
-     * <strong>Warning!</strong> Sequence constraints are experimental and
+     * a minimum value of 1 means, there is no token between the
+     * spans.
+     * It's weird - we know and dislike that. That's why we have to
+     * say:
+     * 
+     * <strong>Warning!</strong> Sequence constraints are experimental
+     * and
      * may (hopefully) change in future versions!
-     *
-     * @param min The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param max The minimum number of tokens between the elements
-     *        of the sequence.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param min
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param max
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      * @see DistanceConstraint
      */
     public SpanSequenceQueryWrapper withConstraint (int min, int max) {
@@ -345,29 +363,38 @@
      * to the sequence with an exclusion constraint, meaning
      * the constraint is fine in case the operands are <em>not</em>
      * within the distance.
-     *
+     * 
      * Multiple constraints are supported.
-     *
+     * 
      * A minimum value of zero means, there may be an overlap,
-     * a minimum value of 1 means, there is no token between the spans.
-     * It's weird - we know and dislike that. That's why we have to say:
-     *
-     * <strong>Warning!</strong> Sequence constraints are experimental and
+     * a minimum value of 1 means, there is no token between the
+     * spans.
+     * It's weird - we know and dislike that. That's why we have to
+     * say:
+     * 
+     * <strong>Warning!</strong> Sequence constraints are experimental
+     * and
      * may (hopefully) change in future versions!
-     *
-     * @param min The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param max The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param exclusion Boolean value indicating, the distance constraint
-     *        has to fail.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param min
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param max
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param exclusion
+     *            Boolean value indicating, the distance constraint
+     *            has to fail.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      * @see DistanceConstraint
      */
-    public SpanSequenceQueryWrapper withConstraint (int min, int max, boolean exclusion) {
+    public SpanSequenceQueryWrapper withConstraint (int min, int max,
+            boolean exclusion) {
         if (this.constraints == null)
             this.constraints = new ArrayList<DistanceConstraint>(1);
-        this.constraints.add(new DistanceConstraint(min, max, this.isInOrder, exclusion));
+        this.constraints.add(new DistanceConstraint(min, max, this.isInOrder,
+                exclusion));
         return this;
     };
 
@@ -377,29 +404,38 @@
      * to the sequence based on a certain unit.
      * The unit has to be a valid {@link SpanElementQuery} term
      * or <tt>w</tt> for tokens.
-     *
+     * 
      * Multiple constraints are supported.
-     *
+     * 
      * A minimum value of zero means, there may be an overlap,
-     * a minimum value of 1 means, there is no token between the spans.
-     * It's weird - we know and dislike that. That's why we have to say:
-     *
-     * <strong>Warning!</strong> Sequence constraints are experimental and
+     * a minimum value of 1 means, there is no token between the
+     * spans.
+     * It's weird - we know and dislike that. That's why we have to
+     * say:
+     * 
+     * <strong>Warning!</strong> Sequence constraints are experimental
+     * and
      * may (hopefully) change in future versions!
-     *
-     * @param min The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param max The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param unit Unit for distance - will be evaluated to a {@link SpanElementQuery}.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param min
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param max
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param unit
+     *            Unit for distance - will be evaluated to a
+     *            {@link SpanElementQuery}.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      * @see DistanceConstraint
      */
-    public SpanSequenceQueryWrapper withConstraint (int min, int max, String unit) {
+    public SpanSequenceQueryWrapper withConstraint (int min, int max,
+            String unit) {
         return this.withConstraint(min, max, unit, false);
     };
 
-    
+
 
     /**
      * Add a sequence constraint (aka distance constraint)
@@ -408,41 +444,50 @@
      * in case the operands are <em>not</em> within the distance.
      * The unit has to be a valid {@link SpanElementQuery} term
      * or <tt>w</tt> for tokens.
-     *
+     * 
      * Multiple constraints are supported.
-     *
+     * 
      * A minimum value of zero means, there may be an overlap,
-     * a minimum value of 1 means, there is no token between the spans.
-     * It's weird - we know and dislike that. That's why we have to say:
-     *
-     * <strong>Warning!</strong> Sequence constraints are experimental and
+     * a minimum value of 1 means, there is no token between the
+     * spans.
+     * It's weird - we know and dislike that. That's why we have to
+     * say:
+     * 
+     * <strong>Warning!</strong> Sequence constraints are experimental
+     * and
      * may (hopefully) change in future versions!
-     *
-     * @param min The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param max The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param unit Unit for distance - will be evaluated to a {@link SpanElementQuery}.
-     * @param exclusion Boolean value indicating, the distance constraint
-     *        has to fail.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param min
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param max
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param unit
+     *            Unit for distance - will be evaluated to a
+     *            {@link SpanElementQuery}.
+     * @param exclusion
+     *            Boolean value indicating, the distance constraint
+     *            has to fail.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      * @see DistanceConstraint
      */
-    public SpanSequenceQueryWrapper withConstraint
-        (int min, int max, String unit, boolean exclusion) {
+    public SpanSequenceQueryWrapper withConstraint (int min, int max,
+            String unit, boolean exclusion) {
 
         // Word unit
         if (unit.equals("w")) {
             if (this.constraints == null)
                 this.constraints = new ArrayList<DistanceConstraint>(1);
-            this.constraints.add(new DistanceConstraint(min, max, isInOrder, exclusion));
+            this.constraints.add(new DistanceConstraint(min, max, isInOrder,
+                    exclusion));
             return this;
         };
 
         // Element unit (sentence or paragraph)
-        return this.withConstraint(
-            min, max, new SpanElementQueryWrapper(this.field, unit), exclusion
-        );
+        return this.withConstraint(min, max, new SpanElementQueryWrapper(
+                this.field, unit), exclusion);
     };
 
 
@@ -451,43 +496,46 @@
      * to the sequence based on a certain unit and with an
      * exclusion constraint, meaning the constraint is fine
      * in case the operands are <em>not</em> within the distance.
-     *
+     * 
      * Multiple constraints are supported.
-     *
+     * 
      * A minimum value of zero means, there may be an overlap,
-     * a minimum value of 1 means, there is no token between the spans.
-     * It's weird - we know and dislike that. That's why we have to say:
-     *
-     * <strong>Warning!</strong> Sequence constraints are experimental and
+     * a minimum value of 1 means, there is no token between the
+     * spans.
+     * It's weird - we know and dislike that. That's why we have to
+     * say:
+     * 
+     * <strong>Warning!</strong> Sequence constraints are experimental
+     * and
      * may (hopefully) change in future versions!
-     *
-     * @param min The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param max The minimum number of tokens between the elements
-     *        of the sequence.
-     * @param unit A {@link SpanElementQueryWrapper} as the unit for distance.
-     * @param exclusion Boolean value indicating, the distance constraint
-     *        has to fail.
-     * @return The {@link SpanSequenceQueryWrapper} object for chaining.
+     * 
+     * @param min
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param max
+     *            The minimum number of tokens between the elements
+     *            of the sequence.
+     * @param unit
+     *            A {@link SpanElementQueryWrapper} as the unit for
+     *            distance.
+     * @param exclusion
+     *            Boolean value indicating, the distance constraint
+     *            has to fail.
+     * @return The {@link SpanSequenceQueryWrapper} object for
+     *         chaining.
      * @see DistanceConstraint
      */
-    public SpanSequenceQueryWrapper withConstraint
-        (int min, int max, SpanElementQueryWrapper unit, boolean exclusion) {
+    public SpanSequenceQueryWrapper withConstraint (int min, int max,
+            SpanElementQueryWrapper unit, boolean exclusion) {
         if (this.constraints == null)
             this.constraints = new ArrayList<DistanceConstraint>(1);
 
         // Element unit (sentence or paragraph)
         // Todo: This should possibly be evaluated to a query later on!
         try {
-            this.constraints.add(
-                new DistanceConstraint(
-                    (SpanElementQuery) unit.retrieveNode(this.retrieveNode).toQuery(),
-                    min,
-                    max,
-                    isInOrder,
-                    exclusion
-                )
-            );
+            this.constraints.add(new DistanceConstraint((SpanElementQuery) unit
+                    .retrieveNode(this.retrieveNode).toQuery(), min, max,
+                    isInOrder, exclusion));
         }
         catch (QueryException qe) {
             this.constraintException = qe;
@@ -498,7 +546,7 @@
 
     /**
      * Check if the sequence has to be in order.
-     *
+     * 
      * @return <tt>true</tt> in case the sequence
      *         has to be in order and <tt>false</tt>
      *         in case the order is not relevant.
@@ -511,10 +559,11 @@
     /**
      * Set the boolean value indicating if the sequence
      * has to be in order.
-     *
-     * @param order <tt>true</tt> in case the sequence
-     *        has to be in order and <tt>false</tt>
-     *        in case the order is not relevant.
+     * 
+     * @param order
+     *            <tt>true</tt> in case the sequence
+     *            has to be in order and <tt>false</tt>
+     *            in case the order is not relevant.
      */
     public void setInOrder (boolean order) {
         this.isInOrder = order;
@@ -523,7 +572,7 @@
 
     /**
      * Check if the sequence has constraints.
-     *
+     * 
      * @return <tt>true</tt> in case the sequence
      *         has any constraints and <tt>false</tt>
      *         in case it is a simple next query.
@@ -534,14 +583,13 @@
 
         if (this.constraints.size() <= 0)
             return false;
-        
+
         // The constraint is in fact a next query,
         // that will be optimized away later on
         if (this.constraints.size() == 1) {
             DistanceConstraint dc = this.constraints.get(0);
-            if (dc.getUnit().equals("w") &&
-                dc.getMinDistance() == 1 &&
-                dc.getMaxDistance() == 1) {
+            if (dc.getUnit().equals("w") && dc.getMinDistance() == 1
+                    && dc.getMaxDistance() == 1) {
                 return false;
             };
         };
@@ -568,6 +616,7 @@
         return super.isOptional();
     };
 
+
     public boolean isNegative () {
         if (this.segments.size() == 1)
             return this.segments.get(0).isNegative();
@@ -576,6 +625,7 @@
         return super.isNegative();
     };
 
+
     public boolean isExtendedToTheRight () {
         if (!this.isSolved)
             _solveProblematicSequence();
@@ -585,7 +635,7 @@
 
     /**
      * Serialize the wrapped sequence to a {@link SpanQuery} object.
-     *
+     * 
      * @return A {@link SpanQuery} object.
      * @throws QueryException
      */
@@ -605,47 +655,42 @@
         if (size == 1) {
 
             // But the element may be expanded
-            if (this.segments.get(0).isExtended() &&
-                (this.hasConstraints() || !this.isInOrder())) {
+            if (this.segments.get(0).isExtended()
+                    && (this.hasConstraints() || !this.isInOrder())) {
                 throw new QueryException(613, limitationError);
             };
 
             // Unproblematic single query
             if (this.segments.get(0).maybeAnchor())
-                return (SpanQuery) this.segments.get(0).retrieveNode(this.retrieveNode).toQuery();
+                return (SpanQuery) this.segments.get(0)
+                        .retrieveNode(this.retrieveNode).toQuery();
 
             if (this.segments.get(0).isEmpty())
-                throw new QueryException(
-                    613, "Sequence is not allowed to be empty"
-                );
+                throw new QueryException(613,
+                        "Sequence is not allowed to be empty");
 
             if (this.segments.get(0).isOptional())
-                throw new QueryException(
-                    613, "Sequence is not allowed to be optional"
-                );
+                throw new QueryException(613,
+                        "Sequence is not allowed to be optional");
 
             if (this.segments.get(0).isNegative())
-                throw new QueryException(
-                    613, "Sequence is not allowed to be negative"
-                );
+                throw new QueryException(613,
+                        "Sequence is not allowed to be negative");
         };
 
         if (!this.isSolved) {
             if (!_solveProblematicSequence()) {
                 if (this.segments.get(0).maybeExtension()) {
-                    throw new QueryException(
-                        613,
-                        "Sequence contains unresolvable " +
-                        "empty, optional, or negative segments"
-                    );
+                    throw new QueryException(613,
+                            "Sequence contains unresolvable "
+                                    + "empty, optional, or negative segments");
                 };
             };
         };
 
         // The element may be expanded
-        if (this.segments.size() == 1 &&
-            this.segments.get(0).isExtended() &&
-            (this.hasConstraints() || !this.isInOrder())) {
+        if (this.segments.size() == 1 && this.segments.get(0).isExtended()
+                && (this.hasConstraints() || !this.isInOrder())) {
             throw new QueryException(613, limitationError);
         };
 
@@ -653,7 +698,8 @@
         SpanQuery query = null;// = this.segments.get(0).toQuery();
         int i = 0;
         while (query == null && i < this.segments.size()) {
-            query = this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
+            query = this.segments.get(i).retrieveNode(this.retrieveNode)
+                    .toQuery();
             i++;
         };
 
@@ -664,18 +710,16 @@
         if (!this.hasConstraints() && this.isInOrder()) {
             for (; i < this.segments.size(); i++) {
 
-                SpanQuery second = this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
+                SpanQuery second = this.segments.get(i)
+                        .retrieveNode(this.retrieveNode).toQuery();
                 if (second == null)
                     continue;
 
-                query = new SpanNextQuery(
-                    query,
-                    second
-                );
+                query = new SpanNextQuery(query, second);
             };
             return (SpanQuery) query;
         };
-        
+
         // DistanceQueries
         if (this.constraints.size() == 1) {
             DistanceConstraint constraint = this.constraints.get(0);
@@ -688,15 +732,13 @@
                     if (this.segments.get(i).isExtended())
                         throw new QueryException(613, limitationError);
 
-                    SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
-                    if (sq == null) continue;
+                    SpanQuery sq = (SpanQuery) this.segments.get(i)
+                            .retrieveNode(this.retrieveNode).toQuery();
+                    if (sq == null)
+                        continue;
 
-                    SpanDistanceQuery sdquery = new SpanDistanceQuery(
-                        query,
-                        sq,
-                        constraint,
-                        true
-                    );
+                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query,
+                            sq, constraint, true);
                     query = (SpanQuery) sdquery;
                 };
             }
@@ -709,15 +751,13 @@
                     if (this.segments.get(i).isExtended())
                         throw new QueryException(613, limitationError);
 
-                    SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
-                    if (sq == null) continue;
-                    
-                    SpanDistanceQuery sdquery = new SpanDistanceQuery(
-                        query,
-                        sq,
-                        constraint,
-                        true
-                    );
+                    SpanQuery sq = (SpanQuery) this.segments.get(i)
+                            .retrieveNode(this.retrieveNode).toQuery();
+                    if (sq == null)
+                        continue;
+
+                    SpanDistanceQuery sdquery = new SpanDistanceQuery(query,
+                            sq, constraint, true);
                     query = (SpanQuery) sdquery;
                 };
             };
@@ -732,16 +772,13 @@
             if (this.segments.get(i).isExtended())
                 throw new QueryException(613, limitationError);
 
-            SpanQuery sq = (SpanQuery) this.segments.get(i).retrieveNode(this.retrieveNode).toQuery();
-            if (sq == null) continue;
+            SpanQuery sq = (SpanQuery) this.segments.get(i)
+                    .retrieveNode(this.retrieveNode).toQuery();
+            if (sq == null)
+                continue;
 
-            query = new SpanMultipleDistanceQuery(
-                query,
-                sq,
-                this.constraints,
-                isInOrder,
-                true
-	        );
+            query = new SpanMultipleDistanceQuery(query, sq, this.constraints,
+                    isInOrder, true);
         };
         return (SpanQuery) query;
     };
@@ -782,16 +819,16 @@
                     log.trace("segment {} is problematic", i);
 
                 // [problem][anchor]
-                if (i < (size-1) && this.segments.get(i+1).maybeAnchor()) {
+                if (i < (size - 1) && this.segments.get(i + 1).maybeAnchor()) {
                     if (DEBUG)
                         log.trace("Situation is [problem][anchor]");
 
                     // Insert the solution
                     try {
                         this.segments.set(
-                          i+1,
-                          _merge(this.segments.get(i+1), underScrutiny, false)
-                        );
+                                i + 1,
+                                _merge(this.segments.get(i + 1), underScrutiny,
+                                        false));
                     }
 
                     // An error occurred while solving the problem
@@ -811,16 +848,16 @@
                 }
 
                 // [anchor][problem]
-                else if (i >= 1 && this.segments.get(i-1).maybeAnchor()) {
+                else if (i >= 1 && this.segments.get(i - 1).maybeAnchor()) {
                     if (DEBUG)
                         log.trace("Situation is [anchor][problem]");
 
                     // Insert the solution
                     try {
                         this.segments.set(
-                            i-1,
-                            _merge(this.segments.get(i-1), underScrutiny, true)
-                        );
+                                i - 1,
+                                _merge(this.segments.get(i - 1), underScrutiny,
+                                        true));
                     }
                     catch (QueryException e) {
                         return false;
@@ -870,32 +907,28 @@
     // Todo: Deal with negative and optional!
     // [base=der][base!=Baum]?
     private SpanQueryWrapper _merge (SpanQueryWrapper anchor,
-                                     SpanQueryWrapper problem,
-                                     boolean mergeLeft) throws QueryException {
+            SpanQueryWrapper problem, boolean mergeLeft) throws QueryException {
 
         // Extend to the right - merge to the left
         int direction = mergeLeft ? 1 : -1;
 
         if (DEBUG)
-            log.trace("Will merge two spans to {}",
-                      mergeLeft ? "left" : "right");
-	    
+            log.trace("Will merge two spans to {}", mergeLeft ? "left"
+                    : "right");
+
         // Make empty extension to anchor
         if (problem.isEmpty()) {
             SpanQuery query;
 
             if (DEBUG)
                 log.trace("Problem is empty with class {}",
-                          problem.getClassNumber());
+                        problem.getClassNumber());
 
-            query = new SpanExpansionQuery(
-                anchor.retrieveNode(this.retrieveNode).toQuery(),
-                problem.getMin(),
-                problem.getMax(),
-                direction,
-                problem.hasClass() ? problem.getClassNumber() : (byte) 0,
-                true
-            );
+            query = new SpanExpansionQuery(anchor.retrieveNode(
+                    this.retrieveNode).toQuery(), problem.getMin(),
+                    problem.getMax(), direction,
+                    problem.hasClass() ? problem.getClassNumber() : (byte) 0,
+                    true);
             return new SpanSimpleQueryWrapper(query).isExtended(true);
         }
 
@@ -906,17 +939,14 @@
 
             if (DEBUG)
                 log.trace("Problem is negative with class {}",
-                          problem.getClassNumber());
+                        problem.getClassNumber());
 
-            query = new SpanExpansionQuery(
-                anchor.retrieveNode(this.retrieveNode).toQuery(),
-                problem.retrieveNode(this.retrieveNode).toQuery(),
-                problem.getMin(),
-                problem.getMax(),
-                direction,
-                problem.hasClass() ? problem.getClassNumber() : (byte) 0,
-                true
-            );
+            query = new SpanExpansionQuery(anchor.retrieveNode(
+                    this.retrieveNode).toQuery(), problem.retrieveNode(
+                    this.retrieveNode).toQuery(), problem.getMin(),
+                    problem.getMax(), direction,
+                    problem.hasClass() ? problem.getClassNumber() : (byte) 0,
+                    true);
             return new SpanSimpleQueryWrapper(query).isExtended(true);
         };
 
@@ -926,20 +956,22 @@
         // [base=der][base=baum]?
 
         // [base=der]
-        SpanAlterQueryWrapper saqw =
-            new SpanAlterQueryWrapper(this.field, anchor);
+        SpanAlterQueryWrapper saqw = new SpanAlterQueryWrapper(this.field,
+                anchor);
 
         // [base=der]
-        SpanSequenceQueryWrapper ssqw =
-            new SpanSequenceQueryWrapper(this.field, anchor);
+        SpanSequenceQueryWrapper ssqw = new SpanSequenceQueryWrapper(
+                this.field, anchor);
 
         // [base=der][base=baum]
         if (mergeLeft)
-            ssqw.append(new SpanSimpleQueryWrapper(problem.retrieveNode(this.retrieveNode).toQuery()));
+            ssqw.append(new SpanSimpleQueryWrapper(problem.retrieveNode(
+                    this.retrieveNode).toQuery()));
         // [base=baum][base=der]
         else
-            ssqw.prepend(new SpanSimpleQueryWrapper(problem.retrieveNode(this.retrieveNode).toQuery()));
-	
+            ssqw.prepend(new SpanSimpleQueryWrapper(problem.retrieveNode(
+                    this.retrieveNode).toQuery()));
+
         saqw.or(ssqw);
 
         return (SpanQueryWrapper) saqw;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
index ad72570..28edbf6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSimpleQueryWrapper.java
@@ -7,25 +7,30 @@
 public class SpanSimpleQueryWrapper extends SpanQueryWrapper {
     private SpanQuery query;
 
+
     public SpanSimpleQueryWrapper (String field, String term) {
         this.isNull = false;
         this.query = new SpanTermQuery(new Term(field, term));
     };
 
-	public SpanSimpleQueryWrapper(String field, String term, boolean value) {
-		this(field, term);
-		this.isNegative = !value;
-	}
+
+    public SpanSimpleQueryWrapper (String field, String term, boolean value) {
+        this(field, term);
+        this.isNegative = !value;
+    }
+
 
     public SpanSimpleQueryWrapper (SpanQuery query) {
         this.isNull = false;
         this.query = query;
     };
 
+
     public SpanQuery toQuery () {
         return this.query;
     };
 
+
     public SpanSimpleQueryWrapper isExtended (boolean extended) {
         this.isExtended = true;
         return this;
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
index 5ae86c8..ec61e70 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanSubspanQueryWrapper.java
@@ -14,128 +14,138 @@
  */
 public class SpanSubspanQueryWrapper extends SpanQueryWrapper {
 
-	private SpanQueryWrapper subquery;
-	private int startOffset, length;
+    private SpanQueryWrapper subquery;
+    private int startOffset, length;
 
-	private final static Logger log = LoggerFactory
-			.getLogger(SpanSubspanQueryWrapper.class);
+    private final static Logger log = LoggerFactory
+            .getLogger(SpanSubspanQueryWrapper.class);
 
-	// This advices the java compiler to ignore all loggings
-	public static final boolean DEBUG = false;
-
-	public SpanSubspanQueryWrapper(SpanQueryWrapper sqw, int startOffset,
-			int length) throws QueryException {
-		if (length < 0) {
-			throw new QueryException(
-					"SpanSubspanQuery cannot have length less than 0.");
-		}
-
-		this.subquery = sqw;
-		if (subquery != null) {
-			this.isNull = false;
-		} else
-			return;
-
-		this.startOffset = startOffset;
-		this.length = length;
-
-		if (subquery.isEmpty()) {
-			handleEmptySubquery();
-		} 
-		else if (subquery.isNegative()) {
-			handleNegativeSubquery();
-		}
-	}
-
-	private void handleNegativeSubquery() {
-		this.isNegative = true;
-		if (startOffset < 0) {
-			int max = Math.abs(startOffset) + length;
-			subquery.setMax(max);
-			startOffset = max + startOffset;
-		} 
-		else {
-			int endOffset = startOffset + length;
-			if (subquery.getMax() > endOffset) {
-				subquery.setMax(startOffset + length);
-			}
-		}
-		subquery.setMin(startOffset);
-		subquery.isOptional = false;
-
-		max = subquery.max - subquery.min;
-		min = max;
-	}
-
-	private void handleEmptySubquery() {
-		if (subquery instanceof SpanRepetitionQueryWrapper) {
-			this.isEmpty = true;
-		}
-		// subspan([]{,5}, 2) -> subspan([]{2,5}, 2)
-		// e.g. subspan([]{0,6}, 8)
-		if (startOffset >= subquery.getMax()) {
-			this.isNull = true;
-			return;
-		}
-		if (startOffset < 0) {
-			startOffset = subquery.getMax() + startOffset;
-		}
-		subquery.isOptional = false;
-		subquery.setMin(startOffset);
-
-		// subspan([]{2,}, 2,5) -> subspan([]{2,5}, 2,5)
-		int endOffset = startOffset + length;
-		if (length == 0) {
-			length = subquery.getMax() - startOffset;
-		}
-		else if (subquery.getMax() > endOffset || subquery.getMax() == 0) {
-			subquery.setMax(endOffset);
-		}
-		else if (subquery.getMax() < endOffset) {
-			length = subquery.max - subquery.min;
-		}
-
-		setMax(subquery.max);
-		setMin(subquery.min);
-	}
-
-	@Override
-	public SpanQuery toQuery() throws QueryException {
-		if (this.isNull()) { return null; }
-
-		SpanQuery sq = subquery.retrieveNode(this.retrieveNode).toQuery();
-		if (sq == null) return null;
-		if (sq instanceof SpanTermQuery) {
-			if (subquery.isNegative()) {
-				return sq;
-			}
-			else if ((startOffset == 0 || startOffset == -1) &&
-					(length == 1 || length == 0)) {
-				// if (DEBUG) log.warn("Not SpanSubspanQuery. " +
-				// "Creating only a SpanQuery for the subquery.");
-				return sq;
-			}
-			return null;
-		}
-
-		return new SpanSubspanQuery(sq, startOffset, length, true);
-	}
-
-	@Override
-	public boolean isNegative() {
-		return this.subquery.isNegative();
-	};
-
-	@Override
-	public boolean isOptional() {
-		if (startOffset > 0)
-			return false;
-		return this.subquery.isOptional();
-	};
+    // This advices the java compiler to ignore all loggings
+    public static final boolean DEBUG = false;
 
 
-	@Override
-	public boolean maybeUnsorted () {
+    public SpanSubspanQueryWrapper (SpanQueryWrapper sqw, int startOffset,
+                                    int length) throws QueryException {
+        if (length < 0) {
+            throw new QueryException(
+                    "SpanSubspanQuery cannot have length less than 0.");
+        }
+
+        this.subquery = sqw;
+        if (subquery != null) {
+            this.isNull = false;
+        }
+        else
+            return;
+
+        this.startOffset = startOffset;
+        this.length = length;
+
+        if (subquery.isEmpty()) {
+            handleEmptySubquery();
+        }
+        else if (subquery.isNegative()) {
+            handleNegativeSubquery();
+        }
+    }
+
+
+    private void handleNegativeSubquery () {
+        this.isNegative = true;
+        if (startOffset < 0) {
+            int max = Math.abs(startOffset) + length;
+            subquery.setMax(max);
+            startOffset = max + startOffset;
+        }
+        else {
+            int endOffset = startOffset + length;
+            if (subquery.getMax() > endOffset) {
+                subquery.setMax(startOffset + length);
+            }
+        }
+        subquery.setMin(startOffset);
+        subquery.isOptional = false;
+
+        max = subquery.max - subquery.min;
+        min = max;
+    }
+
+
+    private void handleEmptySubquery () {
+        if (subquery instanceof SpanRepetitionQueryWrapper) {
+            this.isEmpty = true;
+        }
+        // subspan([]{,5}, 2) -> subspan([]{2,5}, 2)
+        // e.g. subspan([]{0,6}, 8)
+        if (startOffset >= subquery.getMax()) {
+            this.isNull = true;
+            return;
+        }
+        if (startOffset < 0) {
+            startOffset = subquery.getMax() + startOffset;
+        }
+        subquery.isOptional = false;
+        subquery.setMin(startOffset);
+
+        // subspan([]{2,}, 2,5) -> subspan([]{2,5}, 2,5)
+        int endOffset = startOffset + length;
+        if (length == 0) {
+            length = subquery.getMax() - startOffset;
+        }
+        else if (subquery.getMax() > endOffset || subquery.getMax() == 0) {
+            subquery.setMax(endOffset);
+        }
+        else if (subquery.getMax() < endOffset) {
+            length = subquery.max - subquery.min;
+        }
+
+        setMax(subquery.max);
+        setMin(subquery.min);
+    }
+
+
+    @Override
+    public SpanQuery toQuery () throws QueryException {
+        if (this.isNull()) {
+            return null;
+        }
+
+        SpanQuery sq = subquery.retrieveNode(this.retrieveNode).toQuery();
+        if (sq == null)
+            return null;
+        if (sq instanceof SpanTermQuery) {
+            if (subquery.isNegative()) {
+                return sq;
+            }
+            else if ((startOffset == 0 || startOffset == -1)
+                    && (length == 1 || length == 0)) {
+                // if (DEBUG) log.warn("Not SpanSubspanQuery. " +
+                // "Creating only a SpanQuery for the subquery.");
+                return sq;
+            }
+            return null;
+        }
+
+        return new SpanSubspanQuery(sq, startOffset, length, true);
+    }
+
+
+    @Override
+    public boolean isNegative () {
+        return this.subquery.isNegative();
+    };
+
+
+    @Override
+    public boolean isOptional () {
+        if (startOffset > 0)
+            return false;
+        return this.subquery.isOptional();
+    };
+
+
+    @Override
+    public boolean maybeUnsorted () {
         return this.subquery.maybeUnsorted();
     };
 }
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 4332856..6eb6bdf 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
@@ -10,12 +10,15 @@
 
 public class SpanWildcardQueryWrapper extends SpanQueryWrapper {
     private SpanQuery query;
-    
+
+
     public SpanWildcardQueryWrapper (String field, String wc) {
         this(field, wc, false);
     };
 
-    public SpanWildcardQueryWrapper (String field, String wc, boolean caseinsensitive) {
+
+    public SpanWildcardQueryWrapper (String field, String wc,
+                                     boolean caseinsensitive) {
         if (caseinsensitive) {
             if (wc.startsWith("s:")) {
                 wc = wc.replaceFirst("s:", "i:");
@@ -23,13 +26,15 @@
             wc = wc.toLowerCase();
         };
         WildcardQuery wcquery = new WildcardQuery(new Term(field, wc));
-        query = new SpanMultiTermQueryWrapper<WildcardQuery>( wcquery );
+        query = new SpanMultiTermQueryWrapper<WildcardQuery>(wcquery);
     };
 
-    public SpanQuery toQuery() {
+
+    public SpanQuery toQuery () {
         return this.query;
     };
 
+
     public boolean isNull () {
         return false;
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
index 7b633c0..8916bda 100644
--- a/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/query/wrap/SpanWithAttributeQueryWrapper.java
@@ -18,195 +18,206 @@
  * */
 public class SpanWithAttributeQueryWrapper extends SpanQueryWrapper {
 
-	private SpanQueryWrapper withIdQueryWrapper = null;
-	private SpanQueryWrapper attrQueryWrapper = null;
-	private List<SpanQueryWrapper> queryWrapperList = null;
-	private boolean isSingleAttribute = false;
+    private SpanQueryWrapper withIdQueryWrapper = null;
+    private SpanQueryWrapper attrQueryWrapper = null;
+    private List<SpanQueryWrapper> queryWrapperList = null;
+    private boolean isSingleAttribute = false;
 
-	public SpanWithAttributeQueryWrapper(SpanQueryWrapper attrQuery)
-			throws QueryException {
-		if (attrQuery != null) isNull = false;
-		if (attrQuery.isEmpty()) {
-			isEmpty = true;
-			return;
-		}
-		if (attrQuery.isNegative) {
-			throw new QueryException("The query requires a positive attribute.");
-		}
-		this.attrQueryWrapper = attrQuery;
-		this.isSingleAttribute = true;
-	}
 
-	public SpanWithAttributeQueryWrapper(List<SpanQueryWrapper> attrList)
-			throws QueryException {
+    public SpanWithAttributeQueryWrapper (SpanQueryWrapper attrQuery)
+            throws QueryException {
+        if (attrQuery != null)
+            isNull = false;
+        if (attrQuery.isEmpty()) {
+            isEmpty = true;
+            return;
+        }
+        if (attrQuery.isNegative) {
+            throw new QueryException("The query requires a positive attribute.");
+        }
+        this.attrQueryWrapper = attrQuery;
+        this.isSingleAttribute = true;
+    }
 
-		if (attrList != null) isNull = false;
-		if (attrList.isEmpty()) {
-			throw new QueryException("No attribute is defined.");
-		}
 
-		boolean isAllNegative = true;
-		for (SpanQueryWrapper sqw : attrList) {
-			if (sqw == null) {
-				isNull = true;
-				return;
-			}
-			if (sqw.isEmpty) {
-				isEmpty = true;
-				return;
-			}
-			if (!sqw.isNegative) {
-				isAllNegative = false;
-			}
-		}
-		if (isAllNegative) {
-			throw new QueryException("No positive attribute is defined.");
-		}
-		this.queryWrapperList = attrList;
-	}
+    public SpanWithAttributeQueryWrapper (List<SpanQueryWrapper> attrList)
+            throws QueryException {
 
-	public SpanWithAttributeQueryWrapper(SpanQueryWrapper withIdQuery,
-			SpanQueryWrapper attrQuery) {
+        if (attrList != null)
+            isNull = false;
+        if (attrList.isEmpty()) {
+            throw new QueryException("No attribute is defined.");
+        }
 
-		if (withIdQuery != null || attrQuery != null) {
-			isNull = false;
-		}
-		if (withIdQuery.isEmpty || attrQuery.isEmpty()) {
-			isEmpty = true;
-			return;
-		}
+        boolean isAllNegative = true;
+        for (SpanQueryWrapper sqw : attrList) {
+            if (sqw == null) {
+                isNull = true;
+                return;
+            }
+            if (sqw.isEmpty) {
+                isEmpty = true;
+                return;
+            }
+            if (!sqw.isNegative) {
+                isAllNegative = false;
+            }
+        }
+        if (isAllNegative) {
+            throw new QueryException("No positive attribute is defined.");
+        }
+        this.queryWrapperList = attrList;
+    }
 
-		this.attrQueryWrapper = attrQuery;
-		this.withIdQueryWrapper = withIdQuery;
-		this.isSingleAttribute = true;
-	}
 
-	public SpanWithAttributeQueryWrapper(SpanQueryWrapper withIdQuery,
-			List<SpanQueryWrapper> attrList) {
+    public SpanWithAttributeQueryWrapper (SpanQueryWrapper withIdQuery,
+                                          SpanQueryWrapper attrQuery) {
 
-		if (withIdQuery != null || attrList != null) {
-			isNull = false;
-		}
-		if (withIdQuery.isEmpty) {
-			isEmpty = true;
-			return;
-		}
-		// if (attrList.isEmpty()) {
-			// not withattribute query, just a normal query
-		// }
+        if (withIdQuery != null || attrQuery != null) {
+            isNull = false;
+        }
+        if (withIdQuery.isEmpty || attrQuery.isEmpty()) {
+            isEmpty = true;
+            return;
+        }
 
-		for (SpanQueryWrapper sqw : attrList) {
-			if (sqw == null) {
-				isNull = true;
-				return;
-			}
-			if (sqw.isEmpty) {
-				isEmpty = true;
-				return;
-			}
-		}
-		
-		this.queryWrapperList = attrList;
-		this.withIdQueryWrapper = withIdQuery;
-	}
+        this.attrQueryWrapper = attrQuery;
+        this.withIdQueryWrapper = withIdQuery;
+        this.isSingleAttribute = true;
+    }
 
-	@Override
-	public SpanQuery toQuery() throws QueryException {
 
-		if (isNull || isEmpty) return null;		
-		if (withIdQueryWrapper != null){
-			return createSpecificSpanWithAttributeQuery();
-		}
-		else{
-			return createArbitrarySpanWithAttributeQuery(); 
-		}
-	}
-	
-	private SpanQuery createSpecificSpanWithAttributeQuery()
-			throws QueryException {
-		SpanWithIdQuery withIdQuery = (SpanWithIdQuery) withIdQueryWrapper
-				.toQuery();
-		if (withIdQuery == null) {
-			isNull = true;
-			return null;
-		}
-		if (isSingleAttribute) {
-			return createSpanWithSingleAttributeQuery(withIdQuery);
-		}
-		else if (queryWrapperList.isEmpty()) {
-			return withIdQuery;
-		}
-		else{
-			return createSpanWithAttributeListQuery(withIdQuery);
-		}
-	}
-	
-	private SpanWithAttributeQuery createSpanWithSingleAttributeQuery(
-			SpanWithIdQuery withIdQuery)
-			throws QueryException {
-		SpanAttributeQuery attrQuery = createSpanAttributeQuery(this.attrQueryWrapper);
-		if (attrQuery != null) {
-			if (withIdQuery != null) {
-				return new SpanWithAttributeQuery(withIdQuery, attrQuery, true);
-			} 
-			else {
-				return new SpanWithAttributeQuery(attrQuery, true);
-			}
-		}
-		isNull = true;
-		return null;
-	}
+    public SpanWithAttributeQueryWrapper (SpanQueryWrapper withIdQuery,
+                                          List<SpanQueryWrapper> attrList) {
 
-	private SpanAttributeQuery createSpanAttributeQuery(
-			SpanQueryWrapper attrQueryWrapper) throws QueryException {
-		SpanQuery sq = attrQueryWrapper.toQuery();
-		if (sq != null) {
-			if (sq instanceof SpanTermQuery) {
-				return new SpanAttributeQuery((SpanTermQuery) sq,
-						attrQueryWrapper.isNegative, true);
-			} 
-			else {
-				throw new IllegalArgumentException(
-						"The subquery is not a SpanTermQuery.");
-			}
-		}
-		return null;
-	}
+        if (withIdQuery != null || attrList != null) {
+            isNull = false;
+        }
+        if (withIdQuery.isEmpty) {
+            isEmpty = true;
+            return;
+        }
+        // if (attrList.isEmpty()) {
+        // not withattribute query, just a normal query
+        // }
 
-	private SpanWithAttributeQuery createSpanWithAttributeListQuery(
-			SpanWithIdQuery withIdQuery)
-			throws QueryException {
-		List<SpanQuery> attrQueries = new ArrayList<SpanQuery>();
-		SpanQuery attrQuery = null;
-		for (SpanQueryWrapper sqw : queryWrapperList) {
-			attrQuery = createSpanAttributeQuery(sqw);
-			if (attrQuery == null) {
-				isNull = true;
-				return null;
-			}
-			attrQueries.add(attrQuery);
-		}
-		
-		if (withIdQuery != null) {
-			return new SpanWithAttributeQuery(withIdQuery, attrQueries, true);
-		} 
-		else {
-			return new SpanWithAttributeQuery(attrQueries, true);
-		}
-	}
+        for (SpanQueryWrapper sqw : attrList) {
+            if (sqw == null) {
+                isNull = true;
+                return;
+            }
+            if (sqw.isEmpty) {
+                isEmpty = true;
+                return;
+            }
+        }
 
-	private SpanQuery createArbitrarySpanWithAttributeQuery()
-			throws QueryException {
-		if (isSingleAttribute) {
-			return createSpanWithSingleAttributeQuery(null);
-		}
-		else if (queryWrapperList.isEmpty()) {
-			throw new QueryException("No attribute is defined.");
-		}
-		else{
-			return createSpanWithAttributeListQuery(null);
-		}				
-	}
+        this.queryWrapperList = attrList;
+        this.withIdQueryWrapper = withIdQuery;
+    }
+
+
+    @Override
+    public SpanQuery toQuery () throws QueryException {
+
+        if (isNull || isEmpty)
+            return null;
+        if (withIdQueryWrapper != null) {
+            return createSpecificSpanWithAttributeQuery();
+        }
+        else {
+            return createArbitrarySpanWithAttributeQuery();
+        }
+    }
+
+
+    private SpanQuery createSpecificSpanWithAttributeQuery ()
+            throws QueryException {
+        SpanWithIdQuery withIdQuery = (SpanWithIdQuery) withIdQueryWrapper
+                .toQuery();
+        if (withIdQuery == null) {
+            isNull = true;
+            return null;
+        }
+        if (isSingleAttribute) {
+            return createSpanWithSingleAttributeQuery(withIdQuery);
+        }
+        else if (queryWrapperList.isEmpty()) {
+            return withIdQuery;
+        }
+        else {
+            return createSpanWithAttributeListQuery(withIdQuery);
+        }
+    }
+
+
+    private SpanWithAttributeQuery createSpanWithSingleAttributeQuery (
+            SpanWithIdQuery withIdQuery) throws QueryException {
+        SpanAttributeQuery attrQuery = createSpanAttributeQuery(this.attrQueryWrapper);
+        if (attrQuery != null) {
+            if (withIdQuery != null) {
+                return new SpanWithAttributeQuery(withIdQuery, attrQuery, true);
+            }
+            else {
+                return new SpanWithAttributeQuery(attrQuery, true);
+            }
+        }
+        isNull = true;
+        return null;
+    }
+
+
+    private SpanAttributeQuery createSpanAttributeQuery (
+            SpanQueryWrapper attrQueryWrapper) throws QueryException {
+        SpanQuery sq = attrQueryWrapper.toQuery();
+        if (sq != null) {
+            if (sq instanceof SpanTermQuery) {
+                return new SpanAttributeQuery((SpanTermQuery) sq,
+                        attrQueryWrapper.isNegative, true);
+            }
+            else {
+                throw new IllegalArgumentException(
+                        "The subquery is not a SpanTermQuery.");
+            }
+        }
+        return null;
+    }
+
+
+    private SpanWithAttributeQuery createSpanWithAttributeListQuery (
+            SpanWithIdQuery withIdQuery) throws QueryException {
+        List<SpanQuery> attrQueries = new ArrayList<SpanQuery>();
+        SpanQuery attrQuery = null;
+        for (SpanQueryWrapper sqw : queryWrapperList) {
+            attrQuery = createSpanAttributeQuery(sqw);
+            if (attrQuery == null) {
+                isNull = true;
+                return null;
+            }
+            attrQueries.add(attrQuery);
+        }
+
+        if (withIdQuery != null) {
+            return new SpanWithAttributeQuery(withIdQuery, attrQueries, true);
+        }
+        else {
+            return new SpanWithAttributeQuery(attrQueries, true);
+        }
+    }
+
+
+    private SpanQuery createArbitrarySpanWithAttributeQuery ()
+            throws QueryException {
+        if (isSingleAttribute) {
+            return createSpanWithSingleAttributeQuery(null);
+        }
+        else if (queryWrapperList.isEmpty()) {
+            throw new QueryException("No attribute is defined.");
+        }
+        else {
+            return createSpanWithAttributeListQuery(null);
+        }
+    }
 
 
 }
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 a04b33a..904d771 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
@@ -62,7 +62,9 @@
     private SpanQueryWrapper wrap;
     private byte flag;
 
-    public SpanWithinQueryWrapper (SpanQueryWrapper element, SpanQueryWrapper wrap) {
+
+    public SpanWithinQueryWrapper (SpanQueryWrapper element,
+                                   SpanQueryWrapper wrap) {
         this.element = element;
         this.wrap = wrap;
 
@@ -74,8 +76,8 @@
     };
 
 
-    public SpanWithinQueryWrapper
-        (SpanQueryWrapper element, SpanQueryWrapper wrap, byte flag) {
+    public SpanWithinQueryWrapper (SpanQueryWrapper element,
+                                   SpanQueryWrapper wrap, byte flag) {
         this.element = element;
         this.wrap = wrap;
         this.flag = flag;
@@ -90,14 +92,12 @@
     public SpanQuery toQuery () throws QueryException {
         if (this.isNull)
             return (SpanQuery) null;
-	
+
         // TODO: if (wrap.isNegative())
 
-        return new SpanWithinQuery(
-            this.element.retrieveNode(this.retrieveNode).toQuery(),
-            this.wrap.retrieveNode(this.retrieveNode).toQuery(),
-            this.flag
-        );
+        return new SpanWithinQuery(this.element.retrieveNode(this.retrieveNode)
+                .toQuery(),
+                this.wrap.retrieveNode(this.retrieveNode).toQuery(), this.flag);
     };
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/response/Match.java b/src/main/java/de/ids_mannheim/korap/response/Match.java
index db32550..17f6cae 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.response;
+
 import java.util.*;
 import java.io.*;
 
@@ -43,7 +44,7 @@
 
 /**
  * Representation of Matches in a Result.
- *
+ * 
  * @author Nils Diewald
  * @see Result
  */
@@ -68,8 +69,7 @@
     public int startPos, endPos = -1;
 
     @JsonIgnore
-    public int potentialStartPosChar = -1,
-	       potentialEndPosChar   = -1;
+    public int potentialStartPosChar = -1, potentialEndPosChar = -1;
 
     private String error = null;
     private String version;
@@ -78,24 +78,20 @@
     @JsonIgnore
     public int localDocID = -1;
 
-    private HashMap<Integer, String>   annotationNumber = new HashMap<>(16);
-    private HashMap<Integer, Relation> relationNumber   = new HashMap<>(16);
-    private HashMap<Integer, Integer>  identifierNumber = new HashMap<>(16);
+    private HashMap<Integer, String> annotationNumber = new HashMap<>(16);
+    private HashMap<Integer, Relation> relationNumber = new HashMap<>(16);
+    private HashMap<Integer, Integer> identifierNumber = new HashMap<>(16);
 
     // -1 is match highlight
     int annotationNumberCounter = 256;
-    int relationNumberCounter   = 2048;
+    int relationNumberCounter = 2048;
     int identifierNumberCounter = -2;
 
-    private String tempSnippet,
-	           snippetHTML,
-	           snippetBrackets,
-	           identifier;
+    private String tempSnippet, snippetHTML, snippetBrackets, identifier;
 
     private HighlightCombinator snippetArray;
 
-    public boolean startMore = true,
-	           endMore = true;
+    public boolean startMore = true, endMore = true;
 
     private Collection<byte[]> payload;
     private ArrayList<Highlight> highlight;
@@ -104,298 +100,317 @@
     private PositionsToOffset positionsToOffset;
     private boolean processed = false;
 
+
     /**
      * Constructs a new Match object.
      * Todo: Maybe that's not necessary!
-     *
-     * @param pto The PositionsToOffset object, containing relevant
+     * 
+     * @param pto
+     *            The PositionsToOffset object, containing relevant
      *            positional information for highlighting
-     * @param localDocID Document ID based on the atomic reader.
-     * @param startPos Start position of the match in the document.
-     * @param endPos End position of the match in the document.
-     *
+     * @param localDocID
+     *            Document ID based on the atomic reader.
+     * @param startPos
+     *            Start position of the match in the document.
+     * @param endPos
+     *            End position of the match in the document.
+     * 
      * @see #snippetHTML()
      * @see #snippetBrackets()
      * @see PositionsToOffset
      */
-    public Match (PositionsToOffset pto,
-		       int localDocID,
-		       int startPos,
-		       int endPos) {
-	this.positionsToOffset = pto;
-	this.localDocID = localDocID;
-	this.startPos   = startPos;
-	this.endPos     = endPos;
+    public Match (PositionsToOffset pto, int localDocID, int startPos,
+                  int endPos) {
+        this.positionsToOffset = pto;
+        this.localDocID = localDocID;
+        this.startPos = startPos;
+        this.endPos = endPos;
     };
 
-    
+
     /**
      * Constructs a new Match object.
      */
     public Match () {};
 
-    
+
     /**
      * Constructs a new Match object.
-     *
-     * @param idString Match identifier string as provided by Result.
-     * @param includeHighlights Boolean value indicating if possible provided
-     *        highlight information should be ignored or not.
+     * 
+     * @param idString
+     *            Match identifier string as provided by Result.
+     * @param includeHighlights
+     *            Boolean value indicating if possible provided
+     *            highlight information should be ignored or not.
      */
     public Match (String idString, boolean includeHighlights) {
-	MatchIdentifier id = new MatchIdentifier(idString);
-	if (id.getStartPos() > -1) {
-	    this.setCorpusID(id.getCorpusID());
-	    this.setDocID(id.getDocID());
-	    this.setStartPos(id.getStartPos());
-	    this.setEndPos(id.getEndPos());
+        MatchIdentifier id = new MatchIdentifier(idString);
+        if (id.getStartPos() > -1) {
+            this.setCorpusID(id.getCorpusID());
+            this.setDocID(id.getDocID());
+            this.setStartPos(id.getStartPos());
+            this.setEndPos(id.getEndPos());
 
-	    if (includeHighlights)
-		for (int[] pos : id.getPos()) {
-		    if (pos[0] < id.getStartPos() || pos[1] > id.getEndPos())
-			continue;
-		    
-		    this.addHighlight(pos[0], pos[1], pos[2]);
-		};
-	};
+            if (includeHighlights)
+                for (int[] pos : id.getPos()) {
+                    if (pos[0] < id.getStartPos() || pos[1] > id.getEndPos())
+                        continue;
+
+                    this.addHighlight(pos[0], pos[1], pos[2]);
+                };
+        };
     };
 
-    
+
     /**
      * Private class of highlights.
-     */   
+     */
     private class Highlight {
-	public int start, end;
-	public int number = -1;
+        public int start, end;
+        public int number = -1;
 
-	// Relational highlight
-       	public Highlight (int start, int end, String annotation, int ref) {
-	    this.start = start;
-	    this.end   = end;
-	    // TODO: This can overflow!
-	    this.number = relationNumberCounter++;
-	    relationNumber.put(this.number, new Relation(annotation, ref));
-	};
 
-	// Span highlight
-	public Highlight (int start, int end, String annotation) {
-	    this.start = start;
-	    this.end   = end;
-	    // TODO: This can overflow!
-	    if (annotationNumberCounter < 2048) {
-		this.number = annotationNumberCounter++;
-		annotationNumber.put(this.number, annotation);
-	    };
-	};
+        // Relational highlight
+        public Highlight (int start, int end, String annotation, int ref) {
+            this.start = start;
+            this.end = end;
+            // TODO: This can overflow!
+            this.number = relationNumberCounter++;
+            relationNumber.put(this.number, new Relation(annotation, ref));
+        };
 
-	// Simple highlight
-	public Highlight (int start, int end, int number) {
-	    this.start  = start;
-	    this.end    = end;
-	    this.number = number;
-	};
+
+        // Span highlight
+        public Highlight (int start, int end, String annotation) {
+            this.start = start;
+            this.end = end;
+            // TODO: This can overflow!
+            if (annotationNumberCounter < 2048) {
+                this.number = annotationNumberCounter++;
+                annotationNumber.put(this.number, annotation);
+            };
+        };
+
+
+        // Simple highlight
+        public Highlight (int start, int end, int number) {
+            this.start = start;
+            this.end = end;
+            this.number = number;
+        };
     };
 
-    
+
     // TODO: Here are offsets and highlight offsets!
     // <> payloads have 12 bytes (iii) or 8!?
     // highlightoffsets have 11 bytes (iis)!
     public void addPayload (List<byte[]> payload) {
 
-	if (DEBUG)
-	    log.trace("Add payloads to match");
+        if (DEBUG)
+            log.trace("Add payloads to match");
 
-	// Reverse to make embedding of highlights correct
-	Collections.reverse(payload);
-	try {
-	    ByteBuffer bb = ByteBuffer.allocate(10);
+        // Reverse to make embedding of highlights correct
+        Collections.reverse(payload);
+        try {
+            ByteBuffer bb = ByteBuffer.allocate(10);
 
-	    // TODO: REVERSE ITERATOR!
-	    for (byte[] b : payload) {
+            // TODO: REVERSE ITERATOR!
+            for (byte[] b : payload) {
 
-		if (DEBUG)
-		    log.trace("Found a payload with length {}", b.length);
+                if (DEBUG)
+                    log.trace("Found a payload with length {}", b.length);
 
-		// Todo element searches!
+                // Todo element searches!
 
-		// Highlights!
-		if (b.length == 9) {
-		    bb.put(b);
-		    bb.rewind();
+                // Highlights!
+                if (b.length == 9) {
+                    bb.put(b);
+                    bb.rewind();
 
-		    int start   = bb.getInt();
-		    int end     = bb.getInt();
-		    byte number = bb.get();
+                    int start = bb.getInt();
+                    int end = bb.getInt();
+                    byte number = bb.get();
 
-		    if (DEBUG)
-			log.trace(
-			    "Have a highlight of class {} in {}-{} inside of {}-{}",
-			    number,
-			    start,
-			    end,
-			    this.getStartPos(),
-			    this.getEndPos()
-			);
+                    if (DEBUG)
+                        log.trace(
+                                "Have a highlight of class {} in {}-{} inside of {}-{}",
+                                number, start, end, this.getStartPos(),
+                                this.getEndPos());
 
-		    // Ignore classes out of match range and set by the system
-		    if ((number & 0xFF) <= 128 &&
-			start >= this.getStartPos() &&
-			end <= this.getEndPos())
-			this.addHighlight(start, end - 1, number);
-		}
+                    // Ignore classes out of match range and set by the system
+                    if ((number & 0xFF) <= 128 && start >= this.getStartPos()
+                            && end <= this.getEndPos())
+                        this.addHighlight(start, end - 1, number);
+                }
 
-		// Element payload for match!
-		// This MAY BE the correct match
-		else if (b.length == 8) {
-		    bb.put(b);
-		    bb.rewind();
+                // Element payload for match!
+                // This MAY BE the correct match
+                else if (b.length == 8) {
+                    bb.put(b);
+                    bb.rewind();
 
-		    if (this.potentialStartPosChar == -1) {
-			this.potentialStartPosChar = bb.getInt(0);
-		    }
-		    else {
-			if (bb.getInt(0) < this.potentialStartPosChar)
-			    this.potentialStartPosChar = bb.getInt(0);
-		    };
-		    
-		    if (bb.getInt(4) > this.potentialEndPosChar)
-			this.potentialEndPosChar = bb.getInt(4);
+                    if (this.potentialStartPosChar == -1) {
+                        this.potentialStartPosChar = bb.getInt(0);
+                    }
+                    else {
+                        if (bb.getInt(0) < this.potentialStartPosChar)
+                            this.potentialStartPosChar = bb.getInt(0);
+                    };
 
-		    if (DEBUG)
-			log.trace(
-			    "Element payload from {} to {}",
-			    this.potentialStartPosChar,
-			    this.potentialEndPosChar
-			);
-		};
-	
-		// Clear bytebuffer
-		bb.clear();
-	    };
-	}
+                    if (bb.getInt(4) > this.potentialEndPosChar)
+                        this.potentialEndPosChar = bb.getInt(4);
 
-	catch (Exception e) {
-	    log.error(e.getMessage());
-	}
+                    if (DEBUG)
+                        log.trace("Element payload from {} to {}",
+                                this.potentialStartPosChar,
+                                this.potentialEndPosChar);
+                };
+
+                // Clear bytebuffer
+                bb.clear();
+            };
+        }
+
+        catch (Exception e) {
+            log.error(e.getMessage());
+        }
     };
 
 
     /**
      * Insert a highlight for the snippet view by means of positional
      * offsets and an optional class number.
-     *
-     * @param start  Integer value of a span's positional start offset.
-     * @param end    Integer value of a span's positional end offset.
-     * @param number Optional class number of the highlight.
+     * 
+     * @param start
+     *            Integer value of a span's positional start offset.
+     * @param end
+     *            Integer value of a span's positional end offset.
+     * @param number
+     *            Optional class number of the highlight.
      */
     public void addHighlight (int start, int end) {
-	this.addHighlight(new Highlight(start, end, (int) 0));
+        this.addHighlight(new Highlight(start, end, (int) 0));
     };
 
+
     public void addHighlight (int start, int end, byte number) {
-	this.addHighlight(new Highlight(start, end, (int) number));
+        this.addHighlight(new Highlight(start, end, (int) number));
     };
 
+
     public void addHighlight (int start, int end, short number) {
-	this.addHighlight(new Highlight(start, end, (int) number));
+        this.addHighlight(new Highlight(start, end, (int) number));
     };
 
+
     public void addHighlight (int start, int end, int number) {
-	this.addHighlight(new Highlight(start, end, number));
+        this.addHighlight(new Highlight(start, end, number));
     };
 
-    
+
     /**
      * Insert a highlight for the snippet view.
-     *
-     * @param hl A highlight object to add to the match.
+     * 
+     * @param hl
+     *            A highlight object to add to the match.
      */
     public void addHighlight (Highlight hl) {
 
-	if (this.highlight == null)
-	    this.highlight = new ArrayList<Highlight>(16);
+        if (this.highlight == null)
+            this.highlight = new ArrayList<Highlight>(16);
 
-	if (DEBUG)
-	    log.trace("Add highlight from pos {}-{} of class {}",
-		      hl.start, hl.end, hl.number);
+        if (DEBUG)
+            log.trace("Add highlight from pos {}-{} of class {}", hl.start,
+                    hl.end, hl.number);
 
-	// Reset the fetched match data
-	this._reset();
+        // Reset the fetched match data
+        this._reset();
 
-	this.highlight.add(hl);
+        this.highlight.add(hl);
     };
 
 
     /**
      * Insert a textual annotation for the snippet view by
      * means of positional offsets and an annotation string.
-     *
-     * @param start      Integer value of a span's positional start offset.
-     * @param end        Integer value of a span's positional end offset.
-     * @param annotation Annotation string.
+     * 
+     * @param start
+     *            Integer value of a span's positional start offset.
+     * @param end
+     *            Integer value of a span's positional end offset.
+     * @param annotation
+     *            Annotation string.
      */
     public void addAnnotation (int start, int end, String annotation) {
-	this.addHighlight(new Highlight(start, end, annotation));
+        this.addHighlight(new Highlight(start, end, annotation));
     };
 
-    
+
     /**
      * Insert an annotated relation for the snippet view by
-     * means of relational participant positions and an annotation string.
-     *
-     * @param src        Integer value of a span's positional source object.
-     * @param target     Integer value of a span's positional target object.
-     * @param annotation Annotation string.
+     * means of relational participant positions and an annotation
+     * string.
+     * 
+     * @param src
+     *            Integer value of a span's positional source object.
+     * @param target
+     *            Integer value of a span's positional target object.
+     * @param annotation
+     *            Annotation string.
      */
     public void addRelation (int src, int target, String annotation) {
-	this.addHighlight(new Highlight(src, src, annotation, target));
-	int id = identifierNumberCounter--;
-	identifierNumber.put(id, target);
-	this.addHighlight(new Highlight(target, target, id));
+        this.addHighlight(new Highlight(src, src, annotation, target));
+        int id = identifierNumberCounter--;
+        identifierNumber.put(id, target);
+        this.addHighlight(new Highlight(target, target, id));
     };
 
 
     /**
-     * Populate document meta information with information coming from the index.
-     *
-     * @param doc    Document object.
-     * @param field  Primary data field.
-     * @param fields Hash object with all supported fields.
+     * Populate document meta information with information coming from
+     * the index.
+     * 
+     * @param doc
+     *            Document object.
+     * @param field
+     *            Primary data field.
+     * @param fields
+     *            Hash object with all supported fields.
      */
-    public void populateDocument (Document doc,
-                                  String field, HashSet<String> fields) {
-	this.setField(field);
-	this.setPrimaryData( doc.get(field) );
-	if (fields.contains("corpusID"))
-	    this.setCorpusID(doc.get("corpusID"));
-	if (fields.contains("ID"))
-	    this.setDocID(doc.get("ID"));
-	if (fields.contains("UID"))
-	    this.setUID(doc.get("UID"));
-	if (fields.contains("author"))
-	    this.setAuthor(doc.get("author"));
-	if (fields.contains("textClass"))
-	    this.setTextClass(doc.get("textClass"));
-	if (fields.contains("title"))
-	    this.setTitle(doc.get("title"));
-	if (fields.contains("subTitle"))
-	    this.setSubTitle(doc.get("subTitle"));
-	if (fields.contains("pubDate"))
-	    this.setPubDate(doc.get("pubDate"));
-	if (fields.contains("pubPlace"))
-	    this.setPubPlace(doc.get("pubPlace"));
+    public void populateDocument (Document doc, String field,
+            HashSet<String> fields) {
+        this.setField(field);
+        this.setPrimaryData(doc.get(field));
+        if (fields.contains("corpusID"))
+            this.setCorpusID(doc.get("corpusID"));
+        if (fields.contains("ID"))
+            this.setDocID(doc.get("ID"));
+        if (fields.contains("UID"))
+            this.setUID(doc.get("UID"));
+        if (fields.contains("author"))
+            this.setAuthor(doc.get("author"));
+        if (fields.contains("textClass"))
+            this.setTextClass(doc.get("textClass"));
+        if (fields.contains("title"))
+            this.setTitle(doc.get("title"));
+        if (fields.contains("subTitle"))
+            this.setSubTitle(doc.get("subTitle"));
+        if (fields.contains("pubDate"))
+            this.setPubDate(doc.get("pubDate"));
+        if (fields.contains("pubPlace"))
+            this.setPubPlace(doc.get("pubPlace"));
 
-	// Temporary (later meta fields in term vector)
-	if (fields.contains("foundries"))
-	    this.setFoundries(doc.get("foundries"));
-	if (fields.contains("tokenization"))
-	    this.setTokenization(doc.get("tokenization"));
-	if (fields.contains("layerInfo"))
-	    this.setLayerInfo(doc.get("layerInfo"));
+        // Temporary (later meta fields in term vector)
+        if (fields.contains("foundries"))
+            this.setFoundries(doc.get("foundries"));
+        if (fields.contains("tokenization"))
+            this.setTokenization(doc.get("tokenization"));
+        if (fields.contains("layerInfo"))
+            this.setLayerInfo(doc.get("layerInfo"));
 
-	// New fields
-	if (fields.contains("textSigle"))
-	    this.setTextSigle(doc.get("textSigle"));
+        // New fields
+        if (fields.contains("textSigle"))
+            this.setTextSigle(doc.get("textSigle"));
 
     };
 
@@ -405,56 +420,60 @@
      */
     @JsonProperty("docID")
     public String getDocID () {
-	return super.getID();
+        return super.getID();
     };
 
-    
+
     /**
      * Set document id.
-     *
-     * @param id String representation of document ID.
+     * 
+     * @param id
+     *            String representation of document ID.
      */
     public void setDocID (String id) {
-	super.setID(id);
+        super.setID(id);
     };
 
+
     /**
      * Get the positional start offset of the match.
      */
     @JsonIgnore
-    public int getStartPos() {
-	return this.startPos;
+    public int getStartPos () {
+        return this.startPos;
     };
 
 
     /**
      * Get the positional start offset of the class.
-     *
-     * @param number Class number of the highlight.
+     * 
+     * @param number
+     *            Class number of the highlight.
      */
     @JsonIgnore
     public int getStartPos (int number) {
-	if (number > 256 || this.highlight == null)
-	    return -1;
+        if (number > 256 || this.highlight == null)
+            return -1;
 
-	// Iterate over highlights to find matching class
-	for (Highlight h : this.highlight) {
-	    if (h.number == number)
-		return h.start;
-	};
+        // Iterate over highlights to find matching class
+        for (Highlight h : this.highlight) {
+            if (h.number == number)
+                return h.start;
+        };
 
-	return -1;
+        return -1;
     };
 
 
     /**
      * Set the positional start offset of the match.
-     *
-     * @param pos The positional offset.
+     * 
+     * @param pos
+     *            The positional offset.
      */
     @JsonIgnore
-    public void setStartPos(int pos) {
-	this.startPos = pos;
+    public void setStartPos (int pos) {
+        this.startPos = pos;
     };
 
 
@@ -463,407 +482,406 @@
      */
     @JsonIgnore
     public int getEndPos () {
-	return this.endPos;
+        return this.endPos;
     };
 
 
     /**
      * Get the positional end offset of the class.
-     *
-     * @param number Class number of the highlight.
+     * 
+     * @param number
+     *            Class number of the highlight.
      */
     @JsonIgnore
     public int getEndPos (int number) {
-	if (number > 256 || this.highlight == null)
-	    return -1;
+        if (number > 256 || this.highlight == null)
+            return -1;
 
-	// Iterate over highlights to find matching class
-	for (Highlight h : this.highlight) {
+        // Iterate over highlights to find matching class
+        for (Highlight h : this.highlight) {
 
-	    // Get the number (incremented by 1)
-	    if (h.number == number)
-		return h.end + 1;
-	};
+            // Get the number (incremented by 1)
+            if (h.number == number)
+                return h.end + 1;
+        };
 
-	return -1;
+        return -1;
     };
 
 
     /**
      * Set the positional end offset of the match.
-     *
-     * @param pos The positional offset.
+     * 
+     * @param pos
+     *            The positional offset.
      */
     @JsonIgnore
-    public void setEndPos(int pos) {
-	this.endPos = pos;
+    public void setEndPos (int pos) {
+        this.endPos = pos;
     };
 
-    
+
     /**
      * Get the local (i.e. Lucene given) ID of the document.
      */
     @JsonIgnore
     public int getLocalDocID () {
-	return this.localDocID;
+        return this.localDocID;
     };
 
 
     /**
      * Set the local (i.e. Lucene given) ID of the document.
-     *
-     * @param id The id of the document.
+     * 
+     * @param id
+     *            The id of the document.
      */
     @JsonIgnore
     public void setLocalDocID (int id) {
-	this.localDocID = id;
+        this.localDocID = id;
     };
 
-    
+
     /**
      * Get the PositionsToOffset object.
-     *
+     * 
      * @see PositionsToOffset
      */
     @JsonIgnore
     public PositionsToOffset getPositionsToOffset () {
-	return this.positionsToOffset;
+        return this.positionsToOffset;
     };
 
 
     /**
      * Set the PositionsToOffset object.
-     *
-     * @param pto The PositionsToOffset object
+     * 
+     * @param pto
+     *            The PositionsToOffset object
      * @see PositionsToOffset
      */
     @JsonIgnore
     public void setPositionsToOffset (PositionsToOffset pto) {
-	this.positionsToOffset = pto;
+        this.positionsToOffset = pto;
     };
 
 
     /**
      * Get match ID (for later retrieval).
-     *
+     * 
      * @see MatchIdentifier
      */
     @Override
     @JsonProperty("ID")
     public String getID () {
 
-	// Identifier already given
-	if (this.identifier != null)
-	    return this.identifier;
+        // Identifier already given
+        if (this.identifier != null)
+            return this.identifier;
 
-	// No, nada, nix
-	if (this.localDocID == -1)
-	    return null;
+        // No, nada, nix
+        if (this.localDocID == -1)
+            return null;
 
-	MatchIdentifier id = this.getMatchIdentifier();
+        MatchIdentifier id = this.getMatchIdentifier();
 
-	// Get prefix string corpus/doc
-	id.setCorpusID(this.getCorpusID());
-	id.setDocID(this.getDocID());
+        // Get prefix string corpus/doc
+        id.setCorpusID(this.getCorpusID());
+        id.setDocID(this.getDocID());
 
-	return (this.identifier = id.toString());
+        return (this.identifier = id.toString());
     };
 
+
     @JsonIgnore
     public MatchIdentifier getMatchIdentifier () {
-	MatchIdentifier id = new MatchIdentifier();
+        MatchIdentifier id = new MatchIdentifier();
 
-	id.setStartPos(startPos);
-	id.setEndPos(endPos);
+        id.setStartPos(startPos);
+        id.setEndPos(endPos);
 
-	// There are highlights to integrate
-	if (this.highlight != null) {
-	    for (Highlight h : this.highlight) {
-		if (h.number >= 256)
-		    continue;
+        // There are highlights to integrate
+        if (this.highlight != null) {
+            for (Highlight h : this.highlight) {
+                if (h.number >= 256)
+                    continue;
 
-		// Add highlight to the snippet
-		id.addPos(h.start, h.end, h.number);
-	    };
-	};
+                // Add highlight to the snippet
+                id.addPos(h.start, h.end, h.number);
+            };
+        };
 
-	return id;
+        return id;
     };
 
 
     /**
      * Get identifier for a specific position.
-     *
+     * 
      * @param int Position to get identifier on.
      */
     @JsonIgnore
     public String getPosID (int pos) {
 
-	// Identifier already given
-	if (this.identifier != null)
-	    return this.identifier;
+        // Identifier already given
+        if (this.identifier != null)
+            return this.identifier;
 
-	// Nothing here
-	if (this.localDocID == -1)
-	    return null;
+        // Nothing here
+        if (this.localDocID == -1)
+            return null;
 
-	PosIdentifier id = new PosIdentifier();
+        PosIdentifier id = new PosIdentifier();
 
-	// Get prefix string corpus/doc
-	id.setCorpusID(this.getCorpusID());
-	id.setDocID(this.getDocID());
-	id.setPos(pos);
+        // Get prefix string corpus/doc
+        id.setCorpusID(this.getCorpusID());
+        id.setDocID(this.getDocID());
+        id.setPos(pos);
 
-	return id.toString();
+        return id.toString();
     };
 
+
     /**
      * Get possible error message.
      */
     // Identical to Result
     public String getError () {
-	return this.error;
+        return this.error;
     };
 
+
     /**
      * Set error message.
-     *
-     * @param msg The error message.
+     * 
+     * @param msg
+     *            The error message.
      */
     public void setError (String msg) {
-	this.error = msg;
+        this.error = msg;
     };
 
 
     public Match setContext (SearchContext context) {
-	this.context = context;
-	return this;
+        this.context = context;
+        return this;
     };
 
+
     @JsonIgnore
     public SearchContext getContext () {
-	if (this.context == null)
-	    this.context = new SearchContext();
-	return this.context;
+        if (this.context == null)
+            this.context = new SearchContext();
+        return this.context;
     };
-    
+
 
     // Expand the context to a span
     public int[] expandContextToSpan (String element) {
 
-	// TODO: THE BITS HAVE TO BE SET!
-	
-	if (this.positionsToOffset != null)
-	    return this.expandContextToSpan(
-	        this.positionsToOffset.getAtomicReader(),
-		(Bits) null,
-		"tokens",
-		element
-	    );
-	return new int[]{0,0,0,0};
+        // TODO: THE BITS HAVE TO BE SET!
+
+        if (this.positionsToOffset != null)
+            return this.expandContextToSpan(
+                    this.positionsToOffset.getAtomicReader(), (Bits) null,
+                    "tokens", element);
+        return new int[] { 0, 0, 0, 0 };
     };
 
+
     // Expand the context to a span
     // THIS IS NOT VERY CLEVER - MAKE IT MORE CLEVER!
-    public int[] expandContextToSpan (AtomicReaderContext atomic,
-				      Bits bitset,
-				      String field,
-				      String element) {
+    public int[] expandContextToSpan (AtomicReaderContext atomic, Bits bitset,
+            String field, String element) {
 
-	try {
-	    // Store character offsets in ByteBuffer
-	    ByteBuffer bb = ByteBuffer.allocate(8);
+        try {
+            // Store character offsets in ByteBuffer
+            ByteBuffer bb = ByteBuffer.allocate(8);
 
-	    SpanElementQuery cquery =
-		new SpanElementQuery(field, element);
+            SpanElementQuery cquery = new SpanElementQuery(field, element);
 
-	    Spans contextSpans = cquery.getSpans(
-	        atomic,
-		bitset,
-		new HashMap<Term, TermContext>()
-	    );
+            Spans contextSpans = cquery.getSpans(atomic, bitset,
+                    new HashMap<Term, TermContext>());
 
-	    int newStart = -1,
-		newEnd = -1;
-	    int newStartChar = -1,
-		newEndChar = -1;
+            int newStart = -1, newEnd = -1;
+            int newStartChar = -1, newEndChar = -1;
 
-	    if (DEBUG)
-		log.trace("Extend match to context boundary with {} in {}",
-			  cquery.toString(),
-			  this.localDocID);
+            if (DEBUG)
+                log.trace("Extend match to context boundary with {} in {}",
+                        cquery.toString(), this.localDocID);
 
-	    while (true) {
+            while (true) {
 
-		// Game over
-		if (contextSpans.next() != true)
-		    break;
+                // Game over
+                if (contextSpans.next() != true)
+                    break;
 
-		if (contextSpans.doc() != this.localDocID) {
-		    contextSpans.skipTo(this.localDocID);
-		    if (contextSpans.doc() != this.localDocID)
-			break;
-		};
+                if (contextSpans.doc() != this.localDocID) {
+                    contextSpans.skipTo(this.localDocID);
+                    if (contextSpans.doc() != this.localDocID)
+                        break;
+                };
 
-		// There's a <context> found -- I'm curious,
-		// if it's closer to the match than everything before
-		if (contextSpans.start() <= this.getStartPos() &&
-		    contextSpans.end() >= this.getStartPos()) {
+                // There's a <context> found -- I'm curious,
+                // if it's closer to the match than everything before
+                if (contextSpans.start() <= this.getStartPos()
+                        && contextSpans.end() >= this.getStartPos()) {
 
-		    // Set as newStart
-		    newStart = contextSpans.start() > newStart ?
-			contextSpans.start() : newStart;
+                    // Set as newStart
+                    newStart = contextSpans.start() > newStart ? contextSpans
+                            .start() : newStart;
 
-		    if (DEBUG)
-			log.trace("NewStart is at {}", newStart);
+                    if (DEBUG)
+                        log.trace("NewStart is at {}", newStart);
 
-		    // Get character offset (start)
-		    if (contextSpans.isPayloadAvailable()) {
-			try {
-			    bb.rewind();
-			    for (byte[] b : contextSpans.getPayload()) {
+                    // Get character offset (start)
+                    if (contextSpans.isPayloadAvailable()) {
+                        try {
+                            bb.rewind();
+                            for (byte[] b : contextSpans.getPayload()) {
 
-				// Not an element span
-				if (b.length != 8)
-				    continue;
+                                // Not an element span
+                                if (b.length != 8)
+                                    continue;
 
-				bb.put(b);
-				bb.rewind();
-				newStartChar = bb.getInt();
-				newEndChar = bb.getInt();
-				break;
-			    };
-			}
-			catch (Exception e) {
-			    log.warn(e.getMessage());
-			};
-		    };
-		}
-		else {
-		    // Has to be resettet to avoid multiple readings of the payload
-		    newEndChar = 0;
-		};
-		
-		// There's an s found, that ends after the match
-		if (contextSpans.end() >= this.getEndPos()) {
-		    newEnd = contextSpans.end();
+                                bb.put(b);
+                                bb.rewind();
+                                newStartChar = bb.getInt();
+                                newEndChar = bb.getInt();
+                                break;
+                            };
+                        }
+                        catch (Exception e) {
+                            log.warn(e.getMessage());
+                        };
+                    };
+                }
+                else {
+                    // Has to be resettet to avoid multiple readings of the payload
+                    newEndChar = 0;
+                };
 
-		    // Get character offset (end)
-		    if (newEndChar == 0 && contextSpans.isPayloadAvailable()) {
-			try {
-			    bb.rewind();
-			    for (byte[] b : contextSpans.getPayload()) {
+                // There's an s found, that ends after the match
+                if (contextSpans.end() >= this.getEndPos()) {
+                    newEnd = contextSpans.end();
 
-				// Not an element span
-				if (b.length != 8)
-				    continue;
+                    // Get character offset (end)
+                    if (newEndChar == 0 && contextSpans.isPayloadAvailable()) {
+                        try {
+                            bb.rewind();
+                            for (byte[] b : contextSpans.getPayload()) {
 
-				bb.put(b);
-				bb.rewind();
-				newEndChar = bb.getInt(1);
-				break;
-			    };
-			}
-			catch (Exception e) {
-			    log.warn(e.getMessage());
-			};
-		    };
-		    break;
-		};
-	    };
-	    
-	    // We have a new match surrounding
-	    if (DEBUG)
-		log.trace("New match spans from {}-{}/{}-{}", newStart, newEnd, newStartChar, newEndChar);
+                                // Not an element span
+                                if (b.length != 8)
+                                    continue;
 
-	    return new int[]{newStart, newEnd, newStartChar, newEndChar};
-	}
-	catch (IOException e) {
-	    log.error(e.getMessage());
-	};
-	
-	return new int[]{-1,-1,-1,-1};
+                                bb.put(b);
+                                bb.rewind();
+                                newEndChar = bb.getInt(1);
+                                break;
+                            };
+                        }
+                        catch (Exception e) {
+                            log.warn(e.getMessage());
+                        };
+                    };
+                    break;
+                };
+            };
+
+            // We have a new match surrounding
+            if (DEBUG)
+                log.trace("New match spans from {}-{}/{}-{}", newStart, newEnd,
+                        newStartChar, newEndChar);
+
+            return new int[] { newStart, newEnd, newStartChar, newEndChar };
+        }
+        catch (IOException e) {
+            log.error(e.getMessage());
+        };
+
+        return new int[] { -1, -1, -1, -1 };
     };
 
-    
+
     // Reset all internal data
     private void _reset () {
-	this.processed       = false;
-	this.snippetHTML     = null;
-	this.snippetBrackets = null;
-	this.identifier      = null;
+        this.processed = false;
+        this.snippetHTML = null;
+        this.snippetBrackets = null;
+        this.identifier = null;
 
-	// Delete all spans
-	if (this.span != null)
-	    this.span.clear();
+        // Delete all spans
+        if (this.span != null)
+            this.span.clear();
     };
 
-    
+
     // Start building highlighted snippets
     private boolean _processHighlight () {
-	if (processed)
-	    return true;
+        if (processed)
+            return true;
 
-	// Relevant details are missing
-	if (this.positionsToOffset == null || this.localDocID == -1) {
-	    log.warn("You have to define " +
-		     "positionsToOffset and localDocID first " +
-		     "before");
-	    return false;
-	};
+        // Relevant details are missing
+        if (this.positionsToOffset == null || this.localDocID == -1) {
+            log.warn("You have to define "
+                    + "positionsToOffset and localDocID first " + "before");
+            return false;
+        };
 
-	if (DEBUG)
-	    log.trace("--- Start highlight processing ...");
+        if (DEBUG)
+            log.trace("--- Start highlight processing ...");
 
-	// Get pto object
-	PositionsToOffset pto = this.positionsToOffset;
-	pto.add(this.localDocID, this.getStartPos());
-	pto.add(this.localDocID, this.getEndPos() - 1);
+        // Get pto object
+        PositionsToOffset pto = this.positionsToOffset;
+        pto.add(this.localDocID, this.getStartPos());
+        pto.add(this.localDocID, this.getEndPos() - 1);
 
-	if (DEBUG)
-	    log.trace("PTO will retrieve {} & {} (Match boundary)",
-		      this.getStartPos(),
-		      this.getEndPos());
+        if (DEBUG)
+            log.trace("PTO will retrieve {} & {} (Match boundary)",
+                    this.getStartPos(), this.getEndPos());
 
-	// Add all highlights for character retrieval
-	if (this.highlight != null) {
-	    for (Highlight hl : this.highlight) {
-		if (hl.start >= this.getStartPos() && hl.end <= this.getEndPos()) {
-		    pto.add(this.localDocID, hl.start);
-		    pto.add(this.localDocID, hl.end);
+        // Add all highlights for character retrieval
+        if (this.highlight != null) {
+            for (Highlight hl : this.highlight) {
+                if (hl.start >= this.getStartPos()
+                        && hl.end <= this.getEndPos()) {
+                    pto.add(this.localDocID, hl.start);
+                    pto.add(this.localDocID, hl.end);
 
-		    if (DEBUG)
-			log.trace("PTO will retrieve {} & {} (Highlight boundary)",
-				  hl.start, hl.end);
-		};
-	    };
-	};
-	
-	// Get the list of spans for matches and highlighting
-	if (this.span == null || this.span.size() == 0) {
-	    if (!this._processHighlightSpans())
-		return false;
-	};
+                    if (DEBUG)
+                        log.trace(
+                                "PTO will retrieve {} & {} (Highlight boundary)",
+                                hl.start, hl.end);
+                };
+            };
+        };
 
-	// Create a stack for highlighted elements
-	// (opening and closing elements)
-	ArrayList<int[]> stack = this._processHighlightStack();
+        // Get the list of spans for matches and highlighting
+        if (this.span == null || this.span.size() == 0) {
+            if (!this._processHighlightSpans())
+                return false;
+        };
 
-	if (DEBUG)
-	    log.trace("The snippet is {}", this.tempSnippet);
+        // Create a stack for highlighted elements
+        // (opening and closing elements)
+        ArrayList<int[]> stack = this._processHighlightStack();
+
+        if (DEBUG)
+            log.trace("The snippet is {}", this.tempSnippet);
 
 
-	// The temporary snippet is empty, nothing to do
-	if (this.tempSnippet == null) {
-	    processed = true;
-	    return false;
-	};
+        // The temporary snippet is empty, nothing to do
+        if (this.tempSnippet == null) {
+            processed = true;
+            return false;
+        };
 
-	// Merge the element stack with the primary textual data
-	this._processHighlightSnippet(this.tempSnippet, stack);
+        // Merge the element stack with the primary textual data
+        this._processHighlightSnippet(this.tempSnippet, stack);
 
-	// Match is processed - done
-	return (processed = true);
+        // Match is processed - done
+        return (processed = true);
     };
 
 
@@ -871,181 +889,181 @@
       Comparator class for opening tags
      */
     private class OpeningTagComparator implements Comparator<int[]> {
-	@Override
-	public int compare (int[] arg0, int[] arg1) {
-	    // Check start positions
-	    if (arg0[0] > arg1[0]) {
-		return 1;
-	    }
-	    else if (arg0[0] == arg1[0]) {
-		// Check endpositions
-		if (arg0[1] > arg1[1]) {
-		    return -1;
-		}
-		else if (arg0[1] == arg1[1]) {
-		    return 0;
-		}
-		return 1;
-	    };
-	    return -1;
-	};
+        @Override
+        public int compare (int[] arg0, int[] arg1) {
+            // Check start positions
+            if (arg0[0] > arg1[0]) {
+                return 1;
+            }
+            else if (arg0[0] == arg1[0]) {
+                // Check endpositions
+                if (arg0[1] > arg1[1]) {
+                    return -1;
+                }
+                else if (arg0[1] == arg1[1]) {
+                    return 0;
+                }
+                return 1;
+            };
+            return -1;
+        };
     };
 
     /*
       Comparator class for closing tags
      */
     private class ClosingTagComparator implements Comparator<int[]> {
-	@Override
-	public int compare (int[] arg0, int[] arg1) {
-	    // Check end positions
-	    if (arg0[1] > arg1[1]) {
-		return 1;
-	    }
-	    else if (arg0[1] == arg1[1]) {
-		// Check start positions
-		if (arg0[0] < arg1[0]) {
-		    return 1;
-		}
-		else if (arg0[0] == arg1[0]) {
-		    return 0;
-		};
-		return -1;
-	    };
-	    return -1;
-	};
+        @Override
+        public int compare (int[] arg0, int[] arg1) {
+            // Check end positions
+            if (arg0[1] > arg1[1]) {
+                return 1;
+            }
+            else if (arg0[1] == arg1[1]) {
+                // Check start positions
+                if (arg0[0] < arg1[0]) {
+                    return 1;
+                }
+                else if (arg0[0] == arg1[0]) {
+                    return 0;
+                };
+                return -1;
+            };
+            return -1;
+        };
     };
 
 
 
-    private void _processHighlightSnippet (String clean,
-					   ArrayList<int[]> stack) {
+    private void _processHighlightSnippet (String clean, ArrayList<int[]> stack) {
 
-	if (DEBUG)
-	    log.trace("--- Process Highlight snippet");
+        if (DEBUG)
+            log.trace("--- Process Highlight snippet");
 
-	int pos = 0, oldPos = 0;
+        int pos = 0, oldPos = 0;
 
-	this.snippetArray = new HighlightCombinator();
+        this.snippetArray = new HighlightCombinator();
 
-	for (int[] element : stack) {
-	    pos = element[3] != 0 ? element[0] : element[1];
+        for (int[] element : stack) {
+            pos = element[3] != 0 ? element[0] : element[1];
 
-	    if (pos > oldPos) {
+            if (pos > oldPos) {
 
-	      if (pos > clean.length()) {
-		pos = clean.length() - 1;
-	      };
+                if (pos > clean.length()) {
+                    pos = clean.length() - 1;
+                };
 
-		snippetArray.addString(clean.substring(oldPos, pos));
+                snippetArray.addString(clean.substring(oldPos, pos));
 
-		oldPos = pos;
-	    };
+                oldPos = pos;
+            };
 
-	    if (element[3] != 0) {
-		snippetArray.addOpen(element[2]);
-	    }
-	    else {
-		snippetArray.addClose(element[2]);
-	    };
-	};
+            if (element[3] != 0) {
+                snippetArray.addOpen(element[2]);
+            }
+            else {
+                snippetArray.addClose(element[2]);
+            };
+        };
 
-	if (clean.length() > pos) {
-	    snippetArray.addString(clean.substring(pos));
-	};
+        if (clean.length() > pos) {
+            snippetArray.addString(clean.substring(pos));
+        };
     };
 
 
     @JsonProperty("snippet")
     public String getSnippetHTML () {
 
-	if (!this._processHighlight())
-	    return null;
+        if (!this._processHighlight())
+            return null;
 
-	if (this.processed && this.snippetHTML != null)
-	    return this.snippetHTML;
+        if (this.processed && this.snippetHTML != null)
+            return this.snippetHTML;
 
-	if (DEBUG)
-	    log.trace("Create HTML Snippet");
+        if (DEBUG)
+            log.trace("Create HTML Snippet");
 
-	StringBuilder sb = new StringBuilder();
+        StringBuilder sb = new StringBuilder();
 
-	// Snippet stack sizes
-	short start = (short) 0;
-	short end = this.snippetArray.size();
-	end--;
+        // Snippet stack sizes
+        short start = (short) 0;
+        short end = this.snippetArray.size();
+        end--;
 
-	// Set levels for highlights 
-	FixedBitSet level = new FixedBitSet(255);
-	level.set(0, 255);
-	byte[] levelCache = new byte[255];
+        // Set levels for highlights 
+        FixedBitSet level = new FixedBitSet(255);
+        level.set(0, 255);
+        byte[] levelCache = new byte[255];
 
-	// First element of sorted array
-	HighlightCombinatorElement elem = this.snippetArray.getFirst();
+        // First element of sorted array
+        HighlightCombinatorElement elem = this.snippetArray.getFirst();
 
-	// Create context
-	sb.append("<span class=\"context-left\">");
-	if (this.startMore)
-	    sb.append("<span class=\"more\"></span>");
+        // Create context
+        sb.append("<span class=\"context-left\">");
+        if (this.startMore)
+            sb.append("<span class=\"more\"></span>");
 
-	// First element is textual
-	if (elem.type == 0) {
-	    sb.append(elem.toHTML(this, level, levelCache));
-	    // Move start position
-	    start++;
-	};
-	sb.append("</span>");
+        // First element is textual
+        if (elem.type == 0) {
+            sb.append(elem.toHTML(this, level, levelCache));
+            // Move start position
+            start++;
+        };
+        sb.append("</span>");
 
-	// Last element of sorted array
-	elem = this.snippetArray.getLast();
+        // Last element of sorted array
+        elem = this.snippetArray.getLast();
 
-	StringBuilder rightContext = new StringBuilder();
+        StringBuilder rightContext = new StringBuilder();
 
-	// Create right context, if there is any
-	rightContext.append("<span class=\"context-right\">");
+        // Create right context, if there is any
+        rightContext.append("<span class=\"context-right\">");
 
-	// Last element is textual
-	if (elem != null && elem.type == 0) {
-	    rightContext.append(elem.toHTML(this, level, levelCache));
+        // Last element is textual
+        if (elem != null && elem.type == 0) {
+            rightContext.append(elem.toHTML(this, level, levelCache));
 
-	    // decrement end
-	    end--;
-	};
-	if (this.endMore)
-	    rightContext.append("<span class=\"more\"></span>");
-	rightContext.append("</span>");
+            // decrement end
+            end--;
+        };
+        if (this.endMore)
+            rightContext.append("<span class=\"more\"></span>");
+        rightContext.append("</span>");
 
-	// Iterate through all remaining elements
-	for (short i = start; i <= end; i++) {
-	    sb.append(this.snippetArray.get(i).toHTML(this, level,levelCache));
-	};
+        // Iterate through all remaining elements
+        for (short i = start; i <= end; i++) {
+            sb.append(this.snippetArray.get(i).toHTML(this, level, levelCache));
+        };
 
-	sb.append(rightContext);
+        sb.append(rightContext);
 
-	return (this.snippetHTML = sb.toString());
+        return (this.snippetHTML = sb.toString());
     };
-    
+
+
     @JsonIgnore
     public String getSnippetBrackets () {
 
-	if (!this._processHighlight())
-	    return null;
+        if (!this._processHighlight())
+            return null;
 
-	if (this.processed && this.snippetBrackets != null)
-	    return this.snippetBrackets;
+        if (this.processed && this.snippetBrackets != null)
+            return this.snippetBrackets;
 
-	StringBuilder sb = new StringBuilder();
+        StringBuilder sb = new StringBuilder();
 
-	if (this.startMore)
-	    sb.append("... ");
+        if (this.startMore)
+            sb.append("... ");
 
-	for (HighlightCombinatorElement hce : this.snippetArray.list()) {
-	    sb.append(hce.toBrackets(this));
-	};
+        for (HighlightCombinatorElement hce : this.snippetArray.list()) {
+            sb.append(hce.toBrackets(this));
+        };
 
-	if (this.endMore)
-	    sb.append(" ...");
+        if (this.endMore)
+            sb.append(" ...");
 
-	return (this.snippetBrackets = sb.toString());
+        return (this.snippetBrackets = sb.toString());
     };
 
 
@@ -1053,371 +1071,350 @@
     // even in case they overlap
     // TODO: Not very fast - improve!
     private ArrayList<int[]> _processHighlightStack () {
-	if (DEBUG)
-	    log.trace("--- Process Highlight stack");
+        if (DEBUG)
+            log.trace("--- Process Highlight stack");
 
-	LinkedList<int[]> openList  = new LinkedList<int[]>();
-	LinkedList<int[]> closeList = new LinkedList<int[]>();
+        LinkedList<int[]> openList = new LinkedList<int[]>();
+        LinkedList<int[]> closeList = new LinkedList<int[]>();
 
-	// Filter multiple identifiers, that may be introduced and would
-	// result in invalid xml
-	this._filterMultipleIdentifiers();
+        // Filter multiple identifiers, that may be introduced and would
+        // result in invalid xml
+        this._filterMultipleIdentifiers();
 
-	// Add highlight spans to balance lists
-	openList.addAll(this.span);
-	closeList.addAll(this.span);
+        // Add highlight spans to balance lists
+        openList.addAll(this.span);
+        closeList.addAll(this.span);
 
-	// Sort balance lists
-	Collections.sort(openList, new OpeningTagComparator());
-	Collections.sort(closeList, new ClosingTagComparator());
+        // Sort balance lists
+        Collections.sort(openList, new OpeningTagComparator());
+        Collections.sort(closeList, new ClosingTagComparator());
 
-	// New stack array
-	ArrayList<int[]> stack = new ArrayList<>(openList.size() * 2);
+        // New stack array
+        ArrayList<int[]> stack = new ArrayList<>(openList.size() * 2);
 
-	// Create stack unless both lists are empty
-	while (!openList.isEmpty() || !closeList.isEmpty()) {
+        // Create stack unless both lists are empty
+        while (!openList.isEmpty() || !closeList.isEmpty()) {
 
-	    if (openList.isEmpty()) {
-		stack.addAll(closeList);
-		break;
-	    }
+            if (openList.isEmpty()) {
+                stack.addAll(closeList);
+                break;
+            }
 
-	    // Not sure about this, but it can happen
-	    else if (closeList.isEmpty()) {
-		break;
-	    };
+            // Not sure about this, but it can happen
+            else if (closeList.isEmpty()) {
+                break;
+            };
 
-	    if (openList.peekFirst()[0] < closeList.peekFirst()[1]) {
-		int[] e = openList.removeFirst().clone();
-		e[3] = 1;
-		stack.add(e);
-	    }
-	    else {
-		stack.add(closeList.removeFirst());
-	    };
-	};
-	return stack;
+            if (openList.peekFirst()[0] < closeList.peekFirst()[1]) {
+                int[] e = openList.removeFirst().clone();
+                e[3] = 1;
+                stack.add(e);
+            }
+            else {
+                stack.add(closeList.removeFirst());
+            };
+        };
+        return stack;
     };
 
+
     /**
      * This will retrieve character offsets for all spans.
      */
     private boolean _processHighlightSpans () {
 
-	if (DEBUG)
-	    log.trace("--- Process Highlight spans");
+        if (DEBUG)
+            log.trace("--- Process Highlight spans");
 
-	// Local document ID
-	int ldid = this.localDocID;
+        // Local document ID
+        int ldid = this.localDocID;
 
-	int startPosChar = -1, endPosChar = -1;
+        int startPosChar = -1, endPosChar = -1;
 
-	// No positionsToOffset object found
-	if (this.positionsToOffset == null)
-	    return false;
+        // No positionsToOffset object found
+        if (this.positionsToOffset == null)
+            return false;
 
-	// Match position
-	startPosChar = this.positionsToOffset.start(ldid, this.startPos);
+        // Match position
+        startPosChar = this.positionsToOffset.start(ldid, this.startPos);
 
-	if (DEBUG)
-	    log.trace("Unaltered startPosChar is {}", startPosChar);
+        if (DEBUG)
+            log.trace("Unaltered startPosChar is {}", startPosChar);
 
-	// Check potential differing start characters
-	// e.g. from element spans
-	if (potentialStartPosChar != -1 &&
-	    (startPosChar > this.potentialStartPosChar))
-	    startPosChar = this.potentialStartPosChar;
+        // Check potential differing start characters
+        // e.g. from element spans
+        if (potentialStartPosChar != -1
+                && (startPosChar > this.potentialStartPosChar))
+            startPosChar = this.potentialStartPosChar;
 
-	endPosChar = this.positionsToOffset.end(ldid, this.endPos - 1);
+        endPosChar = this.positionsToOffset.end(ldid, this.endPos - 1);
 
-	if (DEBUG)
-	    log.trace("Unaltered endPosChar is {}", endPosChar);
+        if (DEBUG)
+            log.trace("Unaltered endPosChar is {}", endPosChar);
 
-	// Potential end characters may come from spans with
-	// defined character offsets like sentences including .", ... etc.
-	if (endPosChar < potentialEndPosChar)
-	    endPosChar = potentialEndPosChar;
+        // Potential end characters may come from spans with
+        // defined character offsets like sentences including .", ... etc.
+        if (endPosChar < potentialEndPosChar)
+            endPosChar = potentialEndPosChar;
 
-	if (DEBUG)
-	    log.trace("Refined: Match offset is pos {}-{} (chars {}-{})",
-		      this.startPos,
-		      this.endPos,
-		      startPosChar,
-		      endPosChar);
+        if (DEBUG)
+            log.trace("Refined: Match offset is pos {}-{} (chars {}-{})",
+                    this.startPos, this.endPos, startPosChar, endPosChar);
 
-	this.identifier = null;
+        this.identifier = null;
 
-	// No spans yet
-	if (this.span == null)
-	    this.span = new LinkedList<int[]>();
+        // No spans yet
+        if (this.span == null)
+            this.span = new LinkedList<int[]>();
 
-	// Process offset char findings
-	int[] intArray = this._processOffsetChars(ldid, startPosChar, endPosChar);
+        // Process offset char findings
+        int[] intArray = this._processOffsetChars(ldid, startPosChar,
+                endPosChar);
 
-	// Recalculate startOffsetChar
-	int startOffsetChar = startPosChar - intArray[0];
+        // Recalculate startOffsetChar
+        int startOffsetChar = startPosChar - intArray[0];
 
-	// Add match span
-	this.span.add(intArray);
+        // Add match span
+        this.span.add(intArray);
 
-	// highlights
-	// -- I'm not sure about this.
-	if (this.highlight != null) {
-	    if (DEBUG)
-		log.trace("There are highlights!");
-	    
-	    for (Highlight highlight : this.highlight) {
-		int start = this.positionsToOffset.start(
-		  ldid, highlight.start
-	        );
-		
-		int end = this.positionsToOffset.end(
-	          ldid,
-		  highlight.end
-		);
+        // highlights
+        // -- I'm not sure about this.
+        if (this.highlight != null) {
+            if (DEBUG)
+                log.trace("There are highlights!");
 
-		if (DEBUG)
-		    log.trace("PTO has retrieved {}-{} for class {}",
-			      start,
-			      end,
-			      highlight.number);
-		
-		start -= startOffsetChar;
-		end   -= startOffsetChar;
-		
-		if (start < 0 || end < 0)
-		    continue;
+            for (Highlight highlight : this.highlight) {
+                int start = this.positionsToOffset.start(ldid, highlight.start);
 
-		// Create intArray for highlight
-		intArray = new int[]{
-		    start,
-		    end,
-		    highlight.number,
-		    0 // Dummy value for later
-		};
+                int end = this.positionsToOffset.end(ldid, highlight.end);
 
-		this.span.add(intArray);
-	    };
-	};
-	return true;
+                if (DEBUG)
+                    log.trace("PTO has retrieved {}-{} for class {}", start,
+                            end, highlight.number);
+
+                start -= startOffsetChar;
+                end -= startOffsetChar;
+
+                if (start < 0 || end < 0)
+                    continue;
+
+                // Create intArray for highlight
+                intArray = new int[] { start, end, highlight.number, 0 // Dummy value for later
+                };
+
+                this.span.add(intArray);
+            };
+        };
+        return true;
     };
 
 
     // Pass the local docid to retrieve character positions for the offset
-    private int[] _processOffsetChars (int ldid, int startPosChar, int endPosChar) {
+    private int[] _processOffsetChars (int ldid, int startPosChar,
+            int endPosChar) {
 
-	int startOffsetChar = -1, endOffsetChar = -1;
-	int startOffset = -1, endOffset = -1;
+        int startOffsetChar = -1, endOffsetChar = -1;
+        int startOffset = -1, endOffset = -1;
 
-	// The offset is defined by a span
-	if (this.getContext().isSpanDefined()) {
+        // The offset is defined by a span
+        if (this.getContext().isSpanDefined()) {
 
-	    if (DEBUG)
-		log.trace("Try to expand to <{}>",
-			  this.context.getSpanContext());
+            if (DEBUG)
+                log.trace("Try to expand to <{}>",
+                        this.context.getSpanContext());
 
-	    this.startMore = false;
-	    this.endMore = false;
+            this.startMore = false;
+            this.endMore = false;
 
-	    int [] spanContext = this.expandContextToSpan(
-	        this.positionsToOffset.getAtomicReader(),
-	        (Bits) null,
-	        "tokens",
-	        this.context.getSpanContext()
-	    );
-	    startOffset = spanContext[0];
-	    endOffset = spanContext[1];
-	    startOffsetChar = spanContext[2];
-	    endOffsetChar = spanContext[3];
-	    if (DEBUG)
-		log.trace("Got context is based from span {}-{}/{}-{}",
-			  startOffset, endOffset, startOffsetChar, endOffsetChar);
-	};
+            int[] spanContext = this.expandContextToSpan(
+                    this.positionsToOffset.getAtomicReader(), (Bits) null,
+                    "tokens", this.context.getSpanContext());
+            startOffset = spanContext[0];
+            endOffset = spanContext[1];
+            startOffsetChar = spanContext[2];
+            endOffsetChar = spanContext[3];
+            if (DEBUG)
+                log.trace("Got context is based from span {}-{}/{}-{}",
+                        startOffset, endOffset, startOffsetChar, endOffsetChar);
+        };
 
-	// The offset is defined by tokens or characters
-	if (endOffset == -1) {
+        // The offset is defined by tokens or characters
+        if (endOffset == -1) {
 
-	    PositionsToOffset pto = this.positionsToOffset;
-	    
-	    // The left offset is defined by tokens
-	    if (this.context.left.isToken()) {
-		startOffset = this.startPos - this.context.left.getLength();
-		if (DEBUG)
-		    log.trace("PTO will retrieve {} (Left context)", startOffset);
-		pto.add(ldid, startOffset);
-	    }
+            PositionsToOffset pto = this.positionsToOffset;
 
-	    // The left offset is defined by characters
-	    else {
-		startOffsetChar = startPosChar - this.context.left.getLength();
-	    };
+            // The left offset is defined by tokens
+            if (this.context.left.isToken()) {
+                startOffset = this.startPos - this.context.left.getLength();
+                if (DEBUG)
+                    log.trace("PTO will retrieve {} (Left context)",
+                            startOffset);
+                pto.add(ldid, startOffset);
+            }
 
-	    // The right context is defined by tokens
-	    if (this.context.right.isToken()) {
-		endOffset = this.endPos + this.context.right.getLength() -1;
-		if (DEBUG)
-		    log.trace("PTO will retrieve {} (Right context)", endOffset);
-		pto.add(ldid, endOffset);
+            // The left offset is defined by characters
+            else {
+                startOffsetChar = startPosChar - this.context.left.getLength();
+            };
 
-	    }
+            // The right context is defined by tokens
+            if (this.context.right.isToken()) {
+                endOffset = this.endPos + this.context.right.getLength() - 1;
+                if (DEBUG)
+                    log.trace("PTO will retrieve {} (Right context)", endOffset);
+                pto.add(ldid, endOffset);
 
-	    // The right context is defined by characters
-	    else {
-		endOffsetChar = (endPosChar == -1) ? -1 :
-		    endPosChar + this.context.right.getLength();
-	    };
+            }
 
-	    if (startOffset != -1)
-		startOffsetChar = pto.start(ldid, startOffset);
+            // The right context is defined by characters
+            else {
+                endOffsetChar = (endPosChar == -1) ? -1 : endPosChar
+                        + this.context.right.getLength();
+            };
 
-	    if (endOffset != -1)
-		endOffsetChar = pto.end(ldid, endOffset);
-	};
+            if (startOffset != -1)
+                startOffsetChar = pto.start(ldid, startOffset);
 
-	if (DEBUG)
-	    log.trace("Premature found offsets at {}-{}",
-		      startOffsetChar,
-		      endOffsetChar);
-	
+            if (endOffset != -1)
+                endOffsetChar = pto.end(ldid, endOffset);
+        };
 
-	// This can happen in case of non-token characters
-	// in the match and null offsets
-	if (startOffsetChar > startPosChar)
-	    startOffsetChar = startPosChar;
-	else if (startOffsetChar < 0)
-	    startOffsetChar = 0;
+        if (DEBUG)
+            log.trace("Premature found offsets at {}-{}", startOffsetChar,
+                    endOffsetChar);
 
-	// No "..." at the beginning
-	if (startOffsetChar == 0)
-	    this.startMore = false;
 
-	if (endOffsetChar != -1 && endOffsetChar < endPosChar)
-	    endOffsetChar = endPosChar;
+        // This can happen in case of non-token characters
+        // in the match and null offsets
+        if (startOffsetChar > startPosChar)
+            startOffsetChar = startPosChar;
+        else if (startOffsetChar < 0)
+            startOffsetChar = 0;
 
-	if (DEBUG)
-	    log.trace("The context spans from chars {}-{}",
-		      startOffsetChar, endOffsetChar);
+        // No "..." at the beginning
+        if (startOffsetChar == 0)
+            this.startMore = false;
 
-	// Get snippet information from the primary data
-	if (endOffsetChar > -1 &&
-	    (endOffsetChar < this.getPrimaryDataLength())) {
-	    this.tempSnippet = this.getPrimaryData(
-		startOffsetChar,
-		endOffsetChar
-	    );
-	}
-	else {
-	    this.tempSnippet = this.getPrimaryData(startOffsetChar);
-	    this.endMore = false;
-	};
+        if (endOffsetChar != -1 && endOffsetChar < endPosChar)
+            endOffsetChar = endPosChar;
 
-	if (DEBUG)
-	    log.trace("Snippet: '" + this.tempSnippet + "'");
+        if (DEBUG)
+            log.trace("The context spans from chars {}-{}", startOffsetChar,
+                    endOffsetChar);
 
-	if (DEBUG)
-	    log.trace("The match entry is {}-{} ({}-{}) with absolute offsetChars {}-{}",
-		      startPosChar - startOffsetChar,
-		      endPosChar - startOffsetChar,
-		      startPosChar,
-		      endPosChar,
-		      startOffsetChar,
-		      endOffsetChar);
+        // Get snippet information from the primary data
+        if (endOffsetChar > -1 && (endOffsetChar < this.getPrimaryDataLength())) {
+            this.tempSnippet = this.getPrimaryData(startOffsetChar,
+                    endOffsetChar);
+        }
+        else {
+            this.tempSnippet = this.getPrimaryData(startOffsetChar);
+            this.endMore = false;
+        };
 
-	// TODO: Simplify
-	return new int[]{
-	    startPosChar - startOffsetChar,
-	    endPosChar - startOffsetChar,
-	    -1,
-	    0};
+        if (DEBUG)
+            log.trace("Snippet: '" + this.tempSnippet + "'");
+
+        if (DEBUG)
+            log.trace(
+                    "The match entry is {}-{} ({}-{}) with absolute offsetChars {}-{}",
+                    startPosChar - startOffsetChar, endPosChar
+                            - startOffsetChar, startPosChar, endPosChar,
+                    startOffsetChar, endOffsetChar);
+
+        // TODO: Simplify
+        return new int[] { startPosChar - startOffsetChar,
+                endPosChar - startOffsetChar, -1, 0 };
     };
-    
+
 
     // Identical to Result!
     public String toJsonString () {
-	ObjectNode json = (ObjectNode) mapper.valueToTree(this);
+        ObjectNode json = (ObjectNode) mapper.valueToTree(this);
 
-	// Match was no match
-	if (json.size() == 0)
-	    return "{}";
+        // Match was no match
+        if (json.size() == 0)
+            return "{}";
 
-	if (this.context != null)
-	    json.put("context", this.getContext().toJsonNode());
+        if (this.context != null)
+            json.put("context", this.getContext().toJsonNode());
 
-	if (this.version != null)
-	    json.put("version", this.getVersion());
+        if (this.version != null)
+            json.put("version", this.getVersion());
 
-	try {
-	    return mapper.writeValueAsString(json);
-	}
-	catch (Exception e) {
-	    log.warn(e.getLocalizedMessage());
-	};
+        try {
+            return mapper.writeValueAsString(json);
+        }
+        catch (Exception e) {
+            log.warn(e.getLocalizedMessage());
+        };
 
-	return "{}";
+        return "{}";
     };
 
+
     // Return match as token list
     public ObjectNode toTokenList () {
-	ObjectNode json = mapper.createObjectNode();
+        ObjectNode json = mapper.createObjectNode();
 
-	if (this.getDocID() != null)
-	    json.put("textSigle", this.getDocID());
-	else if (this.getTextSigle() != null)
-	    json.put("textSigle", this.getTextSigle());
+        if (this.getDocID() != null)
+            json.put("textSigle", this.getDocID());
+        else if (this.getTextSigle() != null)
+            json.put("textSigle", this.getTextSigle());
 
-	ArrayNode tokens = json.putArray("tokens");
+        ArrayNode tokens = json.putArray("tokens");
 
-	// Get pto object
-	PositionsToOffset pto = this.positionsToOffset;
+        // Get pto object
+        PositionsToOffset pto = this.positionsToOffset;
 
-	// Add for position retrieval
-	for (int i = this.getStartPos(); i < this.getEndPos(); i++) {
-	    pto.add(this.localDocID, i);
-	};
+        // Add for position retrieval
+        for (int i = this.getStartPos(); i < this.getEndPos(); i++) {
+            pto.add(this.localDocID, i);
+        };
 
-	// Retrieve positions
-	for (int i = this.getStartPos(); i < this.getEndPos(); i++) {
-	    ArrayNode token = tokens.addArray();
-	    for (int offset : pto.span(this.localDocID, i)) {
-		token.add(offset);
-	    };
-	};
+        // Retrieve positions
+        for (int i = this.getStartPos(); i < this.getEndPos(); i++) {
+            ArrayNode token = tokens.addArray();
+            for (int offset : pto.span(this.localDocID, i)) {
+                token.add(offset);
+            };
+        };
 
-	return json;
+        return json;
     };
 
 
     // Remove duplicate identifiers
     // Yeah ... I mean ... why not?
     private void _filterMultipleIdentifiers () {
-	ArrayList<Integer> removeDuplicate = new ArrayList<>(10);
-	HashSet<Integer> identifiers = new HashSet<>(20);
-	for (int i = 0; i < this.span.size(); i++) {
-	    // span is an int array: [Start, End, Number, Dummy]
-	    int highlightNumber = this.span.get(i)[2];
+        ArrayList<Integer> removeDuplicate = new ArrayList<>(10);
+        HashSet<Integer> identifiers = new HashSet<>(20);
+        for (int i = 0; i < this.span.size(); i++) {
+            // span is an int array: [Start, End, Number, Dummy]
+            int highlightNumber = this.span.get(i)[2];
 
-	    // Number is an identifier
-	    if (highlightNumber < -1) {
+            // Number is an identifier
+            if (highlightNumber < -1) {
 
-		// Get the real identifier
-		int idNumber = identifierNumber.get(highlightNumber);
-		if (identifiers.contains(idNumber)) {
-		    removeDuplicate.add(i);
-		}
-		else {
-		    identifiers.add(idNumber);
-		};
-	    };
-	};
+                // Get the real identifier
+                int idNumber = identifierNumber.get(highlightNumber);
+                if (identifiers.contains(idNumber)) {
+                    removeDuplicate.add(i);
+                }
+                else {
+                    identifiers.add(idNumber);
+                };
+            };
+        };
 
-	// Order the duplicates to filter from the tail
-	Collections.sort(removeDuplicate);
-	Collections.reverse(removeDuplicate);
+        // Order the duplicates to filter from the tail
+        Collections.sort(removeDuplicate);
+        Collections.reverse(removeDuplicate);
 
-	// Delete all duplicate identifiers
-	for (int delete : removeDuplicate) {
-	    this.span.remove(delete);
-	};
+        // Delete all duplicate identifiers
+        for (int delete : removeDuplicate) {
+            this.span.remove(delete);
+        };
     };
 
 
@@ -1425,14 +1422,15 @@
      * Get identifier based on class number
      */
     public int getClassID (int nr) {
-	return this.identifierNumber.get(nr);
+        return this.identifierNumber.get(nr);
     };
 
+
     /*
      * Get annotation based on id
      */
     public String getAnnotationID (int nr) {
-	return this.annotationNumber.get(nr);
+        return this.annotationNumber.get(nr);
     };
 
 
@@ -1440,6 +1438,6 @@
      * Get relation based on id
      */
     public Relation getRelationID (int nr) {
-	return this.relationNumber.get(nr);
+        return this.relationNumber.get(nr);
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java b/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
index afab8b7..46ad3dd 100644
--- a/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
+++ b/src/main/java/de/ids_mannheim/korap/response/MatchCollector.java
@@ -1,10 +1,13 @@
 package de.ids_mannheim.korap.response;
+
 import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.response.Response;
 import java.util.*;
 
 public class MatchCollector extends Response {
     public int totalResultDocs = 0;
+
+
     /*
       private int totalResults;
       private long totalTexts;
@@ -15,22 +18,27 @@
         this.incrTotalResults(matchcount);
     };
 
+
     public MatchCollector setTotalResultDocs (int i) {
         this.totalResultDocs = i;
         return this;
     };
 
+
     public MatchCollector incrTotalResultDocs (int i) {
         this.totalResultDocs += i;
         return this;
     };
 
+
     public int getTotalResultDocs () {
         return totalResultDocs;
     };
 
+
     public void commit () {};
 
+
     public void close () {};
 
     /*
diff --git a/src/main/java/de/ids_mannheim/korap/response/Message.java b/src/main/java/de/ids_mannheim/korap/response/Message.java
index c121c9d..cef0150 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Message.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Message.java
@@ -9,15 +9,15 @@
 
 /**
  * A message for Notifications.
- *
+ * 
  * <p>
  * <blockquote><pre>
- *   Message m = new Message();
- *   m.setCode(614);
- *   m.setMessage("This is a new message");
- *   m.addParameter("MyClass");
+ * Message m = new Message();
+ * m.setCode(614);
+ * m.setMessage("This is a new message");
+ * m.addParameter("MyClass");
  * </pre></blockquote>
- *
+ * 
  * @author Nils Diewald
  * @see de.ids_mannheim.korap.response.Messages
  */
@@ -32,19 +32,22 @@
 
     /**
      * Construct a new message object.
-     *
-     * @param code Code number representing the message code
-     * @param msg String representation of the message
+     * 
+     * @param code
+     *            Code number representing the message code
+     * @param msg
+     *            String representation of the message
      * @return The new message object
      */
     public Message (int code, String msg) {
         this.code = code;
-        this.msg  = msg;
+        this.msg = msg;
     };
 
+
     /**
      * Construct a new message object.
-     *
+     * 
      * @return The new empty message object
      */
     public Message () {};
@@ -52,7 +55,7 @@
 
     /**
      * Return the string representation of the message.
-     *
+     * 
      * @return String representation of the message
      */
     @JsonIgnore
@@ -63,8 +66,9 @@
 
     /**
      * Set the string representation of the message.
-     *
-     * @param msg String representation of the message
+     * 
+     * @param msg
+     *            String representation of the message
      * @return Message object for chaining
      */
     @JsonIgnore
@@ -76,7 +80,7 @@
 
     /**
      * Return the integer code representation of the message.
-     *
+     * 
      * @return Integer code representation of the message
      */
     @JsonIgnore
@@ -88,8 +92,9 @@
 
     /**
      * Set the integer representation of the message.
-     *
-     * @param code Integer code representation of the message
+     * 
+     * @param code
+     *            Integer code representation of the message
      * @return Message object for chaining
      */
     @JsonIgnore
@@ -101,7 +106,7 @@
 
     /**
      * Add additional string parameters to the message.
-     *
+     * 
      * @return Message object for chaining
      */
     public Message addParameter (String param) {
@@ -114,9 +119,10 @@
 
     /**
      * Create a clone of the Message.
-     *
-     * @return The cloned message object 
-     * @throws CloneNotSupportedException if message can't be cloned
+     * 
+     * @return The cloned message object
+     * @throws CloneNotSupportedException
+     *             if message can't be cloned
      */
     public Object clone () throws CloneNotSupportedException {
         Message clone = new Message();
@@ -127,7 +133,7 @@
 
         // Copy message code
         clone.code = this.code;
-        
+
         // Copy parameters
         if (this.parameters != null) {
             for (String p : this.parameters) {
@@ -138,9 +144,10 @@
         return clone;
     };
 
+
     /**
      * Serialize Message as a JsonNode.
-     *
+     * 
      * @return JsonNode representation of the message
      */
     public JsonNode toJsonNode () {
@@ -148,7 +155,7 @@
 
         if (this.code != 0)
             message.add(this.getCode());
-        
+
         message.add(this.getMessage());
         if (parameters != null)
             for (String p : parameters)
@@ -163,7 +170,7 @@
      * <blockquote><pre>
      * [123, "You are not allowed to serialize these messages"]
      * </pre></blockquote>
-     *
+     * 
      * @return String representation of the message
      */
     public String toJsonString () {
@@ -175,8 +182,6 @@
             // Bad in case the message contains quotes!
             msg = ", \"" + e.getLocalizedMessage() + "\"";
         };
-        return
-            "[620, " +
-            "\"Unable to generate JSON\"" + msg + "]";
+        return "[620, " + "\"Unable to generate JSON\"" + msg + "]";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/Messages.java b/src/main/java/de/ids_mannheim/korap/response/Messages.java
index 2881185..d9d0627 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Messages.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Messages.java
@@ -13,13 +13,13 @@
 
 /**
  * A list of messages for Notifications.
- *
+ * 
  * <p>
  * <blockquote><pre>
- *   Messages m = new Messages();
- *   m.add(614, "This is a new message");
+ * Messages m = new Messages();
+ * m.add(614, "This is a new message");
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  * @see Notifications
  * @see Message
@@ -36,21 +36,25 @@
     private class MessageIterator implements Iterator<Message> {
         int index;
 
+
         // Constructor
         public MessageIterator () {
             this.index = 0;
         };
 
+
         @Override
         public boolean hasNext () {
             return this.index < messages.size();
         };
 
+
         @Override
         public Message next () {
             return messages.get(this.index++);
         };
 
+
         @Override
         public void remove () {
             messages.remove(this.index);
@@ -68,25 +72,26 @@
 
     /**
      * Get the iterator object.
-     *
+     * 
      * @return Iterator for Message object.
      */
-    public Iterator<Message> iterator() {
+    public Iterator<Message> iterator () {
         return new MessageIterator();
     };
 
 
     /**
      * Append a new message.
-     *
-     * @param code  Integer code representation of the warning
-     * @param msg   String representation of the warning
-     * @param terms Optional strings of additional information
+     * 
+     * @param code
+     *            Integer code representation of the warning
+     * @param msg
+     *            String representation of the warning
+     * @param terms
+     *            Optional strings of additional information
      * @return New Message object
      */
-    public Message add (int code,
-                        String message,
-                        String ... terms) {
+    public Message add (int code, String message, String ... terms) {
         Message newMsg = new Message(code, message);
         messages.add(newMsg);
         if (terms != null)
@@ -98,8 +103,9 @@
 
     /**
      * Append an existing message.
-     *
-     * @param msg Message object to be added. Message will be cloned.
+     * 
+     * @param msg
+     *            Message object to be added. Message will be cloned.
      * @return Cloned Message object
      */
     public Message add (Message msg) {
@@ -108,23 +114,24 @@
             messages.add(msgClone);
             return msgClone;
         }
-        catch (CloneNotSupportedException e) {
-        };
+        catch (CloneNotSupportedException e) {};
         return (Message) null;
     };
 
+
     /**
      * Append an existing message comming from a JsonNode.
-     *
-     * @param node  <code>JsonNode</code> representing a message
+     * 
+     * @param node
+     *            <code>JsonNode</code> representing a message
      * @return New Message object
-     * @throws QueryException if notification is not well formed (Error 750)
+     * @throws QueryException
+     *             if notification is not well formed (Error 750)
      */
     public Message add (JsonNode msg) throws QueryException {
         if (!msg.isArray() || !msg.has(0))
-            throw new QueryException(
-                750, "Passed notifications are not well formed"
-            );
+            throw new QueryException(750,
+                    "Passed notifications are not well formed");
 
         // Valid message
         Message newMsg = new Message();
@@ -132,9 +139,8 @@
         if (msg.get(0).isNumber()) {
             newMsg.setCode(msg.get(0).asInt());
             if (!msg.has(1))
-                throw new QueryException(
-                    750, "Passed notifications are not well formed"
-	            );
+                throw new QueryException(750,
+                        "Passed notifications are not well formed");
             newMsg.setMessage(msg.get(1).asText());
             i++;
         }
@@ -145,7 +151,7 @@
         // Add parameters
         while (msg.has(i))
             newMsg.addParameter(msg.get(i++).asText());
-        
+
         // Add messages to list
         this.add(newMsg);
         return newMsg;
@@ -154,8 +160,10 @@
 
     /**
      * Append existing messages.
-     *
-     * @param msgs Messages object to be added. Messages will be cloned.
+     * 
+     * @param msgs
+     *            Messages object to be added. Messages will be
+     *            cloned.
      * @return Messages object for chaining.
      */
     public Messages add (Messages msgs) {
@@ -163,15 +171,14 @@
             for (Message msg : msgs.getMessages())
                 this.add((Message) msg.clone());
         }
-        catch (CloneNotSupportedException e) {
-        };
+        catch (CloneNotSupportedException e) {};
         return this;
     };
 
 
     /**
      * Clear all messages.
-     *
+     * 
      * @return Messages object for chaining
      */
     public Messages clear () {
@@ -182,8 +189,9 @@
 
     /**
      * Get the number of the messages.
-     *
-     * @param Integer representing the number of messages in the list.
+     * 
+     * @param Integer
+     *            representing the number of messages in the list.
      */
     public int size () {
         return this.messages.size();
@@ -192,9 +200,11 @@
 
     /**
      * Return a specific message based on an index.
-     *
-     * @param index The index of the message in the list of messages.
-     * @return The message in case it exists, otherwise <code>null</code>
+     * 
+     * @param index
+     *            The index of the message in the list of messages.
+     * @return The message in case it exists, otherwise
+     *         <code>null</code>
      */
     @JsonIgnore
     public Message get (int index) {
@@ -206,7 +216,7 @@
 
     /**
      * Return all messages.
-     *
+     * 
      * @return List of all Message objects
      */
     @JsonIgnore
@@ -217,9 +227,10 @@
 
     /**
      * Create a clone of the Messages.
-     *
-     * @return The cloned messages object 
-     * @throws CloneNotSupportedException if messages can't be cloned
+     * 
+     * @return The cloned messages object
+     * @throws CloneNotSupportedException
+     *             if messages can't be cloned
      */
     public Object clone () throws CloneNotSupportedException {
         Messages clone = new Messages();
@@ -233,7 +244,7 @@
 
     /**
      * Serialize Messages as a JsonNode.
-     *
+     * 
      * @return JsonNode representation of all messages
      */
     public JsonNode toJsonNode () {
@@ -249,11 +260,11 @@
      * <p>
      * <blockquote><pre>
      * [
-     *   [123, "You are not allowed to serialize these messages"],
-     *   [124, "Your request was invalid"]
+     * [123, "You are not allowed to serialize these messages"],
+     * [124, "Your request was invalid"]
      * ]
      * </pre></blockquote>
-     *
+     * 
      * @return String representation of all messages
      */
     public String toJsonString () {
@@ -266,8 +277,6 @@
             msg = ", \"" + e.getLocalizedMessage() + "\"";
         };
 
-        return
-            "[620, " +
-            "\"Unable to generate JSON\"" + msg + "]";
+        return "[620, " + "\"Unable to generate JSON\"" + msg + "]";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/Notifications.java b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
index e99d515..0485a0e 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Notifications.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
@@ -15,22 +15,22 @@
 /**
  * A unified notification class for KorAP related errors,
  * warnings and messages.
- *
+ * 
  * <p>
  * The object contains lists of errors, warnings and messages
  * and new warnings, errors or messages are appended to these lists.
- *
+ * 
  * <p>
  * <blockquote><pre>
- *   Notifications n = new Notifications();
- *   n.addWarning(456, "Something went wrong");
- *   if (n.hasWarnings()) {
- *     for (Message msg : n.getWarnings())
- *       System.err.out(msg.getCode() + ": " + msg.getMessage());
- *   };
- *   System.err.println(n.toJsonString());
+ * Notifications n = new Notifications();
+ * n.addWarning(456, "Something went wrong");
+ * if (n.hasWarnings()) {
+ * for (Message msg : n.getWarnings())
+ * System.err.out(msg.getCode() + ": " + msg.getMessage());
+ * };
+ * System.err.println(n.toJsonString());
  * </pre></blockquote>
- *
+ * 
  * @author Nils Diewald
  * @see de.ids_mannheim.korap.response.Messages
  */
@@ -47,10 +47,12 @@
 
     private Messages warnings, errors, messages;
 
+
     /**
      * Check for warnings.
-     *
-     * @return <tt>true</tt> in case there are warnings, otherwise <tt>false</tt>
+     * 
+     * @return <tt>true</tt> in case there are warnings, otherwise
+     *         <tt>false</tt>
      */
     public boolean hasWarnings () {
         if (this.warnings == null || this.warnings.size() == 0)
@@ -61,7 +63,7 @@
 
     /**
      * Return all warnings.
-     *
+     * 
      * @return {@link Messages} representing all warnings
      */
     public Messages getWarnings () {
@@ -71,8 +73,9 @@
 
     /**
      * Set warnings by means of a {@link JsonNode}.
-     *
-     * @param msgs JSON array of warnings.
+     * 
+     * @param msgs
+     *            JSON array of warnings.
      * @return {@link Notifications} object for chaining.
      */
     public Notifications setWarnings (JsonNode msgs) {
@@ -85,9 +88,11 @@
 
     /**
      * Return a specific warning based on an index.
-     *
-     * @param index The index of the warning in the list of warnings.
-     * @return The message in case it exists, otherwise <code>null</code>
+     * 
+     * @param index
+     *            The index of the warning in the list of warnings.
+     * @return The message in case it exists, otherwise
+     *         <code>null</code>
      */
     public Message getWarning (int index) {
         if (this.warnings != null)
@@ -98,10 +103,13 @@
 
     /**
      * Appends a new warning.
-     *
-     * @param code  Integer code representation of the warning
-     * @param msg   String representation of the warning
-     * @param terms Optional strings of additional information
+     * 
+     * @param code
+     *            Integer code representation of the warning
+     * @param msg
+     *            String representation of the warning
+     * @param terms
+     *            Optional strings of additional information
      * @return Notification object for chaining
      */
     public Notifications addWarning (int code, String msg, String ... terms) {
@@ -111,31 +119,34 @@
         return this;
     };
 
+
     /**
      * Appends a new warning.
-     *
-     * @param node  {@link JsonNode} representing a warning message
+     * 
+     * @param node
+     *            {@link JsonNode} representing a warning message
      * @return Notification object for chaining
      */
     public Notifications addWarning (JsonNode node) {
         if (this.warnings == null)
             this.warnings = new Messages();
-    
+
         try {
             this.warnings.add(node);
         }
         catch (QueryException qe) {
             this.warnings.add(qe.getErrorCode(), qe.getMessage());
         };
-        
+
         return this;
     };
 
 
     /**
      * Appends new warnings.
-     *
-     * @param msgs  {@link Messages} representing multiple warnings
+     * 
+     * @param msgs
+     *            {@link Messages} representing multiple warnings
      * @return Notification object for chaining
      */
     public Notifications addWarnings (Messages msgs) {
@@ -149,7 +160,7 @@
 
     /**
      * Return all errors.
-     *
+     * 
      * @return The {@link Messages} object representing all errors
      */
     public Messages getErrors () {
@@ -159,8 +170,9 @@
 
     /**
      * Set errors by means of a {@link JsonNode}.
-     *
-     * @param msgs JSON array of errors.
+     * 
+     * @param msgs
+     *            JSON array of errors.
      * @return Notifications object for chaining.
      */
     public Notifications setErrors (JsonNode msgs) {
@@ -172,9 +184,11 @@
 
     /**
      * Return a specific error based on an index.
-     *
-     * @param index The index of the error in the list of errors.
-     * @return The message in case it exists, otherwise <code>null</code>
+     * 
+     * @param index
+     *            The index of the error in the list of errors.
+     * @return The message in case it exists, otherwise
+     *         <code>null</code>
      */
     public Message getError (int index) {
         if (this.errors != null)
@@ -185,8 +199,9 @@
 
     /**
      * Check for errors.
-     *
-     * @return <tt>true</tt> in case there are errors, otherwise <tt>false</tt>
+     * 
+     * @return <tt>true</tt> in case there are errors, otherwise
+     *         <tt>false</tt>
      */
     public boolean hasErrors () {
         if (this.errors == null || this.errors.size() == 0)
@@ -197,10 +212,13 @@
 
     /**
      * Appends a new error.
-     *
-     * @param code  Integer code representation of the error
-     * @param msg   String representation of the error
-     * @param terms Optional strings of additional information
+     * 
+     * @param code
+     *            Integer code representation of the error
+     * @param msg
+     *            String representation of the error
+     * @param terms
+     *            Optional strings of additional information
      * @return Notification object for chaining
      */
     public Notifications addError (int code, String msg, String ... terms) {
@@ -213,8 +231,9 @@
 
     /**
      * Appends a new error.
-     *
-     * @param node  {@link JsonNode} representing an error message
+     * 
+     * @param node
+     *            {@link JsonNode} representing an error message
      * @return Notification object for chaining
      */
     public Notifications addError (JsonNode msg) {
@@ -226,15 +245,16 @@
         catch (QueryException qe) {
             this.errors.add(qe.getErrorCode(), qe.getMessage());
         };
-        
+
         return this;
     };
 
 
     /**
      * Appends new errors.
-     *
-     * @param msgs  {@link Messages} representing multiple errors
+     * 
+     * @param msgs
+     *            {@link Messages} representing multiple errors
      * @return Notification object for chaining
      */
     public Notifications addErrors (Messages msgs) {
@@ -248,7 +268,7 @@
 
     /**
      * Return all messages.
-     *
+     * 
      * @return {@link Messages} representing all messages
      */
     public Messages getMessages () {
@@ -258,8 +278,9 @@
 
     /**
      * Set messages by means of a {@link JsonNode}.
-     *
-     * @param msgs JSON array of messages.
+     * 
+     * @param msgs
+     *            JSON array of messages.
      * @return Notifications object for chaining.
      */
     public Notifications setMessages (JsonNode msgs) {
@@ -271,9 +292,11 @@
 
     /**
      * Return a specific message based on an index.
-     *
-     * @param index The index of the message in the list of messages.
-     * @return The message in case it exists, otherwise <code>null</code>
+     * 
+     * @param index
+     *            The index of the message in the list of messages.
+     * @return The message in case it exists, otherwise
+     *         <code>null</code>
      */
     public Message getMessage (int index) {
         if (this.messages != null)
@@ -284,8 +307,9 @@
 
     /**
      * Check for messages.
-     *
-     * @return <tt>true</tt> in case there are messages, otherwise <tt>false</tt>
+     * 
+     * @return <tt>true</tt> in case there are messages, otherwise
+     *         <tt>false</tt>
      */
     public boolean hasMessages () {
         if (this.messages == null || this.messages.size() == 0)
@@ -296,10 +320,13 @@
 
     /**
      * Appends a new message.
-     *
-     * @param code  Integer code representation of the message
-     * @param msg   String representation of the message
-     * @param terms Optional strings of additional information
+     * 
+     * @param code
+     *            Integer code representation of the message
+     * @param msg
+     *            String representation of the message
+     * @param terms
+     *            Optional strings of additional information
      * @return Notification object for chaining
      */
     public Notifications addMessage (int code, String msg, String ... terms) {
@@ -312,8 +339,9 @@
 
     /**
      * Appends a new message.
-     *
-     * @param node  {@link JsonNode} representing a message
+     * 
+     * @param node
+     *            {@link JsonNode} representing a message
      * @return Notification object for chaining
      */
     public Notifications addMessage (JsonNode msg) {
@@ -331,8 +359,9 @@
 
     /**
      * Appends new messages.
-     *
-     * @param msgs  {@link Messages} representing multiple messages
+     * 
+     * @param msgs
+     *            {@link Messages} representing multiple messages
      * @return Notification object for chaining
      */
     public Notifications addMessages (Messages msgs) {
@@ -346,8 +375,9 @@
 
     /**
      * Copy notifications from another notification object.
-     *
-     * @param notes Notification object to copy notifications from.
+     * 
+     * @param notes
+     *            Notification object to copy notifications from.
      * @return Notification object for chaining
      */
     public Notifications copyNotificationsFrom (Notifications notes) {
@@ -359,31 +389,29 @@
             if (notes.hasMessages())
                 this.addMessages((Messages) notes.getMessages().clone());
         }
-        catch (CloneNotSupportedException cnse) {
-        };
+        catch (CloneNotSupportedException cnse) {};
         return this;
     };
 
 
     /**
      * Copy notifications from a {@link JsonNode} object.
-     *
-     * @param request Notifications containing {@link JsonNode}.
+     * 
+     * @param request
+     *            Notifications containing {@link JsonNode}.
      * @return Notification object for chaining
      */
     public Notifications copyNotificationsFrom (JsonNode request) {
 
         // Add warnings from JSON
-        if (request.has("warnings") &&
-            request.get("warnings").isArray()) {
+        if (request.has("warnings") && request.get("warnings").isArray()) {
             JsonNode msgs = request.get("warnings");
             for (JsonNode msg : msgs)
                 this.addWarning(msg);
         };
 
         // Add messages from JSON
-        if (request.has("messages") &&
-            request.get("messages").isArray()) {
+        if (request.has("messages") && request.get("messages").isArray()) {
             JsonNode msgs = request.get("messages");
             if (msgs.isArray())
                 for (JsonNode msg : msgs)
@@ -391,14 +419,13 @@
         };
 
         // Add errors from JSON
-        if (request.has("errors") &&
-            request.get("errors").isArray()) {
+        if (request.has("errors") && request.get("errors").isArray()) {
             JsonNode msgs = request.get("errors");
             if (msgs.isArray())
                 for (JsonNode msg : msgs)
                     this.addError(msg);
         };
-        
+
         return this;
     };
 
@@ -406,8 +433,9 @@
     /**
      * Move notifications from a passed {@link Notification} object
      * to the invocant.
-     *
-     * @param notes Notification object.
+     * 
+     * @param notes
+     *            Notification object.
      * @return The invocant object for chaining
      */
     public Notifications moveNotificationsFrom (Notifications notes) {
@@ -419,7 +447,7 @@
 
     /**
      * Clear all notifications.
-     *
+     * 
      * @return Notification object for chaining
      */
     public Notifications clearNotifications () {
@@ -436,12 +464,12 @@
 
     /**
      * Serialize Notifications as a {@link JsonNode}.
-     *
+     * 
      * @return {@link JsonNode} representation of all warnings,
      *         errors, and messages.
      */
     public JsonNode toJsonNode () {
-        ObjectNode json =  mapper.createObjectNode();
+        ObjectNode json = mapper.createObjectNode();
 
         // Add messages
         if (this.hasWarnings())
@@ -450,7 +478,7 @@
             json.put("errors", this.getErrors().toJsonNode());
         if (this.hasMessages())
             json.put("messages", this.getMessages().toJsonNode());
-        
+
         return (JsonNode) json;
     };
 
@@ -460,17 +488,18 @@
      * <p>
      * <blockquote><pre>
      * {
-     *   "errors": [
-     *     [123, "You are not allowed to serialize these messages"],
-     *     [124, "Your request was invalid"]
-     *   ],
-     *   "messages" : [
-     *     [125, "Class is deprecated", "Notifications"]
-     *   ]
+     * "errors": [
+     * [123, "You are not allowed to serialize these messages"],
+     * [124, "Your request was invalid"]
+     * ],
+     * "messages" : [
+     * [125, "Class is deprecated", "Notifications"]
+     * ]
      * }
      * </pre></blockquote>
-     *
-     * @return String representation of all warnings, errors, and messages
+     * 
+     * @return String representation of all warnings, errors, and
+     *         messages
      */
     public String toJsonString () {
         String msg = "";
@@ -485,10 +514,7 @@
             msg = ", \"" + e.getLocalizedMessage() + "\"";
         };
 
-        return
-            "{\"errors\" : [" +
-            "[620, " +
-            "\"Unable to generate JSON\"" + msg + "]" +
-            "]}";
+        return "{\"errors\" : [" + "[620, " + "\"Unable to generate JSON\""
+                + msg + "]" + "]}";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/Response.java b/src/main/java/de/ids_mannheim/korap/response/Response.java
index 9e2e603..576d2ad 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Response.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Response.java
@@ -17,15 +17,15 @@
 /**
  * Base class for objects meant to be responded by the server.
  * This inherits KoralQuery requests.
- *
+ * 
  * <p>
  * <blockquote><pre>
- *   Response km = new Response();
- *   System.out.println(
- *     km.toJsonString()
- *   );
+ * Response km = new Response();
+ * System.out.println(
+ * km.toJsonString()
+ * );
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  * @see Notifications
  */
@@ -41,9 +41,8 @@
     private String version, name, node, listener;
     private KrillQuery query;
 
-    private long
-        totalResources = -2, // Not set
-        totalResults   = -2; // Not set
+    private long totalResources = -2, // Not set
+            totalResults = -2; // Not set
     private String benchmark;
     private boolean timeExceeded = false;
 
@@ -56,7 +55,7 @@
 
     /**
      * Get string representation of the backend's version.
-     *
+     * 
      * @return String representation of the backend's version
      */
     public String getVersion () {
@@ -66,8 +65,9 @@
 
     /**
      * Set the string representation of the backend's version.
-     *
-     * @param version The string representation of the backend's version
+     * 
+     * @param version
+     *            The string representation of the backend's version
      * @return Response object for chaining
      */
     public Response setVersion (String fullVersion) {
@@ -89,7 +89,7 @@
     /**
      * Get string representation of the backend's name.
      * All nodes in a cluster should have the same backend name.
-     *
+     * 
      * @return String representation of the backend's name
      */
     public String getName () {
@@ -100,8 +100,9 @@
     /**
      * Set the string representation of the backend's name.
      * All nodes in a cluster should have the same backend name.
-     *
-     * @param name The string representation of the backend's name
+     * 
+     * @param name
+     *            The string representation of the backend's name
      * @return Response object for chaining
      */
     public Response setName (String name) {
@@ -113,7 +114,7 @@
     /**
      * Get string representation of the node's name.
      * Each node in a cluster has a unique name.
-     *
+     * 
      * @return String representation of the node's name
      */
     public String getNode () {
@@ -124,8 +125,9 @@
     /**
      * Set the string representation of the node's name.
      * Each node in a cluster has a unique name.
-     *
-     * @param version The string representation of the node's name
+     * 
+     * @param version
+     *            The string representation of the node's name
      * @return Response object for chaining
      */
     public Response setNode (String name) {
@@ -136,7 +138,7 @@
 
     /**
      * Check if the response time was exceeded.
-     *
+     * 
      * @return <tt>true</tt> in case the response had a timeout,
      *         otherwise <tt>false</tt>
      */
@@ -144,17 +146,18 @@
     public boolean hasTimeExceeded () {
         return this.timeExceeded;
     };
-    
+
 
     /**
      * Set to <tt>true</tt> if time is exceeded
      * based on a timeout.
-     *
+     * 
      * <p>
      * Will add a warning (682) to the output.
-     *
-     * @param timeout Either <tt>true</tt> or <tt>false</tt>,
-     * in case the response timed out
+     * 
+     * @param timeout
+     *            Either <tt>true</tt> or <tt>false</tt>,
+     *            in case the response timed out
      * @return Response object for chaining
      */
     public Response setTimeExceeded (boolean timeout) {
@@ -167,50 +170,53 @@
 
     /**
      * Get the benchmark time as a string.
-     *
+     * 
      * @return String representation of the benchmark
      *         (including trailing time unit)
      */
     public String getBenchmark () {
         return this.benchmark;
     };
-    
+
 
     /**
      * Set the benchmark as timestamp differences.
-     *
-     * @param ts1 Starting time of the benchmark
-     * @param ts2 Ending time of the benchmark
+     * 
+     * @param ts1
+     *            Starting time of the benchmark
+     * @param ts2
+     *            Ending time of the benchmark
      * @return Response object for chaining
      */
     @JsonIgnore
     public Response setBenchmark (long ts1, long ts2) {
-        this.benchmark =
-            (ts2 - ts1) < 100_000_000 ?
-            // Store as miliseconds
-            (((double) (ts2 - ts1) * 1e-6) + " ms") :
-            // Store as seconds
-            (((double) (ts2 - ts1) / 1000000000.0) + " s");
+        this.benchmark = (ts2 - ts1) < 100_000_000 ?
+        // Store as miliseconds
+        (((double) (ts2 - ts1) * 1e-6) + " ms")
+                :
+                // Store as seconds
+                (((double) (ts2 - ts1) / 1000000000.0) + " s");
         return this;
     };
-    
+
 
     /**
      * Set the benchmark as a string representation.
-     *
-     * @param bm String representation of a benchmark
-     *           (including trailing time unit)
+     * 
+     * @param bm
+     *            String representation of a benchmark
+     *            (including trailing time unit)
      * @return Response for chaining
      */
     public Response setBenchmark (String bm) {
         this.benchmark = bm;
         return this;
     };
-    
+
 
     /**
      * Get the listener URI as a string.
-     *
+     * 
      * @return The listener URI as a string representation
      */
     public String getListener () {
@@ -219,15 +225,17 @@
 
 
     /**
-     * Set the listener URI as a String. This is probably the localhost
+     * Set the listener URI as a String. This is probably the
+     * localhost
      * with an arbitrary port, like
-     *
+     * 
      * <p>
      * <blockquote><pre>
-     *   http://localhost:8080/
+     * http://localhost:8080/
      * </pre></blockquote>
-     *
-     * @param listener String representation of the listener URI
+     * 
+     * @param listener
+     *            String representation of the listener URI
      * @return Response object for chaining
      */
     public Response setListener (String listener) {
@@ -238,7 +246,7 @@
 
     /**
      * Get the total number of results.
-     *
+     * 
      * @return The total number of results.
      */
     public long getTotalResults () {
@@ -250,8 +258,9 @@
 
     /**
      * Set the total number of results.
-     *
-     * @param results The total number of results.
+     * 
+     * @param results
+     *            The total number of results.
      * @return {link Response} object for chaining.
      */
     public Response setTotalResults (long results) {
@@ -262,9 +271,10 @@
 
     /**
      * Increment the total number of results by a certain value.
-     *
-     * @param incr The number of results the total number should
-     *        be incremented by.
+     * 
+     * @param incr
+     *            The number of results the total number should
+     *            be incremented by.
      * @return {@link Response} object for chaining.
      */
     public Response incrTotalResults (int incr) {
@@ -279,7 +289,7 @@
     /**
      * Get the total number of resources the total number of
      * results occur in.
-     *
+     * 
      * @return The total number of resources the total number of
      *         results occur in.
      */
@@ -293,9 +303,10 @@
     /**
      * Set the total number of resources the total number of
      * results occur in.
-     *
-     * @param resources The total number of resources the total
-     *        number of results occur in.
+     * 
+     * @param resources
+     *            The total number of resources the total
+     *            number of results occur in.
      * @return {@link Response} object for chaining.
      */
     public Response setTotalResources (long resources) {
@@ -307,10 +318,11 @@
     /**
      * Increment the total number of resources the total number
      * of results occur in by a certain value.
-     *
-     * @param incr The number of resources the total number of
-     *        results occur in should be incremented by.
-     *        (I don't care that this isn't English!)
+     * 
+     * @param incr
+     *            The number of resources the total number of
+     *            results occur in should be incremented by.
+     *            (I don't care that this isn't English!)
      * @return {@link Response} object for chaining.
      */
     public Response incrTotalResources (int i) {
@@ -324,7 +336,7 @@
 
     /**
      * Get the KoralQuery query object.
-     *
+     * 
      * @return The {@link KrillQuery} object,
      *         representing the KoralQuery query object.
      */
@@ -339,9 +351,10 @@
 
     /**
      * Set the KoralQuery query object.
-     *
-     * @param query The {@link KrillQuery} object,
-     *        representing the KoralQuery query object.
+     * 
+     * @param query
+     *            The {@link KrillQuery} object,
+     *            representing the KoralQuery query object.
      * @return The {@link Response} object for chaining
      */
     @JsonIgnore
@@ -357,7 +370,7 @@
      * Get the associated collection object.
      * In case no collection information was defined yet,
      * a new {@link KrillCollection} object will be created.
-     *
+     * 
      * @return The attached {@link KrillCollection} object.
      */
     @JsonIgnore
@@ -370,24 +383,25 @@
 
     /**
      * Set a new {@link KrillCollection} object.
-     *
-     * @param collection A {@link KrillCollection} object.
+     * 
+     * @param collection
+     *            A {@link KrillCollection} object.
      * @return The {@link Response} object for chaining
      */
     @JsonIgnore
     public Response setCollection (KrillCollection collection) {
         this.collection = collection;
-        
+
         // Move messages from the collection
         return (Response) this.moveNotificationsFrom(collection);
     };
 
-    
+
     /**
      * Get the associated meta object.
      * In case no meta information was defined yet,
      * a new {@link KrillMeta} object will be created.
-     *
+     * 
      * @return The attached {@link KrillMeta} object.
      */
     @JsonIgnore
@@ -400,14 +414,15 @@
 
     /**
      * Set a new {@link KrillMeta} object.
-     *
-     * @param meta A {@link KrillMeta} object.
+     * 
+     * @param meta
+     *            A {@link KrillMeta} object.
      * @return The {@link Response} object for chaining
      */
     @JsonIgnore
     public Response setMeta (KrillMeta meta) {
         this.meta = meta;
-        
+
         // Move messages from the collection
         return (Response) this.moveNotificationsFrom(meta);
     };
@@ -415,7 +430,7 @@
 
     /**
      * Serialize response as a {@link JsonNode}.
-     *
+     * 
      * @return {@link JsonNode} representation of the response
      */
     @Override
@@ -427,7 +442,7 @@
         StringBuilder sb = new StringBuilder();
         if (this.getName() != null) {
             sb.append(this.getName());
-            
+
             if (this.getVersion() != null)
                 sb.append("-");
         };
@@ -438,10 +453,10 @@
 
         if (sb.length() > 0)
             json.put("version", sb.toString());
-        
+
         if (this.timeExceeded)
             json.put("timeExceeded", true);
-        
+
         if (this.getNode() != null)
             json.put("node", this.getNode());
 
@@ -454,7 +469,7 @@
         // totalResources is set
         if (this.totalResources != -2)
             json.put("totalResources", this.totalResources);
-        
+
         // totalResults is set
         if (this.totalResults != -2)
             json.put("totalResults", this.totalResults);
@@ -474,8 +489,8 @@
         };
 
         // KoralQuery collection object
-        if (this.collection != null &&
-            this.collection.getFilters().toArray().length > 0) {
+        if (this.collection != null
+                && this.collection.getFilters().toArray().length > 0) {
             JsonNode collNode = this.collection.toJsonNode();
             if (collNode != null)
                 json.put("collection", collNode);
@@ -490,21 +505,21 @@
      * <p>
      * <blockquote><pre>
      * {
-     *   "version" : "Lucene-Backend-0.49.1",
-     *   "timeExceeded" : true,
-     *   "node" : "Tanja",
-     *   "listener" : "http://localhost:8080/",
-     *   "benchmark" : "12.3s",
-     *   "errors": [
-     *     [123, "You are not allowed to serialize these messages"],
-     *     [124, "Your request was invalid"]
-     *   ],
-     *   "messages" : [
-     *     [125, "Class is deprecated", "Notifications"]
-     *   ]
+     * "version" : "Lucene-Backend-0.49.1",
+     * "timeExceeded" : true,
+     * "node" : "Tanja",
+     * "listener" : "http://localhost:8080/",
+     * "benchmark" : "12.3s",
+     * "errors": [
+     * [123, "You are not allowed to serialize these messages"],
+     * [124, "Your request was invalid"]
+     * ],
+     * "messages" : [
+     * [125, "Class is deprecated", "Notifications"]
+     * ]
      * }
      * </pre></blockquote>
-     *
+     * 
      * @return String representation of the response
      */
     public String toJsonString () {
@@ -517,10 +532,7 @@
             msg = ", \"" + e.getLocalizedMessage() + "\"";
         };
 
-        return
-            "{\"errors\":["+
-            "[620, " +
-            "\"Unable to generate JSON\"" + msg + "]" +
-            "]}";
+        return "{\"errors\":[" + "[620, " + "\"Unable to generate JSON\"" + msg
+                + "]" + "]}";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/Result.java b/src/main/java/de/ids_mannheim/korap/response/Result.java
index 23bbcca..e6df367 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Result.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Result.java
@@ -28,9 +28,9 @@
 */
 /**
  * Response class for search results.
- *
+ * 
  * TODO: Synopsis and let it base on KoralQuery
- *
+ * 
  * @author diewald
  * @see Response
  */
@@ -40,7 +40,7 @@
     ObjectMapper mapper = new ObjectMapper();
 
     @JsonIgnore
-    public static final short ITEMS_PER_PAGE     = 25;
+    public static final short ITEMS_PER_PAGE = 25;
     public static final short ITEMS_PER_PAGE_MAX = 100;
 
     private int startIndex = 0;
@@ -50,9 +50,7 @@
 
     private SearchContext context;
 
-    private short
-        itemsPerPage     = ITEMS_PER_PAGE,
-        itemsPerResource = 0;
+    private short itemsPerPage = ITEMS_PER_PAGE, itemsPerResource = 0;
 
     private JsonNode request;
 
@@ -64,23 +62,25 @@
     /**
      * Construct a new Result object.
      */
-    public Result() {
+    public Result () {
         mapper.enable(SerializationFeature.INDENT_OUTPUT);
     };
 
 
     /**
      * Construct a new Result object.
-     *
-     * @param serialQuery Query representation as a string.
-     * @param startIndex Offset position in match array.
-     * @param itemsPerPage Number of matches per page.
-     * @param context Requested {@link SearchContext}
+     * 
+     * @param serialQuery
+     *            Query representation as a string.
+     * @param startIndex
+     *            Offset position in match array.
+     * @param itemsPerPage
+     *            Number of matches per page.
+     * @param context
+     *            Requested {@link SearchContext}
      */
-    public Result(String query,
-                       int startIndex,
-                       short itemsPerPage,
-                       SearchContext context) {
+    public Result (String query, int startIndex, short itemsPerPage,
+                   SearchContext context) {
 
         mapper.enable(SerializationFeature.INDENT_OUTPUT);
         // mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
@@ -89,17 +89,17 @@
         this.matches = new ArrayList<>(itemsPerPage);
         this.serialQuery = query;
         this.startIndex = startIndex;
-        this.itemsPerPage =
-            (itemsPerPage > ITEMS_PER_PAGE_MAX || itemsPerPage < 1) ?
-            ITEMS_PER_PAGE : itemsPerPage;
+        this.itemsPerPage = (itemsPerPage > ITEMS_PER_PAGE_MAX || itemsPerPage < 1) ? ITEMS_PER_PAGE
+                : itemsPerPage;
         this.context = context;
     };
 
 
     /**
      * Add a new match to the result set.
-     *
-     * @param match A {@link Match} to add.
+     * 
+     * @param match
+     *            A {@link Match} to add.
      */
     public void add (Match km) {
         this.matches.add(km);
@@ -108,7 +108,7 @@
 
     /**
      * Get the number of items (documents) shown per page.
-     *
+     * 
      * @return Number of items shown per page.
      */
     public short getItemsPerPage () {
@@ -118,8 +118,9 @@
 
     /**
      * Set the number of items (documents) shown per page.
-     *
-     * @param count Number of items shown per page.
+     * 
+     * @param count
+     *            Number of items shown per page.
      * @return {@link Result} object for chaining.
      */
     public Result setItemsPerPage (short count) {
@@ -130,7 +131,7 @@
 
     /**
      * Get serialized query as a {@link JsonNode}.
-     *
+     * 
      * @return {@link JsonNode} representation of the query object.
      */
     public JsonNode getRequest () {
@@ -140,10 +141,11 @@
 
     /**
      * Set serialized query as a {@link JsonNode}.
-     *
-     * @param request {@link JsonNode} representation of the query object.
+     * 
+     * @param request
+     *            {@link JsonNode} representation of the query object.
      * @return {@link Result} object for chaining.
-     */    
+     */
     public Result setRequest (JsonNode request) {
         this.request = request;
         return this;
@@ -153,7 +155,7 @@
     /**
      * Get the number of items shown per resource (document).
      * Defaults to <tt>0</tt>, which is infinite.
-     *
+     * 
      * @return The number of items shown per resource.
      */
     public short getItemsPerResource () {
@@ -164,8 +166,9 @@
     /**
      * Set the number of items (matches) shown per resource (text).
      * Defaults to <tt>0</tt>, which is infinite.
-     *
-     * @param value The number of items shown per resource.
+     * 
+     * @param value
+     *            The number of items shown per resource.
      * @return {@link Result} object for chaining.
      */
     public Result setItemsPerResource (short value) {
@@ -175,10 +178,12 @@
 
 
     /**
-     * Set the number of items (matches) shown per resource (document).
+     * Set the number of items (matches) shown per resource
+     * (document).
      * Defaults to <tt>0</tt>, which is infinite.
-     *
-     * @param value The number of items shown per resource.
+     * 
+     * @param value
+     *            The number of items shown per resource.
      * @return {@link Result} object for chaining.
      */
     public Result setItemsPerResource (int value) {
@@ -189,7 +194,7 @@
 
     /**
      * Get the string representation of the search query.
-     *
+     * 
      * @return The string representation of the search query.
      */
     public String getSerialQuery () {
@@ -199,9 +204,10 @@
 
     /**
      * Get a certain {@link Match} by index.
-     *
-     * @param index The numerical index of the match,
-     *        starts with <tt>0</tt>.
+     * 
+     * @param index
+     *            The numerical index of the match,
+     *            starts with <tt>0</tt>.
      * @return The {@link Match} object.
      */
     @JsonIgnore
@@ -212,10 +218,10 @@
 
     /**
      * Get the list of {@link Match} matches.
-     *
+     * 
      * @return The list of {@link Match} objects.
      */
-    public List<Match> getMatches() {
+    public List<Match> getMatches () {
         return this.matches;
     };
 
@@ -223,7 +229,7 @@
     /**
      * Get the number of the first match in the result set
      * (<i>aka</i> the offset). Starts with <tt>0</tt>.
-     *
+     * 
      * @return The index number of the first match in the result set.
      */
     public int getStartIndex () {
@@ -234,7 +240,7 @@
     /**
      * Get the context parameters of the search by means of a
      * {@link SearchContext} object.
-     *
+     * 
      * @return The {@link SearchContext} object.
      */
     public SearchContext getContext () {
@@ -245,9 +251,10 @@
     /**
      * Set the context parameters of the search by means of a
      * {@link SearchContext} object.
-     *
-     * @param context The {@link SearchContext} object providing
-     *        search context parameters.
+     * 
+     * @param context
+     *            The {@link SearchContext} object providing
+     *            search context parameters.
      * @return {@link Result} object for chaining.
      */
     public Result setContext (SearchContext context) {
@@ -258,7 +265,7 @@
 
     /**
      * Serialize the result set as a {@link JsonNode}.
-     *
+     * 
      * @return {@link JsonNode} representation of the search results.
      */
     public JsonNode toJsonNode () {
@@ -293,29 +300,24 @@
         return json;
     };
 
+
     /**
      * Stringifies the matches to give a brief overview on
      * the result. Mainly used for testing.
-     *
-     * @return The stringified matches 
+     * 
+     * @return The stringified matches
      */
     public String getOverview () {
         StringBuilder sb = new StringBuilder();
 
-        sb.append("Search for: ")
-            .append(this.serialQuery)
-            .append("\n");
+        sb.append("Search for: ").append(this.serialQuery).append("\n");
 
         int i = 1;
 
         // Add matches as bracket strings
         for (Match km : this.getMatches())
-            sb.append(i++)
-                .append(": ")
-                .append(km.getSnippetBrackets())
-                .append(" (Doc ")
-                .append(km.getLocalDocID())
-                .append(")\n");
+            sb.append(i++).append(": ").append(km.getSnippetBrackets())
+                    .append(" (Doc ").append(km.getLocalDocID()).append(")\n");
 
         return sb.toString();
     };
@@ -325,9 +327,9 @@
     @Deprecated
     public String toTokenListJsonString () {
         ObjectNode json = (ObjectNode) mapper.valueToTree(this);
-        
+
         ArrayNode array = json.putArray("matches");
-	
+
         // Add matches as token lists
         for (Match km : this.getMatches())
             array.add(km.toTokenList());
@@ -338,7 +340,7 @@
         catch (Exception e) {
             log.warn(e.getLocalizedMessage());
         };
-        
+
         return "{}";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/SearchContext.java b/src/main/java/de/ids_mannheim/korap/response/SearchContext.java
index 451dcd2..91ebaa6 100644
--- a/src/main/java/de/ids_mannheim/korap/response/SearchContext.java
+++ b/src/main/java/de/ids_mannheim/korap/response/SearchContext.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.response;
+
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.SerializationFeature;
 import com.fasterxml.jackson.databind.JsonNode;
@@ -18,21 +19,22 @@
     public String spanContext;
 
     {
-        left  = new SearchContextSide();
+        left = new SearchContextSide();
         right = new SearchContextSide();
     };
 
+
     public SearchContext () {};
 
+
     public SearchContext (String spanContext) {
         this.spanType = true;
         this.spanContext = spanContext;
     };
 
-    public SearchContext (boolean leftTokenContext,
-                          short leftContext,
-                          boolean rightTokenContext,
-                          short rightContext) {
+
+    public SearchContext (boolean leftTokenContext, short leftContext,
+                          boolean rightTokenContext, short rightContext) {
         this.spanType = false;
         this.left.setToken(leftTokenContext);
         this.left.setLength(leftContext);
@@ -40,24 +42,27 @@
         this.right.setLength(rightContext);
     };
 
+
     public boolean isSpanDefined () {
         return this.spanType;
     };
 
+
     public String getSpanContext () {
         return this.spanContext;
     };
 
+
     public SearchContext setSpanContext (String spanContext) {
         this.spanType = true;
-        
+
         if (spanContext.equals("sentence")) {
             spanContext = "s";
         }
         else if (spanContext.equals("paragraph")) {
             spanContext = "p";
         };
-	
+
         this.spanContext = spanContext;
         return this;
     };
@@ -66,29 +71,35 @@
         private boolean type = true;
         private short length = 6;
         private short maxLength = 500;
-        
+
+
         public boolean isToken () {
             return this.type;
         };
-        
+
+
         public boolean isCharacter () {
             return !(this.type);
         };
 
+
         public SearchContextSide setToken (boolean value) {
             this.type = value;
             return this;
         };
 
+
         public SearchContextSide setCharacter (boolean value) {
             this.type = !(value);
             return this;
         };
 
-        public short getLength() {
+
+        public short getLength () {
             return this.length;
         };
-	
+
+
         public SearchContextSide setLength (short value) {
             if (value >= 0) {
                 if (value <= maxLength) {
@@ -100,11 +111,13 @@
             };
             return this;
         };
-        
+
+
         public SearchContextSide setLength (int value) {
             return this.setLength((short) value);
         };
 
+
         public void fromJson (JsonNode json) {
             String type = json.get(0).asText();
             if (type.equals("token")) {
@@ -122,7 +135,7 @@
         if (context.isContainerNode()) {
             if (context.has("left"))
                 this.left.fromJson(context.get("left"));
-            
+
             if (context.has("right"))
                 this.right.fromJson(context.get("right"));
         }
@@ -131,15 +144,16 @@
         };
     };
 
+
     public JsonNode toJsonNode () {
-        
+
         if (this.isSpanDefined())
             return new TextNode(this.spanContext);
-	
+
         ArrayNode leftContext = mapper.createArrayNode();
         leftContext.add(this.left.isToken() ? "token" : "char");
         leftContext.add(this.left.getLength());
-        
+
         ArrayNode rightContext = mapper.createArrayNode();
         rightContext.add(this.right.isToken() ? "token" : "char");
         rightContext.add(this.right.getLength());
@@ -147,7 +161,7 @@
         ObjectNode context = mapper.createObjectNode();
         context.put("left", leftContext);
         context.put("right", rightContext);
-        
+
         return context;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java b/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
index d58b473..2cfa252 100644
--- a/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
+++ b/src/main/java/de/ids_mannheim/korap/response/collector/MatchCollectorDB.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.response.collector;
+
 import de.ids_mannheim.korap.server.Node;
 import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.response.MatchCollector;
@@ -31,6 +32,7 @@
     private Connection connection;
     private PreparedStatement prepared;
 
+
     /*
      * Create a new collector for database connections
      */
@@ -40,6 +42,7 @@
         this.matchCollector = new ArrayList<int[]>(bufferSize + 2);
     };
 
+
     /*
      * Add matches till the bufferSize exceeds - then commit to the database.
      */
@@ -49,22 +52,26 @@
 
         this.incrTotalResultDocs(1);
         this.incrTotalResults(matchCount);
-        this.matchCollector.add(new int[]{UID, matchCount});
+        this.matchCollector.add(new int[] { UID, matchCount });
         this.docCollect++;
     };
 
+
     @JsonIgnore
     public void setDatabaseType (String type) {
         this.databaseType = type;
     };
 
+
     @JsonIgnore
     public String getDatabaseType () {
         return this.databaseType;
     };
 
+
     @JsonIgnore
-    public void setDBPool (String type, DataSource ds, Connection conn) throws SQLException {
+    public void setDBPool (String type, DataSource ds, Connection conn)
+            throws SQLException {
         this.setDatabaseType(type);
         this.connection = conn;
         this.pool = ds;
@@ -76,6 +83,8 @@
         this.setDatabaseType(type);
         this.pool = ds;
     };
+
+
     /*
       Create prepared statement for multiple requests
       this.prepared = this.conn.prepareStatement(
@@ -85,25 +94,24 @@
       Difference between mariadb and sqlite!
     */
 
-    
+
     /* TODO: Ensure the commit was successful! */
-    public void commit () {	
+    public void commit () {
         if (this.pool == null)
             return;
 
         try {
-	    /*
-	     * This should be heavily optimized! It's aweful!
-	     * ARGHHHHHHH!
-	     */
+            /*
+             * This should be heavily optimized! It's aweful!
+             * ARGHHHHHHH!
+             */
             if (this.connection.isClosed())
                 this.connection = this.pool.getConnection();
 
             StringBuilder sb = new StringBuilder();
-            sb.append("INSERT INTO ")
-                .append(this.resultID)
-                .append(" (text_id, match_count) ");
-            
+            sb.append("INSERT INTO ").append(this.resultID)
+                    .append(" (text_id, match_count) ");
+
             // SQLite batch insertion idiom
             if (this.getDatabaseType().equals("sqlite")) {
                 for (int i = 1; i < this.docCollect; i++) {
@@ -123,7 +131,7 @@
                 };
                 sb.append("(?,?)");
             }
-            
+
             // Unknown idiom
             else {
                 log.error("Unsupported Database type");
@@ -131,10 +139,11 @@
             };
 
             // Prepare statement based on the string
-            PreparedStatement prep = this.connection.prepareStatement(sb.toString());
+            PreparedStatement prep = this.connection.prepareStatement(sb
+                    .toString());
 
             int i = 1;
-            ListIterator li = this.matchCollector.listIterator(); 
+            ListIterator li = this.matchCollector.listIterator();
             while (li.hasNext()) {
                 int[] v = (int[]) li.next();
                 prep.setInt(i++, v[0]);
@@ -156,6 +165,7 @@
         return;
     };
 
+
     /*
      * Close collector and connection
      */
@@ -164,11 +174,12 @@
         try {
             this.connection.close();
         }
-       	catch (SQLException e) {
+        catch (SQLException e) {
             log.warn(e.getLocalizedMessage());
         }
     };
 
+
     /*
      * Close collector and probably connection
      */
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
index 8680742..2526e94 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/DocIdentifier.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.response.match;
+
 import java.util.*;
 import java.util.regex.*;
 
@@ -6,19 +7,23 @@
 public class DocIdentifier {
     protected String corpusID, docID;
 
+
     public String getCorpusID () {
         return this.corpusID;
     };
 
+
     public void setCorpusID (String id) {
         if (id != null && !id.contains("!"))
             this.corpusID = id;
     };
 
+
     public String getDocID () {
         return this.docID;
     };
 
+
     public void setDocID (String id) {
         if (id != null && !id.contains("!"))
             this.docID = id;
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
index adce408..8292e4a 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinator.java
@@ -21,56 +21,65 @@
 
     private LinkedList<HighlightCombinatorElement> combine;
     private Stack<Integer> balanceStack = new Stack<>();
-    private Stack<Integer> tempStack    = new Stack<>();
+    private Stack<Integer> tempStack = new Stack<>();
+
 
     // Empty constructor
     public HighlightCombinator () {
         this.combine = new LinkedList<>();
     };
 
+
     // Return the combination list
     public LinkedList<HighlightCombinatorElement> list () {
         return this.combine;
     };
 
+
     // get the first element (without removing)
     public HighlightCombinatorElement getFirst () {
         return this.combine.getFirst();
     };
 
+
     // get the last element (without removing)
     public HighlightCombinatorElement getLast () {
         return this.combine.getLast();
     };
 
+
     // get an element by index (without removing)
     public HighlightCombinatorElement get (int index) {
         return this.combine.get(index);
     };
 
+
     // Get the size of the combinator stack
     public short size () {
         return (short) this.combine.size();
     };
 
+
     // Add primary data to the stack
     public void addString (String characters) {
         this.combine.add(new HighlightCombinatorElement(characters));
     };
 
+
     // Add opening highlight combinator to the stack
     public void addOpen (int number) {
         this.combine.add(new HighlightCombinatorElement((byte) 1, number));
         this.balanceStack.push(number);
     };
 
+
     // Add closing highlight combinator to the stack
     public void addClose (int number) {
         HighlightCombinatorElement lastComb;
 
         // Clean up temporary stack
         this.tempStack.clear();
-        
+
         // Check if there is an opening tag at least
         if (this.balanceStack.empty()) {
             if (DEBUG)
@@ -80,7 +89,8 @@
 
         // Just some debug information
         if (DEBUG) {
-            StringBuilder sb = new StringBuilder("Stack for checking with class ");
+            StringBuilder sb = new StringBuilder(
+                    "Stack for checking with class ");
             sb.append(number).append(" is ");
             for (int s : this.balanceStack) {
                 sb.append('[').append(s).append(']');
@@ -91,26 +101,22 @@
         // class number of the last element
         // It's already ensured the stack is not empty
         int eold = this.balanceStack.pop();
-        
+
         // the closing element is not balanced, i.e. the last element differs
         while (eold != number) {
-            
+
             // Retrieve last combinator on stack
             lastComb = this.combine.peekLast();
-            
+
             if (DEBUG)
-                log.trace("Closing element is unbalanced - {} " +
-                          "!= {} with lastComb {}|{}|{}",
-                          eold,
-                          number,
-                          lastComb.type,
-                          lastComb.number,
-                          lastComb.characters);
+                log.trace("Closing element is unbalanced - {} "
+                        + "!= {} with lastComb {}|{}|{}", eold, number,
+                        lastComb.type, lastComb.number, lastComb.characters);
 
             // combinator is opening and the number is not equal to the last
             // element on the balanceStack
             if (lastComb.type == 1 && lastComb.number == eold) {
-                
+
                 // Remove the last element - it's empty and uninteresting!
                 this.combine.removeLast();
             }
@@ -120,9 +126,10 @@
 
                 if (DEBUG)
                     log.trace("close element a) {}", eold);
-		
+
                 // Add a closer for the old element (this has following elements)
-                this.combine.add(new HighlightCombinatorElement((byte) 2, eold, false));
+                this.combine.add(new HighlightCombinatorElement((byte) 2, eold,
+                        false));
             };
 
             // add this element number temporarily on the stack
@@ -136,20 +143,12 @@
         lastComb = this.combine.peekLast();
 
         if (DEBUG) {
-            log.trace("LastComb: " +
-                      lastComb.type +
-                      '|' +
-                      lastComb.number +
-                      '|' + lastComb.characters +
-                      " for " +
-                      number);
-            log.trace("Stack for checking 2: {}|{}|{}|{}",
-                      lastComb.type,
-                      lastComb.number,
-                      lastComb.characters,
-                      number);
+            log.trace("LastComb: " + lastComb.type + '|' + lastComb.number
+                    + '|' + lastComb.characters + " for " + number);
+            log.trace("Stack for checking 2: {}|{}|{}|{}", lastComb.type,
+                    lastComb.number, lastComb.characters, number);
         };
-        
+
         if (lastComb.type == 1 && lastComb.number == number) {
             while (lastComb.type == 1 && lastComb.number == number) {
                 // Remove the damn thing - It's empty and uninteresting!
@@ -160,7 +159,7 @@
         else {
             if (DEBUG)
                 log.trace("close element b) {}", number);
-	    
+
             // Add a closer
             this.combine.add(new HighlightCombinatorElement((byte) 2, number));
         };
@@ -174,6 +173,7 @@
         };
     };
 
+
     // Get all combined elements as a string
     public String toString () {
         StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
index 8eee7f0..55837b8 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/HighlightCombinatorElement.java
@@ -22,29 +22,33 @@
     public String characters;
     public boolean terminal = true;
 
+
     // Constructor for highlighting elements
     public HighlightCombinatorElement (byte type, int number) {
         this.type = type;
         this.number = number;
     };
 
+
     // Constructor for highlighting elements,
     // that may not be terminal, i.e. they were closed and will
     // be reopened for overlapping issues.
     public HighlightCombinatorElement (byte type, int number, boolean terminal) {
-        this.type     = type;
-        this.number   = number;
+        this.type = type;
+        this.number = number;
         this.terminal = terminal;
     };
 
+
     // Constructor for textual data
     public HighlightCombinatorElement (String characters) {
         this.type = (byte) 0;
         this.characters = characters;
     };
 
+
     // Return html fragment for this combinator element
-    public String toHTML (Match match, FixedBitSet level, byte[] levelCache) {	    
+    public String toHTML (Match match, FixedBitSet level, byte[] levelCache) {
         // Opening
         if (this.type == 1) {
             StringBuilder sb = new StringBuilder();
@@ -54,24 +58,22 @@
 
             else if (this.number < -1) {
                 sb.append("<span xml:id=\"")
-                    .append(match.getPosID(match.getClassID(this.number)))
-                    .append("\">");
+                        .append(match.getPosID(match.getClassID(this.number)))
+                        .append("\">");
             }
-            
+
             else if (this.number >= 256) {
                 sb.append("<span ");
                 if (this.number < 2048) {
                     sb.append("title=\"")
-                        .append(match.getAnnotationID(this.number))
-                        .append('"');
+                            .append(match.getAnnotationID(this.number))
+                            .append('"');
                 }
                 else {
                     Relation rel = match.getRelationID(this.number);
-                    sb.append("xlink:title=\"")
-                        .append(rel.annotation)
-                        .append("\" xlink:type=\"simple\" xlink:href=\"#")
-                        .append(match.getPosID(rel.ref))
-                        .append('"');
+                    sb.append("xlink:title=\"").append(rel.annotation)
+                            .append("\" xlink:type=\"simple\" xlink:href=\"#")
+                            .append(match.getPosID(rel.ref)).append('"');
                 };
                 sb.append('>');
             }
@@ -88,11 +90,8 @@
                     level.clear(pos);
                     levelCache[this.number] = pos;
                 };
-                sb.append("<mark class=\"class-")
-                    .append(this.number)
-                    .append(" level-")
-                    .append(pos)
-                    .append("\">");
+                sb.append("<mark class=\"class-").append(this.number)
+                        .append(" level-").append(pos).append("\">");
             };
             return sb.toString();
         }
@@ -100,59 +99,60 @@
         else if (this.type == 2) {
             if (this.number < -1 || this.number >= 256)
                 return "</span>";
-           
+
             if (this.number == -1)
                 return "</mark>";
-         
+
             if (this.terminal)
                 level.set((int) levelCache[this.number]);
             return "</mark>";
-	};
+        };
 
-	// HTML encode primary data
-	return escapeHTML(this.characters);
+        // HTML encode primary data
+        return escapeHTML(this.characters);
     };
 
+
     // Return bracket fragment for this combinator element
     public String toBrackets (Match match) {
-	if (this.type == 1) {
-	    StringBuilder sb = new StringBuilder();
-	    
-	    // Match
-	    if (this.number == -1) {
-		sb.append("[");
-	    }
+        if (this.type == 1) {
+            StringBuilder sb = new StringBuilder();
 
-	    // Identifier
-	    else if (this.number < -1) {
-		sb.append("{#");
-		sb.append(match.getClassID(this.number));
-		sb.append(':');
-	    }
+            // Match
+            if (this.number == -1) {
+                sb.append("[");
+            }
 
-	    // Highlight, Relation, Span
-	    else {
-		sb.append("{");
-		if (this.number >= 256) {
-		    if (this.number < 2048)
-			sb.append(match.getAnnotationID(this.number));
-		    else {
-			Relation rel = match.getRelationID(this.number);
-			sb.append(rel.annotation);
-			sb.append('>').append(rel.ref);
-		    };
-		    sb.append(':');
-		}
-		else if (this.number != 0)
-		    sb.append(this.number).append(':');
-	    };
-	    return sb.toString();
-	}
-	else if (this.type == 2) {
-	    if (this.number == -1)
-		return "]";
-	    return "}";
-	};
-	return this.characters;
+            // Identifier
+            else if (this.number < -1) {
+                sb.append("{#");
+                sb.append(match.getClassID(this.number));
+                sb.append(':');
+            }
+
+            // Highlight, Relation, Span
+            else {
+                sb.append("{");
+                if (this.number >= 256) {
+                    if (this.number < 2048)
+                        sb.append(match.getAnnotationID(this.number));
+                    else {
+                        Relation rel = match.getRelationID(this.number);
+                        sb.append(rel.annotation);
+                        sb.append('>').append(rel.ref);
+                    };
+                    sb.append(':');
+                }
+                else if (this.number != 0)
+                    sb.append(this.number).append(':');
+            };
+            return sb.toString();
+        }
+        else if (this.type == 2) {
+            if (this.number == -1)
+                return "]";
+            return "}";
+        };
+        return this.characters;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
index 5b954d6..5f13a3b 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/MatchIdentifier.java
@@ -1,4 +1,5 @@
 package de.ids_mannheim.korap.response.match;
+
 import java.util.*;
 import java.util.regex.*;
 
@@ -7,16 +8,15 @@
 
     private ArrayList<int[]> pos = new ArrayList<>(8);
 
-    Pattern idRegex = Pattern.compile(
-		        "^match-(?:([^!]+?)!)?" +
-			"([^!]+)-p([0-9]+)-([0-9]+)" +
-			"((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" +
-			"(?:c.+?)?$");
-    Pattern posRegex = Pattern.compile(
-		        "\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
+    Pattern idRegex = Pattern.compile("^match-(?:([^!]+?)!)?"
+            + "([^!]+)-p([0-9]+)-([0-9]+)"
+            + "((?:\\(-?[0-9]+\\)-?[0-9]+--?[0-9]+)*)" + "(?:c.+?)?$");
+    Pattern posRegex = Pattern.compile("\\(([0-9]+)\\)([0-9]+)-([0-9]+)");
+
 
     public MatchIdentifier () {};
-    
+
+
     public MatchIdentifier (String id) {
         Matcher matcher = idRegex.matcher(id);
         if (matcher.matches()) {
@@ -28,45 +28,51 @@
             if (matcher.group(5) != null) {
                 matcher = posRegex.matcher(matcher.group(5));
                 while (matcher.find()) {
-                    this.addPos(
-                        Integer.parseInt(matcher.group(2)),
-                        Integer.parseInt(matcher.group(3)),
-                        Integer.parseInt(matcher.group(1))
-                    );
+                    this.addPos(Integer.parseInt(matcher.group(2)),
+                            Integer.parseInt(matcher.group(3)),
+                            Integer.parseInt(matcher.group(1)));
                 };
             };
         };
     };
 
+
     public int getStartPos () {
         return this.startPos;
     };
 
+
     public void setStartPos (int pos) {
         if (pos >= 0)
             this.startPos = pos;
     };
 
+
     public int getEndPos () {
         return this.endPos;
     };
 
+
     public void setEndPos (int pos) {
         if (pos >= 0)
             this.endPos = pos;
     };
 
-    public void addPos(int start, int end, int number) {
+
+    public void addPos (int start, int end, int number) {
         if (start >= 0 && end >= 0 && number >= 0)
-            this.pos.add(new int[]{start, end, number});
+            this.pos.add(new int[] { start, end, number });
     };
 
+
     public ArrayList<int[]> getPos () {
         return this.pos;
     };
 
+
     public String toString () {
-        if (this.docID == null) return null;
+        if (this.docID == null)
+            return null;
 
         StringBuilder sb = new StringBuilder("match-");
 
@@ -77,7 +83,7 @@
         sb.append(this.docID);
 
         sb.append('-');
-        sb.append(this.getPositionString());	
+        sb.append(this.getPositionString());
         return sb.toString();
     };
 
@@ -91,7 +97,7 @@
             sb.append('(').append(i[2]).append(')');
             sb.append(i[0]).append('-').append(i[1]);
         };
-        
+
         return sb.toString();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java b/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java
index 8606aa6..eaa8d9e 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/PosIdentifier.java
@@ -1,22 +1,28 @@
 package de.ids_mannheim.korap.response.match;
+
 import java.util.*;
 
 public class PosIdentifier extends DocIdentifier {
     private int pos;
 
+
     public PosIdentifier () {};
 
+
     public void setPos (int pos) {
         if (pos >= 0)
             this.pos = pos;
     };
 
+
     public int getPos () {
         return this.pos;
     };
 
+
     public String toString () {
-        if (this.docID == null) return null;
+        if (this.docID == null)
+            return null;
 
         StringBuilder sb = new StringBuilder("word-");
 
diff --git a/src/main/java/de/ids_mannheim/korap/response/match/Relation.java b/src/main/java/de/ids_mannheim/korap/response/match/Relation.java
index 1587ed3..fc34b23 100644
--- a/src/main/java/de/ids_mannheim/korap/response/match/Relation.java
+++ b/src/main/java/de/ids_mannheim/korap/response/match/Relation.java
@@ -2,10 +2,12 @@
 
 /**
  * Class for relational highlights.
- */   
+ */
 public class Relation {
     public int ref;
     public String annotation;
+
+
     public Relation (String annotation, int ref) {
         this.annotation = annotation;
         this.ref = ref;
diff --git a/src/main/java/de/ids_mannheim/korap/server/Node.java b/src/main/java/de/ids_mannheim/korap/server/Node.java
index 6aebd2d..6267bb9 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Node.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Node.java
@@ -20,28 +20,27 @@
 
 /**
  * Standalone REST-Service for the Lucene Search Backend.
- *
+ * 
  * @author diewald
  */
 public class Node {
 
     // Base URI the Grizzly HTTP server will listen on
     public static String BASE_URI = "http://localhost:8080/";
-    
+
     // Logger
     private final static Logger log = LoggerFactory.getLogger(Node.class);
 
     // Index
     private static KrillIndex index;
     private static ComboPooledDataSource cpds;
-    private static String path,
-                          name = "unknown";
+    private static String path, name = "unknown";
 
     private static String dbUser, dbPwd;
 
-    private static String dbClass = "org.sqlite.JDBC",
-                          dbURL   = "jdbc:sqlite:";
-    
+    private static String dbClass = "org.sqlite.JDBC", dbURL = "jdbc:sqlite:";
+
+
     /*
      * Todo: Add shutdown hook,
      * Then also close cdps.close();
@@ -52,31 +51,28 @@
     /**
      * Starts Grizzly HTTP server exposing JAX-RS
      * resources defined in this application.
-     *
+     * 
      * @return Grizzly HTTP server.
      */
-    public static HttpServer startServer() {
+    public static HttpServer startServer () {
 
         // Load configuration
         try {
-            InputStream file = new FileInputStream(
-                Node.class.getClassLoader()
-                .getResource("krill.properties")
-                .getFile()
-            );
+            InputStream file = new FileInputStream(Node.class.getClassLoader()
+                    .getResource("krill.properties").getFile());
             Properties prop = new Properties();
             prop.load(file);
 
             // Node properties
-            path     = prop.getProperty("krill.indexDir", path);
-            name     = prop.getProperty("krill.server.name", name);
+            path = prop.getProperty("krill.indexDir", path);
+            name = prop.getProperty("krill.server.name", name);
             BASE_URI = prop.getProperty("krill.server.baseURI", BASE_URI);
 
             // Database properties
-            dbUser  = prop.getProperty("krill.db.user",    dbUser);
-            dbPwd   = prop.getProperty("krill.db.pwd",     dbPwd);
-            dbClass = prop.getProperty("krill.db.class",   dbClass);
-            dbURL   = prop.getProperty("krill.db.jdbcURL", dbURL);
+            dbUser = prop.getProperty("krill.db.user", dbUser);
+            dbPwd = prop.getProperty("krill.db.pwd", dbPwd);
+            dbClass = prop.getProperty("krill.db.class", dbClass);
+            dbURL = prop.getProperty("krill.db.jdbcURL", dbURL);
 
         }
         catch (IOException e) {
@@ -85,32 +81,36 @@
 
         // create a resource config that scans for JAX-RS resources and providers
         // in de.ids_mannheim.korap.server package
-        final ResourceConfig rc =
-            new ResourceConfig().packages("de.ids_mannheim.korap.server");
+        final ResourceConfig rc = new ResourceConfig()
+                .packages("de.ids_mannheim.korap.server");
 
         // create and start a new instance of grizzly http server
         // exposing the Jersey application at BASE_URI
-        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI),
+                rc);
     };
 
-    public static HttpServer startServer(String nodeName, String indexPath) {
+
+    public static HttpServer startServer (String nodeName, String indexPath) {
 
         // create a resource config that scans for JAX-RS resources and providers
         // in de.ids_mannheim.korap.server package
-        final ResourceConfig rc =
-            new ResourceConfig().packages("de.ids_mannheim.korap.server");
+        final ResourceConfig rc = new ResourceConfig()
+                .packages("de.ids_mannheim.korap.server");
 
         name = nodeName;
         path = indexPath;
 
         // create and start a new instance of grizzly http server
         // exposing the Jersey application at BASE_URI
-        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);
+        return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI),
+                rc);
     };
 
 
     /**
      * Main method.
+     * 
      * @param args
      * @throws IOException
      */
@@ -120,19 +120,14 @@
         final HttpServer server = startServer();
 
         // Establish shutdown hook
-        Runtime.getRuntime().addShutdownHook(
-            new Thread(
-                new Runnable() {
-                    @Override
-                    public void run() {
-                        log.info("Stop Server");
-                        // staaahp!
-                        server.stop();
-                    }
-                },
-                "shutdownHook"
-            )
-        );
+        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
+            @Override
+            public void run () {
+                log.info("Stop Server");
+                // staaahp!
+                server.stop();
+            }
+        }, "shutdownHook"));
 
         // Start server
         try {
@@ -145,6 +140,7 @@
         };
     };
 
+
     // What's the servers name?
     public static String getName () {
         return name;
@@ -163,7 +159,7 @@
         // Pool already initiated
         if (cpds != null)
             return cpds;
-        
+
         try {
 
             // Parameters are defined in the property file
@@ -190,8 +186,8 @@
         // Index already instantiated
         if (index != null)
             return index;
-        
-    	try {
+
+        try {
 
             // Get a temporary index
             if (path == null)
diff --git a/src/main/java/de/ids_mannheim/korap/server/Ping.java b/src/main/java/de/ids_mannheim/korap/server/Ping.java
index ebaba96..f47cadb 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Ping.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Ping.java
@@ -7,14 +7,14 @@
 
 /**
  * A useful ping service.
- *
+ * 
  * @author Nils Diewald
  */
 @Path("ping")
 public class Ping {
     @GET
     @Produces(MediaType.TEXT_PLAIN)
-    public String getIt() {
+    public String getIt () {
         return "Gimme 5 minutes, please!";
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/server/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
index 2c47e63..4b4fa31 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -46,12 +46,15 @@
 
 /**
  * Root resource (exposed at root path)
- * The responses only represent JSON responses, although HTML responses
+ * The responses only represent JSON responses, although HTML
+ * responses
  * may be handy.
- *
+ * 
  * @author Nils Diewald
- *
- * Look at http://www.mkyong.com/webservices/jax-rs/json-example-with-jersey-jackson/
+ * 
+ *         Look at
+ *         http://www.mkyong.com/webservices/jax-rs/json-example
+ *         -with-jersey-jackson/
  */
 @Path("/")
 public class Resource {
@@ -65,9 +68,9 @@
     public static final boolean DEBUG = false;
 
     // Slightly based on String::BooleanSimple
-    static Pattern p = Pattern.compile(
-        "\\s*(?i:false|no|inactive|disabled|off|n|neg(?:ative)?|not|null|undef)\\s*"
-    );
+    static Pattern p = Pattern
+            .compile("\\s*(?i:false|no|inactive|disabled|off|n|neg(?:ative)?|not|null|undef)\\s*");
+
 
     // Check if a string is meant to represent null
     private static boolean isNull (String value) {
@@ -105,12 +108,14 @@
         kresp.addMessage(680, "Server is up and running!");
         return kresp.toJsonString();
     };
-    
+
 
     /**
      * Add new documents to the index
-     *
-     * @param json JSON-LD string with search and potential meta filters.
+     * 
+     * @param json
+     *            JSON-LD string with search and potential meta
+     *            filters.
      */
     /*
      * Support GZip:
@@ -121,9 +126,8 @@
     @Path("/index/{textID}")
     @Produces(MediaType.APPLICATION_JSON)
     @Consumes(MediaType.APPLICATION_JSON)
-    public String add (@PathParam("textID") Integer uid,
-                       @Context UriInfo uri,
-                       String json) {
+    public String add (@PathParam("textID") Integer uid, @Context UriInfo uri,
+            String json) {
         /*
          * See
          * http://www.mkyong.com/webservices/jax-rs/file-upload-example-in-jersey/
@@ -189,7 +193,7 @@
 
         kresp.setVersion(index.getVersion());
         kresp.setName(index.getName());
-        
+
         // There are documents to commit
         try {
             index.commit();
@@ -207,8 +211,9 @@
 
 
     /**
-     * Find matches in the lucene index based on UIDs and return one match per doc.
-     *
+     * Find matches in the lucene index based on UIDs and return one
+     * match per doc.
+     * 
      * @param text_id
      */
     @POST
@@ -224,7 +229,7 @@
             Krill ks = new Krill(json);
 
             // Get query parameters
-            MultivaluedMap<String,String> qp = uri.getQueryParameters();
+            MultivaluedMap<String, String> qp = uri.getQueryParameters();
 
             if (qp.get("uid") != null) {
 
@@ -232,9 +237,9 @@
                 List<String> uids = qp.get("uid");
                 KrillCollection kc = new KrillCollection();
                 kc.filterUIDs(uids.toArray(new String[uids.size()]));
-                
+
                 // TODO: RESTRICT COLLECTION TO ONLY RESPECT SELF DOCS (REPLICATION)
-                
+
                 // Override old collection
                 ks.setCollection(kc);
 
@@ -245,7 +250,8 @@
             };
             Result kr = new Result();
             kr.setNode(Node.getName());
-            kr.addError(610, "Missing request parameters", "No unique IDs were given");
+            kr.addError(610, "Missing request parameters",
+                    "No unique IDs were given");
             return kr.toJsonString();
         };
 
@@ -253,25 +259,25 @@
         kresp.setNode(Node.getName());
         kresp.setName(index.getName());
         kresp.setVersion(index.getVersion());
-        
+
         kresp.addError(601, "Unable to find index");
-        
+
         return kresp.toJsonString();
     };
 
 
     /**
-     * Collect matches and aggregate the UIDs plus matchcount in the database.
-     *
+     * Collect matches and aggregate the UIDs plus matchcount in the
+     * database.
+     * 
      * @param text_id
      */
     @PUT
     @Path("/collect/{resultID}")
     @Produces(MediaType.APPLICATION_JSON)
     @Consumes(MediaType.APPLICATION_JSON)
-    public String collect (String json,
-                           @PathParam("resultID") String resultID,
-                           @Context UriInfo uri) {
+    public String collect (String json, @PathParam("resultID") String resultID,
+            @Context UriInfo uri) {
 
         // Get index
         KrillIndex index = Node.getIndex();
@@ -289,9 +295,9 @@
             MatchCollectorDB mc = new MatchCollectorDB(1000, "Res_" + resultID);
             Connection conn = Node.getDBPool().getConnection();
             mc.setDBPool("mysql", Node.getDBPool(), conn);
-            
+
             // TODO: Only search in self documents (REPLICATION FTW!)
-            
+
             Krill ks = new Krill(json);
             MatchCollector result = index.collect(ks, mc);
 
@@ -313,17 +319,16 @@
 
 
 
-
-
     /* These routes are still wip: */
 
 
 
-
     /**
      * Search the lucene index.
-     *
-     * @param json JSON-LD string with search and potential meta filters.
+     * 
+     * @param json
+     *            JSON-LD string with search and potential meta
+     *            filters.
      */
     @POST
     @Path("/search")
@@ -331,96 +336,87 @@
     @Consumes(MediaType.APPLICATION_JSON)
     public String search (String json) {
 
-	// Get index
-	KrillIndex index = Node.getIndex();
+        // Get index
+        KrillIndex index = Node.getIndex();
 
-	// Search index
+        // Search index
         if (index != null) {
             Result kr = new Krill(json).apply(index);
-	    kr.setNode(Node.getName());
-	    return kr.toJsonString();
-	};
+            kr.setNode(Node.getName());
+            return kr.toJsonString();
+        };
 
-	Response kresp = new Response();
-	kresp.setNode(Node.getName());
-	kresp.setName(index.getName());
-	kresp.setVersion(index.getVersion());
+        Response kresp = new Response();
+        kresp.setNode(Node.getName());
+        kresp.setName(index.getName());
+        kresp.setVersion(index.getVersion());
 
-	kresp.addError(601, "Unable to find index");
-	return kresp.toJsonString();
+        kresp.addError(601, "Unable to find index");
+        return kresp.toJsonString();
     };
 
+
     @GET
     @Path("/match/{matchID}")
     @Produces(MediaType.APPLICATION_JSON)
-    public String match (@PathParam("matchID") String id,
-			 @Context UriInfo uri) {
+    public String match (@PathParam("matchID") String id, @Context UriInfo uri) {
 
-	// Get index
-	KrillIndex index = Node.getIndex();
+        // Get index
+        KrillIndex index = Node.getIndex();
 
-	// Search index
+        // Search index
         if (index != null) {
 
-	    // Get query parameters
-	    MultivaluedMap<String,String> qp = uri.getQueryParameters();
+            // Get query parameters
+            MultivaluedMap<String, String> qp = uri.getQueryParameters();
 
-	    boolean includeSpans = false,
-		includeHighlights = true,
-		extendToSentence = false,
-		info = false;
+            boolean includeSpans = false, includeHighlights = true, extendToSentence = false, info = false;
 
-	    // Optional query parameter "info" for more information on the match
-	    if (!isNull(qp.getFirst("info")))
-		info = true;
-	    
-	    // Optional query parameter "spans" for span information inclusion
-	    if (!isNull(qp.getFirst("spans"))) {
-		includeSpans = true;
-		info = true;
-	    };
+            // Optional query parameter "info" for more information on the match
+            if (!isNull(qp.getFirst("info")))
+                info = true;
 
-	    // Optional query parameter "highlights" for highlight information inclusion
-	    String highlights = qp.getFirst("highlights");
-	    if (highlights != null && isNull(highlights))
-		includeHighlights = false;
+            // Optional query parameter "spans" for span information inclusion
+            if (!isNull(qp.getFirst("spans"))) {
+                includeSpans = true;
+                info = true;
+            };
 
-	    // Optional query parameter "extended" for sentence expansion
-	    if (!isNull(qp.getFirst("extended")))
-		extendToSentence = true;
+            // Optional query parameter "highlights" for highlight information inclusion
+            String highlights = qp.getFirst("highlights");
+            if (highlights != null && isNull(highlights))
+                includeHighlights = false;
 
-	    List<String> foundries = qp.get("foundry");
-	    List<String> layers    = qp.get("layer");
+            // Optional query parameter "extended" for sentence expansion
+            if (!isNull(qp.getFirst("extended")))
+                extendToSentence = true;
 
-            try {		
-		// Get match info
-                return index.getMatchInfo(
-		    id,
-		    "tokens",
-		    info,
-		    foundries,
-		    layers,
-		    includeSpans,
-		    includeHighlights,
-		    extendToSentence
-		).toJsonString();
+            List<String> foundries = qp.get("foundry");
+            List<String> layers = qp.get("layer");
+
+            try {
+                // Get match info
+                return index.getMatchInfo(id, "tokens", info, foundries,
+                        layers, includeSpans, includeHighlights,
+                        extendToSentence).toJsonString();
             }
 
-	    // Nothing found
-	    catch (QueryException qe) {
-		// Todo: Make Match rely on Response!
+            // Nothing found
+            catch (QueryException qe) {
+                // Todo: Make Match rely on Response!
                 Match km = new Match();
                 km.addError(qe.getErrorCode(), qe.getMessage());
                 return km.toJsonString();
             }
-	};
+        };
 
-	// Response with error message
+        // Response with error message
         Match km = new Match();
         km.addError(601, "Unable to find index");
         return km.toJsonString();
     };
 
+
     /*
       POST /collect/:result_id
       POST /peek
@@ -441,35 +437,35 @@
     @Consumes(MediaType.APPLICATION_JSON)
     public String collection (String json) {
 
-	// Get index
-	KrillIndex index = Node.getIndex();
+        // Get index
+        KrillIndex index = Node.getIndex();
 
-	if (index == null)
-	    return "{\"documents\" : -1, error\" : \"No index given\" }";
+        if (index == null)
+            return "{\"documents\" : -1, error\" : \"No index given\" }";
 
-	return "{}";
+        return "{}";
     };
 
 
 
     // Interceptor class
     public class GZIPReaderInterceptor implements ReaderInterceptor {
-	@Override
-	public Object aroundReadFrom(ReaderInterceptorContext context)
-	    throws IOException, WebApplicationException {
-	    final InputStream originalInputStream = context.getInputStream();
-	    context.setInputStream(new GZIPInputStream(originalInputStream));
-	    return context.proceed();
-	};
+        @Override
+        public Object aroundReadFrom (ReaderInterceptorContext context)
+                throws IOException, WebApplicationException {
+            final InputStream originalInputStream = context.getInputStream();
+            context.setInputStream(new GZIPInputStream(originalInputStream));
+            return context.proceed();
+        };
     };
 
     public class GZIPWriterInterceptor implements WriterInterceptor {
-	@Override
-	public void aroundWriteTo(WriterInterceptorContext context)
-	    throws IOException, WebApplicationException {
-	    final OutputStream outputStream = context.getOutputStream();
-	    context.setOutputStream(new GZIPOutputStream(outputStream));
-	    context.proceed();
-	};
+        @Override
+        public void aroundWriteTo (WriterInterceptorContext context)
+                throws IOException, WebApplicationException {
+            final OutputStream outputStream = context.getOutputStream();
+            context.setOutputStream(new GZIPOutputStream(outputStream));
+            context.proceed();
+        };
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/util/CorpusDataException.java b/src/main/java/de/ids_mannheim/korap/util/CorpusDataException.java
index 9b5ed23..963094e 100644
--- a/src/main/java/de/ids_mannheim/korap/util/CorpusDataException.java
+++ b/src/main/java/de/ids_mannheim/korap/util/CorpusDataException.java
@@ -2,25 +2,27 @@
 
 /**
  * Exception class for corpus data processing problems.
- *
+ * 
  * @author diewald
  */
 public class CorpusDataException extends Exception {
-	
+
     private int errorCode = 0;
-  
+
+
     /**
      * Construct a new CorpusDataException.
      */
-    public CorpusDataException() {
+    public CorpusDataException () {
         super();
     };
 
 
     /**
      * Construct a new CorpusDataException.
-     *
-     * @param message Exception message.
+     * 
+     * @param message
+     *            Exception message.
      */
     public CorpusDataException (String message) {
         super(message);
@@ -29,21 +31,25 @@
 
     /**
      * Construct a new CorpusDataException.
-     *
-     * @param code An integer value as an error code.
-     * @param message Exception message.
+     * 
+     * @param code
+     *            An integer value as an error code.
+     * @param message
+     *            Exception message.
      */
-    public CorpusDataException (int code, String message) {	  
+    public CorpusDataException (int code, String message) {
         super(message);
-        this.setErrorCode(code);      
+        this.setErrorCode(code);
     };
 
 
     /**
      * Construct a new CorpusDataException.
-     *
-     * @param message Exception message.
-     * @param cause A {@link Throwable} object.
+     * 
+     * @param message
+     *            Exception message.
+     * @param cause
+     *            A {@link Throwable} object.
      */
     public CorpusDataException (String message, Throwable cause) {
         super(message, cause);
@@ -52,28 +58,30 @@
 
     /**
      * Construct a new CorpusDataException.
-     *
-     * @param cause A {@link Throwable} object.
-     */    
+     * 
+     * @param cause
+     *            A {@link Throwable} object.
+     */
     public CorpusDataException (Throwable cause) {
         super(cause);
-    };  
-  
+    };
+
 
     /**
      * Get the error code of the exception.
-     *
+     * 
      * @return The error code of the exception as an integer.
      */
-    public int getErrorCode() {
+    public int getErrorCode () {
         return this.errorCode;
     };
 
 
     /**
      * Set the error code of the exception.
-     *
-     * @param code The error code of the exception as an integer.
+     * 
+     * @param code
+     *            The error code of the exception as an integer.
      */
     public void setErrorCode (int code) {
         this.errorCode = code;
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillArray.java b/src/main/java/de/ids_mannheim/korap/util/KrillArray.java
index 210df78..206e587 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillArray.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillArray.java
@@ -5,16 +5,18 @@
 /**
  * A collection of string array related
  * utility functions.
- *
+ * 
  * @author diewald
  */
 public class KrillArray {
 
     /**
      * Join a sequence of strings to a single string.
-     *
-     * @param separator String to separate joined segments
-     * @param strings Segments to join
+     * 
+     * @param separator
+     *            String to separate joined segments
+     * @param strings
+     *            Segments to join
      * @return The joined string.
      */
     public static String join (String separator, String ... strings) {
@@ -34,9 +36,11 @@
 
     /**
      * Join a sequence of strings to a single string.
-     *
-     * @param separator Character to separate joined segments
-     * @param strings Segments to join
+     * 
+     * @param separator
+     *            Character to separate joined segments
+     * @param strings
+     *            Segments to join
      * @return The joined string.
      */
     public static String join (char separator, String ... strings) {
@@ -44,12 +48,12 @@
             return "";
 
         StringBuffer sb = new StringBuffer(strings[0]);
-        
+
         for (int i = 1; i < strings.length; i++) {
             sb.append(separator);
             sb.append(strings[i]);
         };
-        
+
         return sb.toString();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillByte.java b/src/main/java/de/ids_mannheim/korap/util/KrillByte.java
index 8dd6b16..6ae3256 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillByte.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillByte.java
@@ -5,15 +5,16 @@
 /**
  * A collection of byte and byte array related
  * utility functions.
- *
+ * 
  * @author diewald
  */
 public class KrillByte {
 
     /**
      * Convert an integer to a byte array.
-     *
-     * @param number The number to convert.
+     * 
+     * @param number
+     *            The number to convert.
      * @return The translated byte array.
      */
     // Based on
@@ -22,7 +23,7 @@
         byte[] data = new byte[4];
         for (int i = 0; i < 4; ++i) {
             int shift = i << 3; // That's identical to i * 8
-            data[3-i] = (byte)((number & (0xff << shift)) >>> shift);
+            data[3 - i] = (byte) ((number & (0xff << shift)) >>> shift);
         };
         return data;
     };
@@ -30,8 +31,9 @@
 
     /**
      * Convert a byte array to an integer.
-     *
-     * @param data The byte array to convert.
+     * 
+     * @param data
+     *            The byte array to convert.
      * @return The translated integer.
      */
     // Based on
@@ -43,9 +45,11 @@
 
     /**
      * Convert a byte array to an integer.
-     *
-     * @param data The byte array to convert.
-     * @param offset The byte offset (Not integer offset!).
+     * 
+     * @param data
+     *            The byte array to convert.
+     * @param offset
+     *            The byte offset (Not integer offset!).
      * @return The translated integer.
      */
     // Roughly based on
@@ -54,7 +58,7 @@
         offset += 3;
         int number = 0;
         for (int i = 0; i < 4; ++i)
-            number |= (data[offset-i] & 0xff) << (i << 3);
+            number |= (data[offset - i] & 0xff) << (i << 3);
         return number;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillDate.java b/src/main/java/de/ids_mannheim/korap/util/KrillDate.java
index e5f7c99..a578fdd 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillDate.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillDate.java
@@ -8,22 +8,22 @@
  * and parse date strings optimized
  * for integer range queries in Lucene.
  * No support for b.c. dates.
- *
- * Strings are parsed and serialized to
- * {@link http://tools.ietf.org/html/rfc3339 RFC3339}
- * compatible strings with a day granularity according to
- * {@link http://www.w3.org/TR/NOTE-datetime W3-DateTimes}.
- *
+ * 
+ * Strings are parsed and serialized to {@link http
+ * ://tools.ietf.org/html/rfc3339 RFC3339} compatible strings with a
+ * day granularity according to {@link http
+ * ://www.w3.org/TR/NOTE-datetime W3-DateTimes}.
+ * 
  * <blockquote><pre>
- *   KrillDate kd = new KrillDate("2005-06-03");
- *   System.err.println(kd.day());
- *   // 3
-
- *   kd = new KrillDate("2005-06");
- *   System.err.println(kd.month());
- *   // 6
+ * KrillDate kd = new KrillDate("2005-06-03");
+ * System.err.println(kd.day());
+ * // 3
+ * 
+ * kd = new KrillDate("2005-06");
+ * System.err.println(kd.month());
+ * // 6
  * </pre></blockquote>
- *
+ * 
  * @author diewald
  */
 public class KrillDate {
@@ -47,11 +47,9 @@
 
 
     // Date string regex pattern
-    private static final Pattern datePattern = Pattern.compile(
-        "\\s*(\\d\\d\\d\\d)" +
-        "(?:\\s*[-/]?\\s*(\\d\\d)" +
-        "(?:\\s*[-/]?\\s*(\\d\\d))?)?\\s*"
-    );
+    private static final Pattern datePattern = Pattern
+            .compile("\\s*(\\d\\d\\d\\d)" + "(?:\\s*[-/]?\\s*(\\d\\d)"
+                    + "(?:\\s*[-/]?\\s*(\\d\\d))?)?\\s*");
 
     /**
      * Static value representing the minimum date.
@@ -68,13 +66,14 @@
     /**
      * Construct a new KrillDate object.
      */
-    public KrillDate () { };
+    public KrillDate () {};
 
 
     /**
      * Construct a new KrillDate object.
-     *
-     * @param date The date as a string (see synopsis).
+     * 
+     * @param date
+     *            The date as a string (see synopsis).
      */
     public KrillDate (String date) {
         if (date == null || date.isEmpty())
@@ -87,7 +86,7 @@
             if (m.group(2) != null)
                 this.month = Integer.parseInt(m.group(2));
             if (m.group(3) != null)
-                this.day   = Integer.parseInt(m.group(3));
+                this.day = Integer.parseInt(m.group(3));
         };
     };
 
@@ -95,33 +94,32 @@
     /**
      * Get the date as an integer with ceiled values for
      * undefined date segments.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillDate kd = new KrillDate("2005-06");
-     *   System.err.println(kd.ceil());
-     *   // 20050699
+     * KrillDate kd = new KrillDate("2005-06");
+     * System.err.println(kd.ceil());
+     * // 20050699
      * </pre></blockquote>
-     *
+     * 
      * @return ceiled integer value.
      */
     public int ceil () {
-        return
-            (ceil((byte) 4, this.year) * 10_000) +
-            (ceil((byte) 2, this.month) * 100) +
-            (ceil((byte) 2, this.day));
+        return (ceil((byte) 4, this.year) * 10_000)
+                + (ceil((byte) 2, this.month) * 100)
+                + (ceil((byte) 2, this.day));
     };
 
 
     /**
      * Get the date as an integer with floored values for
      * undefined date segments.
-     *
+     * 
      * <blockquote><pre>
-     *   KrillDate kd = new KrillDate("2005-06");
-     *   System.err.println(kd.floor());
-     *   // 20050600
+     * KrillDate kd = new KrillDate("2005-06");
+     * System.err.println(kd.floor());
+     * // 20050600
      * </pre></blockquote>
-     *
+     * 
      * @return floored integer value.
      */
     public int floor () {
@@ -146,10 +144,10 @@
     /**
      * Serialize date to string, appended by zeros,
      * in the form of &quot;20050300&quot;.
-     *
+     * 
      * @return The date as a string.
      */
-    public String toString() {
+    public String toString () {
         StringBuilder sb = this.toStringBuilder();
         if (sb.length() < 4)
             return null;
@@ -167,10 +165,10 @@
 
     /**
      * Serialize ceiled date to string.
-     *
+     * 
      * @return The date as a string.
      */
-    public String toCeilString() {
+    public String toCeilString () {
         StringBuilder sb = new StringBuilder();
         return sb.append(this.ceil()).toString();
     };
@@ -178,10 +176,10 @@
 
     /**
      * Serialize floored date to string.
-     *
+     * 
      * @return The date as a string.
      */
-    public String toFloorString() {
+    public String toFloorString () {
         StringBuilder sb = new StringBuilder();
         return sb.append(this.floor()).toString();
     };
@@ -190,10 +188,10 @@
     /**
      * Serialize date to displayable string.
      * See format description in the class description.
-     *
+     * 
      * @return The date as a string.
      */
-    public String toDisplay() {
+    public String toDisplay () {
         StringBuilder sb = this.toStringBuilder();
         if (sb.length() == 8)
             sb.insert(6, '-');
@@ -217,9 +215,9 @@
                 sb.append("20");
 
             sb.append(this.year);
-	    
+
             if (this.month != 0) {
-                
+
                 // Append month
                 if (this.month < 10)
                     sb.append('0');
diff --git a/src/main/java/de/ids_mannheim/korap/util/KrillString.java b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
index 07af4d6..cfc92f3 100644
--- a/src/main/java/de/ids_mannheim/korap/util/KrillString.java
+++ b/src/main/java/de/ids_mannheim/korap/util/KrillString.java
@@ -9,21 +9,23 @@
 /**
  * A collection of string related utility
  * functions.
- *
+ * 
  * @author diewald
  */
 public class KrillString {
 
     /**
      * Get String from file.
-     *
-     * @param path The path of the file represented as a string. 
-     * @param path The expected {@link Charset}. 
+     * 
+     * @param path
+     *            The path of the file represented as a string.
+     * @param path
+     *            The expected {@link Charset}.
      * @return The content of the file
      * @throws IOException
      */
     public static String StringfromFile (String path, Charset encoding)
-        throws IOException {
+            throws IOException {
         byte[] encoded = Files.readAllBytes(Paths.get(path));
         return new String(encoded, encoding);
     };
@@ -31,8 +33,9 @@
 
     /**
      * Get String from file (expecting UTF-8).
-     *
-     * @param path The path of the file represented as a string. 
+     * 
+     * @param path
+     *            The path of the file represented as a string.
      * @return The content of the file
      * @throws IOException
      */
@@ -43,14 +46,13 @@
 
     /**
      * Escape HTML relevant characters as entities.
-     *
-     * @param text The string to escape.
+     * 
+     * @param text
+     *            The string to escape.
      * @return The secured string.
      */
     public static String escapeHTML (String text) {
-        return text.replace("&", "&amp;")
-            .replace("<", "&lt;")
-            .replace(">", "&gt;")
-            .replace("\"", "&quot;");
+        return text.replace("&", "&amp;").replace("<", "&lt;")
+                .replace(">", "&gt;").replace("\"", "&quot;");
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/util/QueryException.java b/src/main/java/de/ids_mannheim/korap/util/QueryException.java
index 7dca966..f65dc95 100644
--- a/src/main/java/de/ids_mannheim/korap/util/QueryException.java
+++ b/src/main/java/de/ids_mannheim/korap/util/QueryException.java
@@ -2,25 +2,27 @@
 
 /**
  * Exception class for query processing problems.
- *
+ * 
  * @author diewald
  */
 public class QueryException extends Exception {
-	
+
     private int errorCode = 0;
-  
+
+
     /**
      * Construct a new QueryException.
      */
-    public QueryException() {
+    public QueryException () {
         super();
     };
 
 
     /**
      * Construct a new QueryException.
-     *
-     * @param message Exception message.
+     * 
+     * @param message
+     *            Exception message.
      */
     public QueryException (String message) {
         super(message);
@@ -29,21 +31,25 @@
 
     /**
      * Construct a new QueryException.
-     *
-     * @param code An integer value as an error code.
-     * @param message Exception message.
+     * 
+     * @param code
+     *            An integer value as an error code.
+     * @param message
+     *            Exception message.
      */
-    public QueryException (int code, String message) {	  
+    public QueryException (int code, String message) {
         super(message);
-        this.setErrorCode(code);      
+        this.setErrorCode(code);
     };
 
 
     /**
      * Construct a new QueryException.
-     *
-     * @param message Exception message.
-     * @param cause A {@link Throwable} object.
+     * 
+     * @param message
+     *            Exception message.
+     * @param cause
+     *            A {@link Throwable} object.
      */
     public QueryException (String message, Throwable cause) {
         super(message, cause);
@@ -52,28 +58,30 @@
 
     /**
      * Construct a new QueryException.
-     *
-     * @param cause A {@link Throwable} object.
-     */    
+     * 
+     * @param cause
+     *            A {@link Throwable} object.
+     */
     public QueryException (Throwable cause) {
         super(cause);
-    };  
-  
+    };
+
 
     /**
      * Get the error code of the exception.
-     *
+     * 
      * @return The error code of the exception as an integer.
      */
-    public int getErrorCode() {
+    public int getErrorCode () {
         return this.errorCode;
     };
 
 
     /**
      * Set the error code of the exception.
-     *
-     * @param code The error code of the exception as an integer.
+     * 
+     * @param code
+     *            The error code of the exception as an integer.
      */
     public void setErrorCode (int code) {
         this.errorCode = code;
diff --git a/src/test/java/de/ids_mannheim/korap/Test.java b/src/test/java/de/ids_mannheim/korap/Test.java
index 8475cd4..9f33803 100644
--- a/src/test/java/de/ids_mannheim/korap/Test.java
+++ b/src/test/java/de/ids_mannheim/korap/Test.java
@@ -19,12 +19,13 @@
 
 /**
  * Helper class for testing the KrillIndex framework (Normal).
- *
+ * 
  * @author diewald
  */
 public class Test {
 
-    public static void addDoc(IndexWriter w, Map<String, String> m) throws IOException {
+    public static void addDoc (IndexWriter w, Map<String, String> m)
+            throws IOException {
         Document doc = new Document();
         String[] strInt = { "pubDate" };
         String[] strStr = { "id", "corpus", "pubPlace" };
@@ -45,21 +46,19 @@
             doc.add(new IntField(s, Integer.parseInt(m.get(s)), Field.Store.YES));
         };
 
-        FieldType textFieldWithTermVectors = new FieldType(TextField.TYPE_STORED);
+        FieldType textFieldWithTermVectors = new FieldType(
+                TextField.TYPE_STORED);
         textFieldWithTermVectors.setStoreTermVectors(true);
         textFieldWithTermVectors.setStoreTermVectorOffsets(true);
         textFieldWithTermVectors.setStoreTermVectorPositions(true);
         textFieldWithTermVectors.setStoreTermVectorPayloads(true);
 
-        Field textFieldAnalyzed = new Field(
-            "text",
-            m.get("textStr"),
-            textFieldWithTermVectors
-        );
+        Field textFieldAnalyzed = new Field("text", m.get("textStr"),
+                textFieldWithTermVectors);
 
         MultiTermTokenStream ts = getTermVector(m.get("text"));
 
-        textFieldAnalyzed.setTokenStream( ts );
+        textFieldAnalyzed.setTokenStream(ts);
 
         doc.add(textFieldAnalyzed);
 
@@ -67,17 +66,18 @@
         w.addDocument(doc);
     };
 
+
     public static MultiTermTokenStream getTermVector (String stream) {
         MultiTermTokenStream ts = new MultiTermTokenStream();
 
         int pos = 0;
         for (String seg : stream.split(" ")) {
-            
+
             String[] tokseg = seg.split("\\|");
 
             try {
                 MultiTermToken mtt = new MultiTermToken('s', tokseg[0]);
-            
+
                 mtt.add("T");
                 mtt.add('i', tokseg[0].toLowerCase());
                 mtt.add('p', tokseg[1]);
@@ -91,14 +91,14 @@
                 if (tokseg.length == 5) {
                     mtt.add('e', tokseg[4]);
                 };
-                
+
                 ts.addMultiTermToken(mtt);
             }
             catch (CorpusDataException cde) {
                 fail(cde.getErrorCode() + ": " + cde.getMessage());
             };
         };
-        
+
         return ts;
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index fad4419..abda3c8 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -22,16 +22,18 @@
 
 /**
  * Helper class for testing the KrillIndex framework (Simple).
- *
+ * 
  * @author diewald
  */
 public class TestSimple {
 
     // Add document
-    public static void addDoc(IndexWriter w, Map<String, String> m) throws IOException {
+    public static void addDoc (IndexWriter w, Map<String, String> m)
+            throws IOException {
         Document doc = new Document();
 
-        FieldType textFieldWithTermVectors = new FieldType(TextField.TYPE_STORED);
+        FieldType textFieldWithTermVectors = new FieldType(
+                TextField.TYPE_STORED);
         textFieldWithTermVectors.setStoreTermVectors(true);
         /*
           No offsets are stored.
@@ -40,15 +42,12 @@
         textFieldWithTermVectors.setStoreTermVectorPositions(true);
         textFieldWithTermVectors.setStoreTermVectorPayloads(true);
 
-        Field textFieldAnalyzed = new Field(
-            "text",
-            m.get("textStr"),
-            textFieldWithTermVectors
-        );
+        Field textFieldAnalyzed = new Field("text", m.get("textStr"),
+                textFieldWithTermVectors);
 
         MultiTermTokenStream ts = getTermVector(m.get("text"));
 
-        textFieldAnalyzed.setTokenStream( ts );
+        textFieldAnalyzed.setTokenStream(ts);
 
         doc.add(textFieldAnalyzed);
 
@@ -56,6 +55,7 @@
         w.addDocument(doc);
     };
 
+
     // Get Term Vector
     public static MultiTermTokenStream getTermVector (String stream) {
         MultiTermTokenStream ts = new MultiTermTokenStream();
@@ -85,7 +85,7 @@
                 fail(cde.getErrorCode() + ": " + cde.getMessage());
             };
         };
-        
+
         return ts;
     };
 
@@ -93,7 +93,7 @@
     // Get query wrapper based on json file
     public static SpanQueryWrapper getJSONQuery (String jsonFile) {
         SpanQueryWrapper sqwi;
-	
+
         try {
             String json = getString(jsonFile);
             sqwi = new KrillQuery("tokens").fromJson(json);
@@ -116,7 +116,8 @@
                 contentBuilder.append(str);
             };
             in.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             fail(e.getMessage());
         }
         return contentBuilder.toString();
@@ -125,10 +126,10 @@
 
     // getSpan Info
     public static List<String> getSpanInfo (IndexReader reader, SpanQuery query)
-        throws IOException {
+            throws IOException {
         Map<Term, TermContext> termContexts = new HashMap<>();
         List<String> spanArray = new ArrayList<>();
-        
+
         for (AtomicReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             // Spans spans = NearSpansOrdered();
@@ -140,7 +141,7 @@
                 if (spans.isPayloadAvailable()) {
                     for (byte[] payload : spans.getPayload()) {
                         /* retrieve payload for current matching span */
-                        
+
                         payloadString.append(byte2int(payload)).append(",");
                         payloadString.append(byte2int(payload, 2));
                         //			payloadString.append(byte2int(payload, 1));
@@ -148,16 +149,8 @@
                         payloadString.append(" | ");
                     };
                 };
-                spanArray.add(
-                    "Doc: " +
-                    docid +
-                    " with " +
-                    spans.start() +
-                    "-" +
-                    spans.end() +
-                    " || " +
-                    payloadString.toString()
-                );
+                spanArray.add("Doc: " + docid + " with " + spans.start() + "-"
+                        + spans.end() + " || " + payloadString.toString());
             };
         };
         return spanArray;
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 3f9f91d..4f7ba16 100644
--- a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
+++ b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
@@ -28,18 +28,21 @@
     @Test
     public void checkBenchmark1 () throws IOException {
         Properties prop = new Properties();
-        InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
+        InputStream fr = new FileInputStream(getClass().getResource(
+                "/krill.properties").getFile());
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(prop.getProperty("krill.indexDir"))));
+        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+                prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
         KrillCollection kc = new KrillCollection(ki);
 
         long t1 = 0, t2 = 0;
         /// cosmas20.json!!!
-        String json = getString(getClass().getResource("/queries/benchmark1.jsonld").getFile());
+        String json = getString(getClass().getResource(
+                "/queries/benchmark1.jsonld").getFile());
 
         int rounds = 100;
 
@@ -52,24 +55,24 @@
         t2 = System.nanoTime();
 
         // assertEquals("TotalResults", 30751, kr.getTotalResults());
-        assertEquals("TotalResults",  kr.getTotalResults(), 4803739);
+        assertEquals("TotalResults", kr.getTotalResults(), 4803739);
 
         //	long seconds = (long) (t2 - t1 / 1000) % 60 ;
-        double seconds = (double)(t2-t1) / 1000000000.0;
-	
+        double seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds");
 
         // 100 times:
         // 43,538 sec
         // 4.874
-        
+
         // 1000 times:
         // 36.613 sec
 
         // After refactoring
         // 100 times
         // 273.58114372 seconds
-        
+
         // After intro of attributes
         // 100 times
         // 350.171506379 seconds
@@ -79,24 +82,27 @@
     @Test
     public void checkBenchmark2JSON () throws IOException {
         Properties prop = new Properties();
-        InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
+        InputStream fr = new FileInputStream(getClass().getResource(
+                "/krill.properties").getFile());
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(prop.getProperty("krill.indexDir"))));
-        
+        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+                prop.getProperty("krill.indexDir"))));
+
         // Create a container for virtual collections:
         KrillCollection kc = new KrillCollection(ki);
 
         long t1 = 0, t2 = 0;
         /// cosmas20.json!!!
-        String json = getString(getClass().getResource("/queries/benchmark2.jsonld").getFile());
-        
+        String json = getString(getClass().getResource(
+                "/queries/benchmark2.jsonld").getFile());
+
         int rounds = 10000;
-        
+
         Result kr = new Result();
         String result = new String("");
-        
+
         t1 = System.nanoTime();
         double length = 0;
         for (int i = 1; i <= rounds; i++) {
@@ -110,8 +116,8 @@
         // System.err.println(kr.toJSON());
 
         //	long seconds = (long) (t2 - t1 / 1000) % 60 ;
-        double seconds = (double)(t2-t1) / 1000000000.0;
-	
+        double seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds");
 
         // 10000 times:
@@ -122,18 +128,21 @@
     @Test
     public void checkBenchmarkSentences () throws IOException {
         Properties prop = new Properties();
-        InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
+        InputStream fr = new FileInputStream(getClass().getResource(
+                "/krill.properties").getFile());
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(prop.getProperty("krill.indexDir"))));
+        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+                prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
         KrillCollection kc = new KrillCollection(ki);
 
         long t1 = 0, t2 = 0;
         /// cosmas20.json!!!
-        String json = getString(getClass().getResource("/queries/benchmark4.jsonld").getFile());
+        String json = getString(getClass().getResource(
+                "/queries/benchmark4.jsonld").getFile());
 
         int rounds = 10;
 
@@ -147,38 +156,42 @@
         t2 = System.nanoTime();
 
         // System.err.println(kr.getMatch(0).toJSON());
-        
-        assertEquals("TotalResults1", kr.getTotalResults(), 4116282);
-        assertEquals("TotalResults2", kr.getTotalResults(), ki.numberOf("sentences"));
 
-        double seconds = (double)(t2-t1) / 1000000000.0;
-        
+        assertEquals("TotalResults1", kr.getTotalResults(), 4116282);
+        assertEquals("TotalResults2", kr.getTotalResults(),
+                ki.numberOf("sentences"));
+
+        double seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds");
         // 100 rounds
         // 56.253 secs
     };
 
-    
+
     @Test
     public void checkBenchmarkClasses () throws IOException {
         // [orth=Der]{1:[orth=Mann]{2:[orth=und]}}
 
         Properties prop = new Properties();
-        InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
+        InputStream fr = new FileInputStream(getClass().getResource(
+                "/krill.properties").getFile());
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(prop.getProperty("krill.indexDir"))));
+        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+                prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
         KrillCollection kc = new KrillCollection(ki);
 
         long t1 = 0, t2 = 0;
         // Without classes
-        String json = getString(getClass().getResource("/queries/benchmark5-ohne.jsonld").getFile());
+        String json = getString(getClass().getResource(
+                "/queries/benchmark5-ohne.jsonld").getFile());
 
         int rounds = 2000;
-        
+
         Result kr = new Result();
 
         t1 = System.nanoTime();
@@ -187,29 +200,31 @@
         };
         t2 = System.nanoTime();
 
-        double seconds = (double)(t2-t1) / 1000000000.0;
-        
+        double seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds without classes");
 
         t1 = 0;
         t2 = 0;
         // With classes
-        json = getString(getClass().getResource("/queries/benchmark5.jsonld").getFile());
-        
+        json = getString(getClass().getResource("/queries/benchmark5.jsonld")
+                .getFile());
+
         t1 = System.nanoTime();
         for (int i = 1; i <= rounds; i++) {
             kr = new Krill(json).apply(ki);
         };
         t2 = System.nanoTime();
 
-        seconds = (double)(t2-t1) / 1000000000.0;
-        
+        seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds with classes");
 
         t1 = 0;
         t2 = 0;
         // With submatch
-        json = getString(getClass().getResource("/queries/benchmark5-submatch.jsonld").getFile());
+        json = getString(getClass().getResource(
+                "/queries/benchmark5-submatch.jsonld").getFile());
 
         t1 = System.nanoTime();
         for (int i = 1; i <= rounds; i++) {
@@ -217,12 +232,12 @@
         };
         t2 = System.nanoTime();
 
-        seconds = (double)(t2-t1) / 1000000000.0;
-        
+        seconds = (double) (t2 - t1) / 1000000000.0;
+
         // System.out.println("It took " + seconds + " seconds with submatches");
 
         /** HERE IS A BUG! */
-        
+
         // System.err.println(kr.toJsonString());
 
         // System.err.println(kr.toJSON());
@@ -249,12 +264,13 @@
         // It took 15.368675425 seconds without classes
         // It took 18.347603186 seconds with classes
         // It took 15.941057294 seconds with submatches
-        
+
         // It took 15.241253549 seconds without classes
         // It took 17.30375624 seconds with classes
         // It took 15.367171254 seconds with submatches
     };
 
+
     @Test
     public void checkBenchmarkIndexDocuments () throws IOException {
         long t1 = 0, t2 = 0;
@@ -264,14 +280,8 @@
         ArrayList<String> docs = new ArrayList<String>(700);
 
         for (int a = 0; a < 50; a++) {
-            for (String d : new String[] {
-                    "00001",
-                    "00002",
-                    "00003",
-                    "00004",
-                    "00005",
-                    "00006",
-                    "02439"}) {
+            for (String d : new String[] { "00001", "00002", "00003", "00004",
+                    "00005", "00006", "02439" }) {
                 docs.add(d);
             };
         };
@@ -281,19 +291,18 @@
         for (int i = 1; i <= rounds; i++) {
             // Construct index
             KrillIndex ki = new KrillIndex();
-            
+
             // Indexing test files
             for (String d : docs) {
                 FieldDocument fd = ki.addDoc(
-                    getClass().getResourceAsStream("/wiki/" + d + ".json.gz"),
-                    true
-                );
+                        getClass().getResourceAsStream(
+                                "/wiki/" + d + ".json.gz"), true);
             };
             ki.commit();
         };
         t2 = System.nanoTime();
 
-        double seconds = (double)(t2-t1) / 1000000000.0;
+        double seconds = (double) (t2 - t1) / 1000000000.0;
         // System.out.println("It took " + seconds + " seconds");
 
         // 10 times / 350 docs:
@@ -311,21 +320,24 @@
     @Test
     public void checkBenchmark3 () throws IOException {
         Properties prop = new Properties();
-        InputStream fr = new FileInputStream(getClass().getResource("/krill.properties").getFile());
+        InputStream fr = new FileInputStream(getClass().getResource(
+                "/krill.properties").getFile());
         prop.load(fr);
 
         // Get the real index
-        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(prop.getProperty("krill.indexDir"))));
+        KrillIndex ki = new KrillIndex(new MMapDirectory(new File(
+                prop.getProperty("krill.indexDir"))));
 
         // Create a container for virtual collections:
         KrillCollection kc = new KrillCollection(ki);
 
         long t1 = 0, t2 = 0;
         /// cosmas20.json!!!
-        String json = getString(getClass().getResource("/queries/benchmark3.jsonld").getFile());
+        String json = getString(getClass().getResource(
+                "/queries/benchmark3.jsonld").getFile());
 
         int rounds = 500;
-    
+
         Result kr = new Result();
 
         t1 = System.nanoTime();
@@ -339,8 +351,8 @@
         // System.err.println(kr.toJSON());
 
         //	long seconds = (long) (t2 - t1 / 1000) % 60 ;
-        double seconds = (double)(t2-t1) / 1000000000.0;
-	
+        double seconds = (double) (t2 - t1) / 1000000000.0;
+
         System.out.println("It took " + seconds + " seconds");
 
         // 500 times:
@@ -357,15 +369,17 @@
                 contentBuilder.append(str);
             };
             in.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             fail(e.getMessage());
         }
         return contentBuilder.toString();
     };
-    
+
+
     public static SpanQueryWrapper jsonQuery (String jsonFile) {
         SpanQueryWrapper sqwi;
-	
+
         try {
             String json = getString(jsonFile);
             sqwi = new KrillQuery("tokens").fromJson(json);
diff --git a/src/test/java/de/ids_mannheim/korap/cache/TestCache.java b/src/test/java/de/ids_mannheim/korap/cache/TestCache.java
index d968f82..06a882d 100644
--- a/src/test/java/de/ids_mannheim/korap/cache/TestCache.java
+++ b/src/test/java/de/ids_mannheim/korap/cache/TestCache.java
@@ -7,7 +7,6 @@
 import net.sf.jsr107cache.CacheFactory;
 import net.sf.jsr107cache.CacheManager;
 
-
 import static org.junit.Assert.*;
 import org.junit.Test;
 import org.junit.Ignore;
@@ -20,24 +19,25 @@
     @Test
     public void cache1 () {
 
-	Cache cache;
+        Cache cache;
 
         try {
-            CacheFactory cacheFactory = CacheManager.getInstance().getCacheFactory();
+            CacheFactory cacheFactory = CacheManager.getInstance()
+                    .getCacheFactory();
             cache = cacheFactory.createCache(Collections.emptyMap());
         }
 
-	catch (CacheException e) {
+        catch (CacheException e) {
             // ...
-	    return;
+            return;
         };
 
-	cache.put("beispiel1", "Das ist ein Test");
-	cache.put("beispiel2", "Das ist ein Versuch");
-	cache.put("beispiel3", "Das ist ein Beispiel");
+        cache.put("beispiel1", "Das ist ein Test");
+        cache.put("beispiel2", "Das ist ein Versuch");
+        cache.put("beispiel3", "Das ist ein Beispiel");
 
-	assertEquals(cache.get("beispiel1"), "Das ist ein Test");
-	assertEquals(cache.get("beispiel2"), "Das ist ein Versuch");
-	assertEquals(cache.get("beispiel3"), "Das ist ein Beispiel");
+        assertEquals(cache.get("beispiel1"), "Das ist ein Test");
+        assertEquals(cache.get("beispiel2"), "Das ist ein Versuch");
+        assertEquals(cache.get("beispiel3"), "Das ist ein Beispiel");
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java
index 18c8e57..417de65 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestCollectionBuilder.java
@@ -22,21 +22,31 @@
     public void filterExample () throws IOException {
         CollectionBuilder kf = new CollectionBuilder();
 
-        assertEquals("+textClass:tree", kf.and("textClass","tree").toString());
-        assertEquals("+textClass:tree +textClass:sport", kf.and("textClass","tree").and("textClass","sport").toString());
-        assertEquals("+textClass:tree +textClass:sport textClass:news", kf.and("textClass","tree").and("textClass","sport").or("textClass","news").toString());
-        assertEquals("+textClass:tree +textClass:sport +textClass:news", kf.and("textClass", "tree", "sport", "news").toString());
+        assertEquals("+textClass:tree", kf.and("textClass", "tree").toString());
+        assertEquals("+textClass:tree +textClass:sport",
+                kf.and("textClass", "tree").and("textClass", "sport")
+                        .toString());
+        assertEquals(
+                "+textClass:tree +textClass:sport textClass:news",
+                kf.and("textClass", "tree").and("textClass", "sport")
+                        .or("textClass", "news").toString());
+        assertEquals("+textClass:tree +textClass:sport +textClass:news", kf
+                .and("textClass", "tree", "sport", "news").toString());
 
-        assertEquals("corpusID:c-1 corpusID:c-2 corpusID:c-3", kf.or("corpusID", "c-1", "c-2", "c-3").toString());
+        assertEquals("corpusID:c-1 corpusID:c-2 corpusID:c-3",
+                kf.or("corpusID", "c-1", "c-2", "c-3").toString());
     };
 
 
     @Test
     public void rangeExample () throws IOException {
         CollectionBuilder kf = new CollectionBuilder();
-        assertEquals("+pubDate:[20030604 TO 20030899]", kf.between("2003-06-04", "2003-08-99").toString());
-        assertEquals("+pubDate:[0 TO 20030604]", kf.till("2003-06-04").toString());
-        assertEquals("+pubDate:[20030604 TO 99999999]", kf.since("2003-06-04").toString());
+        assertEquals("+pubDate:[20030604 TO 20030899]",
+                kf.between("2003-06-04", "2003-08-99").toString());
+        assertEquals("+pubDate:[0 TO 20030604]", kf.till("2003-06-04")
+                .toString());
+        assertEquals("+pubDate:[20030604 TO 99999999]", kf.since("2003-06-04")
+                .toString());
         assertEquals("+pubDate:20030604", kf.date("2003-06-04").toString());
     };
 
@@ -44,31 +54,47 @@
     @Test
     public void rangeLimited () throws IOException {
         CollectionBuilder kf = new CollectionBuilder();
-        assertEquals("+pubDate:[20050000 TO 20099999]", kf.between("2005", "2009").toString());
-       	assertEquals("+pubDate:[20051000 TO 20090899]", kf.between("200510", "200908").toString());
-        assertEquals("+pubDate:[20051000 TO 20090899]", kf.between("2005-10", "2009-08").toString());
-        assertEquals("+pubDate:[20051006 TO 20090803]", kf.between("2005-1006", "2009-0803").toString());
-        assertEquals("+pubDate:[20051006 TO 20090803]", kf.between("2005-10-06", "2009-08-03").toString());
-        
+        assertEquals("+pubDate:[20050000 TO 20099999]",
+                kf.between("2005", "2009").toString());
+        assertEquals("+pubDate:[20051000 TO 20090899]",
+                kf.between("200510", "200908").toString());
+        assertEquals("+pubDate:[20051000 TO 20090899]",
+                kf.between("2005-10", "2009-08").toString());
+        assertEquals("+pubDate:[20051006 TO 20090803]",
+                kf.between("2005-1006", "2009-0803").toString());
+        assertEquals("+pubDate:[20051006 TO 20090803]",
+                kf.between("2005-10-06", "2009-08-03").toString());
+
         assertEquals("+pubDate:[0 TO 20059999]", kf.till("2005").toString());
         assertEquals("+pubDate:[0 TO 20051099]", kf.till("200510").toString());
         assertEquals("+pubDate:[0 TO 20051099]", kf.till("2005-10").toString());
-        assertEquals("+pubDate:[0 TO 20051006]", kf.till("2005-1006").toString());
-        assertEquals("+pubDate:[0 TO 20051006]", kf.till("2005-10-06").toString());
+        assertEquals("+pubDate:[0 TO 20051006]", kf.till("2005-1006")
+                .toString());
+        assertEquals("+pubDate:[0 TO 20051006]", kf.till("2005-10-06")
+                .toString());
 
-        assertEquals("+pubDate:[20050000 TO 99999999]", kf.since("2005").toString());
-        assertEquals("+pubDate:[20051000 TO 99999999]", kf.since("200510").toString());
-        assertEquals("+pubDate:[20051000 TO 99999999]", kf.since("2005-10").toString());
-        assertEquals("+pubDate:[20051006 TO 99999999]", kf.since("2005-1006").toString());
-        assertEquals("+pubDate:[20051006 TO 99999999]", kf.since("2005-10-06").toString());
-        
-        assertEquals("+pubDate:[20050000 TO 20059999]", kf.date("2005").toString());
-        assertEquals("+pubDate:[20051000 TO 20051099]", kf.date("200510").toString());
-        assertEquals("+pubDate:[20051000 TO 20051099]", kf.date("2005-10").toString());
+        assertEquals("+pubDate:[20050000 TO 99999999]", kf.since("2005")
+                .toString());
+        assertEquals("+pubDate:[20051000 TO 99999999]", kf.since("200510")
+                .toString());
+        assertEquals("+pubDate:[20051000 TO 99999999]", kf.since("2005-10")
+                .toString());
+        assertEquals("+pubDate:[20051006 TO 99999999]", kf.since("2005-1006")
+                .toString());
+        assertEquals("+pubDate:[20051006 TO 99999999]", kf.since("2005-10-06")
+                .toString());
+
+        assertEquals("+pubDate:[20050000 TO 20059999]", kf.date("2005")
+                .toString());
+        assertEquals("+pubDate:[20051000 TO 20051099]", kf.date("200510")
+                .toString());
+        assertEquals("+pubDate:[20051000 TO 20051099]", kf.date("2005-10")
+                .toString());
         assertEquals("+pubDate:20051006", kf.date("2005-1006").toString());
         assertEquals("+pubDate:20051006", kf.date("2005-10-06").toString());
     };
-    
+
+
     @Test
     public void rangeFailure () throws IOException {
         CollectionBuilder kf = new CollectionBuilder();
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
index 0e6a806..37c33f4 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSON.java
@@ -18,25 +18,23 @@
 
     final String path = "/queries/collections/";
 
+
     @Test
     public void collection1 () {
         String metaQuery = _getJSONString("collection_1.jsonld");
         KrillCollection kc = new KrillCollection(metaQuery);
-        assertEquals(
-            kc.toString(),
-            "filter with QueryWrapperFilter(+pubDate:20000101); "
-        );
+        assertEquals(kc.toString(),
+                "filter with QueryWrapperFilter(+pubDate:20000101); ");
     };
 
+
     @Test
     public void collection2 () {
         String metaQuery = _getJSONString("collection_2.jsonld");
         KrillCollection kc = new KrillCollection(metaQuery);
-        assertEquals(
-            kc.toString(),
-            "filter with QueryWrapperFilter(+(+pubDate:"+
-            "[19900000 TO 99999999] +pubDate:[0 TO 20061099])); "
-        );
+        assertEquals(kc.toString(),
+                "filter with QueryWrapperFilter(+(+pubDate:"
+                        + "[19900000 TO 99999999] +pubDate:[0 TO 20061099])); ");
     };
 
 
@@ -52,11 +50,8 @@
     public void collection5 () {
         String metaQuery = _getJSONString("collection_5.jsonld");
         KrillCollection kc = new KrillCollection(metaQuery);
-        assertEquals(
-            kc.toString(),
-            "filter with QueryWrapperFilter(+(pubDate:"+
-            "[19900000 TO 99999999] title:Mannheim)); "
-        );
+        assertEquals(kc.toString(), "filter with QueryWrapperFilter(+(pubDate:"
+                + "[19900000 TO 99999999] title:Mannheim)); ");
     };
 
 
@@ -72,10 +67,8 @@
     public void noCollection () {
         String metaQuery = _getJSONString("no_collection.jsonld");
         KrillCollection kc = new KrillCollection(metaQuery);
-        assertEquals(
-            "filter with QueryWrapperFilter(+corpusID:WPD); ",
-            kc.toString()
-        );
+        assertEquals("filter with QueryWrapperFilter(+corpusID:WPD); ",
+                kc.toString());
     };
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
index 41a0d41..f83804f 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionJSONLegacy.java
@@ -18,46 +18,68 @@
 
     @Test
     public void metaQuery1 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery.jsonld").getFile());
-	KrillCollection kc = new KrillCollection(metaQuery);
+        String metaQuery = getString(getClass().getResource(
+                "/queries/metaquery.jsonld").getFile());
+        KrillCollection kc = new KrillCollection(metaQuery);
 
-	assertEquals("filter with QueryWrapperFilter(+textClass:wissenschaft)", kc.getFilter(0).toString());
-	assertEquals("filter with QueryWrapperFilter(+(+pubPlace:Erfurt +author:Hesse))", kc.getFilter(1).toString());
-	assertEquals("extend with QueryWrapperFilter(+(+pubDate:[20110429 TO 20131231] +textClass:freizeit))", kc.getFilter(2).toString());
-	assertEquals(3, kc.getCount());
+        assertEquals("filter with QueryWrapperFilter(+textClass:wissenschaft)",
+                kc.getFilter(0).toString());
+        assertEquals(
+                "filter with QueryWrapperFilter(+(+pubPlace:Erfurt +author:Hesse))",
+                kc.getFilter(1).toString());
+        assertEquals(
+                "extend with QueryWrapperFilter(+(+pubDate:[20110429 TO 20131231] +textClass:freizeit))",
+                kc.getFilter(2).toString());
+        assertEquals(3, kc.getCount());
     };
 
 
     @Test
     public void metaQuery2 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery2.jsonld").getFile());
-	KrillCollection kc = new KrillCollection(metaQuery);
-	assertEquals(1,kc.getCount());
-	assertEquals("filter with QueryWrapperFilter(+(+author:Hesse +pubDate:[0 TO 20131205]))",kc.getFilter(0).toString());
+        String metaQuery = getString(getClass().getResource(
+                "/queries/metaquery2.jsonld").getFile());
+        KrillCollection kc = new KrillCollection(metaQuery);
+        assertEquals(1, kc.getCount());
+        assertEquals(
+                "filter with QueryWrapperFilter(+(+author:Hesse +pubDate:[0 TO 20131205]))",
+                kc.getFilter(0).toString());
     };
 
+
     @Test
     public void metaQuery3 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery4.jsonld").getFile());
-	KrillCollection kc = new KrillCollection(metaQuery);
-	assertEquals(1,kc.getCount());
-	assertEquals("filter with QueryWrapperFilter(+pubDate:[20000101 TO 20131231])",kc.getFilter(0).toString());
+        String metaQuery = getString(getClass().getResource(
+                "/queries/metaquery4.jsonld").getFile());
+        KrillCollection kc = new KrillCollection(metaQuery);
+        assertEquals(1, kc.getCount());
+        assertEquals(
+                "filter with QueryWrapperFilter(+pubDate:[20000101 TO 20131231])",
+                kc.getFilter(0).toString());
     };
 
+
     @Test
     public void metaQuery7 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery7.jsonld").getFile());
-	KrillCollection kc = new KrillCollection(metaQuery);
-	assertEquals(2,kc.getCount());
-	assertEquals("filter with QueryWrapperFilter(+(corpusID:c-1 corpusID:c-2))",kc.getFilter(0).toString());
-	assertEquals("filter with QueryWrapperFilter(+(+corpusID:d-1 +corpusID:d-2))",kc.getFilter(1).toString());
+        String metaQuery = getString(getClass().getResource(
+                "/queries/metaquery7.jsonld").getFile());
+        KrillCollection kc = new KrillCollection(metaQuery);
+        assertEquals(2, kc.getCount());
+        assertEquals(
+                "filter with QueryWrapperFilter(+(corpusID:c-1 corpusID:c-2))",
+                kc.getFilter(0).toString());
+        assertEquals(
+                "filter with QueryWrapperFilter(+(+corpusID:d-1 +corpusID:d-2))",
+                kc.getFilter(1).toString());
     };
 
+
     @Test
     public void metaQuery9 () {
-	String metaQuery = getString(getClass().getResource("/queries/metaquery9.jsonld").getFile());
-	KrillCollection kc = new KrillCollection(metaQuery);
-	assertEquals(1,kc.getCount());
-	assertEquals("filter with QueryWrapperFilter(+corpusID:WPD)",kc.getFilter(0).toString());
+        String metaQuery = getString(getClass().getResource(
+                "/queries/metaquery9.jsonld").getFile());
+        KrillCollection kc = new KrillCollection(metaQuery);
+        assertEquals(1, kc.getCount());
+        assertEquals("filter with QueryWrapperFilter(+corpusID:WPD)", kc
+                .getFilter(0).toString());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
index 4c2a83b..8341c1c 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKrillCollectionLegacy.java
@@ -26,247 +26,227 @@
 
     @Test
     public void filterExample () throws Exception {
-	
-	// Construct index
-	KrillIndex ki = new KrillIndex();
-	// Indexing test files
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	    ki.addDoc(
-	        getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
-	};
-	ki.commit();
 
-	CollectionBuilder kf = new CollectionBuilder();
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        // Indexing test files
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
 
-	// Create Virtual collections:
-	KrillCollection kc = new KrillCollection(ki);
+        CollectionBuilder kf = new CollectionBuilder();
 
-	assertEquals("Documents", 7, kc.numberOf("documents"));
+        // Create Virtual collections:
+        KrillCollection kc = new KrillCollection(ki);
 
-	// The virtual collection consists of all documents that have
-	// the textClass "reisen" and "freizeit"
+        assertEquals("Documents", 7, kc.numberOf("documents"));
 
-	kc.filter(
-            kf.and("textClass", "reisen")
-	      .and("textClass", "freizeit-unterhaltung")
-	);
+        // The virtual collection consists of all documents that have
+        // the textClass "reisen" and "freizeit"
 
-	assertEquals("Documents", 5, kc.numberOf("documents"));
-	assertEquals("Tokens", 1678, kc.numberOf("tokens"));
-	assertEquals("Sentences", 194, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
+        kc.filter(kf.and("textClass", "reisen").and("textClass",
+                "freizeit-unterhaltung"));
 
-	// Subset this to all documents that have also the text
-	kc.filter(kf.and("textClass", "kultur"));
+        assertEquals("Documents", 5, kc.numberOf("documents"));
+        assertEquals("Tokens", 1678, kc.numberOf("tokens"));
+        assertEquals("Sentences", 194, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
 
-	assertEquals("Documents", 1, kc.numberOf("documents"));
-	assertEquals("Tokens", 405, kc.numberOf("tokens"));
-	assertEquals("Sentences", 75, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+        // Subset this to all documents that have also the text
+        kc.filter(kf.and("textClass", "kultur"));
 
-	kc.filter(kf.and("corpusID", "WPD"));
+        assertEquals("Documents", 1, kc.numberOf("documents"));
+        assertEquals("Tokens", 405, kc.numberOf("tokens"));
+        assertEquals("Sentences", 75, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
 
-	assertEquals("Documents", 1, kc.numberOf("documents"));
-	assertEquals("Tokens", 405, kc.numberOf("tokens"));
-	assertEquals("Sentences", 75, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+        kc.filter(kf.and("corpusID", "WPD"));
 
-	// Create a query
-	QueryBuilder kq = new QueryBuilder("tokens");
-	SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
+        assertEquals("Documents", 1, kc.numberOf("documents"));
+        assertEquals("Tokens", 405, kc.numberOf("tokens"));
+        assertEquals("Sentences", 75, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
 
-	Result kr = kc.search(query);
-	assertEquals(kr.getTotalResults(), 70);
+        // Create a query
+        QueryBuilder kq = new QueryBuilder("tokens");
+        SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
 
-	kc.extend( kf.and("textClass", "uninteresting") );
-	assertEquals("Documents", 1, kc.numberOf("documents"));
+        Result kr = kc.search(query);
+        assertEquals(kr.getTotalResults(), 70);
 
-	kc.extend( kf.and("textClass", "wissenschaft") );
+        kc.extend(kf.and("textClass", "uninteresting"));
+        assertEquals("Documents", 1, kc.numberOf("documents"));
 
-	assertEquals("Documents", 3, kc.numberOf("documents"));
-	assertEquals("Tokens", 1669, kc.numberOf("tokens"));
-	assertEquals("Sentences", 188, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
-	// System.err.println(kr.toJSON());
+        kc.extend(kf.and("textClass", "wissenschaft"));
+
+        assertEquals("Documents", 3, kc.numberOf("documents"));
+        assertEquals("Tokens", 1669, kc.numberOf("tokens"));
+        assertEquals("Sentences", 188, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
+        // System.err.println(kr.toJSON());
     };
 
+
     @Test
     public void filterExampleAtomic () throws Exception {
-	
-	// That's exactly the same test class, but with multiple atomic indices
 
-	// Construct index
-	KrillIndex ki = new KrillIndex();
-	// Indexing test files
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	    ki.addDoc(
-	      getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
-	    ki.commit();
-	};
+        // That's exactly the same test class, but with multiple atomic indices
 
-	CollectionBuilder kf = new CollectionBuilder();
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        // Indexing test files
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+            ki.commit();
+        };
 
-	// Create Virtual collections:
-	KrillCollection kc = new KrillCollection(ki);
+        CollectionBuilder kf = new CollectionBuilder();
 
-	assertEquals("Documents", 7, kc.numberOf("documents"));
+        // Create Virtual collections:
+        KrillCollection kc = new KrillCollection(ki);
 
-	// If this is set - everything is fine automatically ...
-	kc.filter(kf.and("corpusID", "WPD"));
-	assertEquals("Documents", 7, kc.numberOf("documents"));
+        assertEquals("Documents", 7, kc.numberOf("documents"));
+
+        // If this is set - everything is fine automatically ...
+        kc.filter(kf.and("corpusID", "WPD"));
+        assertEquals("Documents", 7, kc.numberOf("documents"));
 
 
-	// The virtual collection consists of all documents that have the textClass "reisen" and "freizeit"
+        // The virtual collection consists of all documents that have the textClass "reisen" and "freizeit"
 
-	kc.filter( kf.and("textClass", "reisen").and("textClass", "freizeit-unterhaltung") );
+        kc.filter(kf.and("textClass", "reisen").and("textClass",
+                "freizeit-unterhaltung"));
 
-	assertEquals("Documents", 5, kc.numberOf("documents"));
-	assertEquals("Tokens", 1678, kc.numberOf("tokens"));
-	assertEquals("Sentences", 194, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
+        assertEquals("Documents", 5, kc.numberOf("documents"));
+        assertEquals("Tokens", 1678, kc.numberOf("tokens"));
+        assertEquals("Sentences", 194, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
 
-	// Subset this to all documents that have also the text
-	kc.filter(kf.and("textClass", "kultur"));
+        // Subset this to all documents that have also the text
+        kc.filter(kf.and("textClass", "kultur"));
 
-	assertEquals("Documents", 1, kc.numberOf("documents"));
-	assertEquals("Tokens", 405, kc.numberOf("tokens"));
-	assertEquals("Sentences", 75, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+        assertEquals("Documents", 1, kc.numberOf("documents"));
+        assertEquals("Tokens", 405, kc.numberOf("tokens"));
+        assertEquals("Sentences", 75, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
 
-	// This is already filtered though ...
-	kc.filter(kf.and("corpusID", "WPD"));
+        // This is already filtered though ...
+        kc.filter(kf.and("corpusID", "WPD"));
 
-	assertEquals("Documents", 1, kc.numberOf("documents"));
-	assertEquals("Tokens", 405, kc.numberOf("tokens"));
-	assertEquals("Sentences", 75, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
+        assertEquals("Documents", 1, kc.numberOf("documents"));
+        assertEquals("Tokens", 405, kc.numberOf("tokens"));
+        assertEquals("Sentences", 75, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 48, kc.numberOf("paragraphs"));
 
-	// Create a query
-	QueryBuilder kq = new QueryBuilder("tokens");
-	SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
+        // Create a query
+        QueryBuilder kq = new QueryBuilder("tokens");
+        SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
 
-	Result kr = kc.search(query);
-	assertEquals(kr.getTotalResults(), 70);
+        Result kr = kc.search(query);
+        assertEquals(kr.getTotalResults(), 70);
 
-	kc.extend( kf.and("textClass", "uninteresting") );
-	assertEquals("Documents", 1, kc.numberOf("documents"));
+        kc.extend(kf.and("textClass", "uninteresting"));
+        assertEquals("Documents", 1, kc.numberOf("documents"));
 
-	kc.extend( kf.and("textClass", "wissenschaft") );
+        kc.extend(kf.and("textClass", "wissenschaft"));
 
-	assertEquals("Documents", 3, kc.numberOf("documents"));
-	assertEquals("Tokens", 1669, kc.numberOf("tokens"));
-	assertEquals("Sentences", 188, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
+        assertEquals("Documents", 3, kc.numberOf("documents"));
+        assertEquals("Tokens", 1669, kc.numberOf("tokens"));
+        assertEquals("Sentences", 188, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 130, kc.numberOf("paragraphs"));
     };
 
 
 
     @Test
     public void filterExample2 () throws Exception {
-	
-	// Construct index
-	KrillIndex ki = new KrillIndex();
-	// Indexing test files
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	  ki.addDoc(
-	      getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
-	};
-	ki.commit();
 
-	ki.addDoc(getClass().getResourceAsStream("/wiki/00012-fakemeta.json.gz"), true);
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        // Indexing test files
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
 
-	ki.commit();
+        ki.addDoc(getClass()
+                .getResourceAsStream("/wiki/00012-fakemeta.json.gz"), true);
 
-	CollectionBuilder kf = new CollectionBuilder();
+        ki.commit();
 
-	// Create Virtual collections:
-	KrillCollection kc = new KrillCollection(ki);
-	kc.filter( kf.and("textClass", "reisen").and("textClass", "freizeit-unterhaltung") );
-	assertEquals("Documents", 5, kc.numberOf("documents"));
-	assertEquals("Tokens", 1678, kc.numberOf("tokens"));
-	assertEquals("Sentences", 194, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
+        CollectionBuilder kf = new CollectionBuilder();
 
-	// Create a query
-	QueryBuilder kq = new QueryBuilder("tokens");
-	SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
+        // Create Virtual collections:
+        KrillCollection kc = new KrillCollection(ki);
+        kc.filter(kf.and("textClass", "reisen").and("textClass",
+                "freizeit-unterhaltung"));
+        assertEquals("Documents", 5, kc.numberOf("documents"));
+        assertEquals("Tokens", 1678, kc.numberOf("tokens"));
+        assertEquals("Sentences", 194, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 139, kc.numberOf("paragraphs"));
 
-	Result kr = kc.search(query);
+        // Create a query
+        QueryBuilder kq = new QueryBuilder("tokens");
+        SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
 
-	assertEquals(kr.getTotalResults(), 369);
+        Result kr = kc.search(query);
 
-	kc.filter( kf.and("corpusID", "QQQ") );
+        assertEquals(kr.getTotalResults(), 369);
 
-	assertEquals("Documents", 0, kc.numberOf("documents"));
-	assertEquals("Tokens", 0, kc.numberOf("tokens"));
-	assertEquals("Sentences", 0, kc.numberOf("sentences"));
-	assertEquals("Paragraphs", 0, kc.numberOf("paragraphs"));
+        kc.filter(kf.and("corpusID", "QQQ"));
+
+        assertEquals("Documents", 0, kc.numberOf("documents"));
+        assertEquals("Tokens", 0, kc.numberOf("tokens"));
+        assertEquals("Sentences", 0, kc.numberOf("sentences"));
+        assertEquals("Paragraphs", 0, kc.numberOf("paragraphs"));
     };
 
 
     @Test
     public void uidCollection () throws IOException {
-	
-	// Construct index
-	KrillIndex ki = new KrillIndex();
-	// Indexing test files
-	int uid = 1;
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	    FieldDocument fd = ki.addDoc(
-                                     uid++,
-	        getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-		true
-	    );
-	};
-	ki.commit();
 
-	assertEquals("Documents",    7, ki.numberOf("documents"));
-	assertEquals("Paragraphs", 174, ki.numberOf("paragraphs"));
-	assertEquals("Sentences",  281, ki.numberOf("sentences"));
-	assertEquals("Tokens",    2661, ki.numberOf("tokens"));
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        // Indexing test files
+        int uid = 1;
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            FieldDocument fd = ki.addDoc(uid++,
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
 
-	SpanQuery sq = new SpanTermQuery(new Term("tokens", "s:der"));
-	Result kr = ki.search(sq, (short) 10);
-        assertEquals(86,kr.getTotalResults());
+        assertEquals("Documents", 7, ki.numberOf("documents"));
+        assertEquals("Paragraphs", 174, ki.numberOf("paragraphs"));
+        assertEquals("Sentences", 281, ki.numberOf("sentences"));
+        assertEquals("Tokens", 2661, ki.numberOf("tokens"));
 
-	// Create Virtual collections:
-	KrillCollection kc = new KrillCollection();
-	kc.filterUIDs(new String[]{"2", "3", "4"});
-	kc.setIndex(ki);
-	assertEquals("Documents", 3, kc.numberOf("documents"));
+        SpanQuery sq = new SpanTermQuery(new Term("tokens", "s:der"));
+        Result kr = ki.search(sq, (short) 10);
+        assertEquals(86, kr.getTotalResults());
 
-	assertEquals("Paragraphs", 46, kc.numberOf("paragraphs"));
-	assertEquals("Sentences", 103, kc.numberOf("sentences"));
-	assertEquals("Tokens",   1229, kc.numberOf("tokens"));
+        // Create Virtual collections:
+        KrillCollection kc = new KrillCollection();
+        kc.filterUIDs(new String[] { "2", "3", "4" });
+        kc.setIndex(ki);
+        assertEquals("Documents", 3, kc.numberOf("documents"));
 
-	kr = kc.search(sq);
+        assertEquals("Paragraphs", 46, kc.numberOf("paragraphs"));
+        assertEquals("Sentences", 103, kc.numberOf("sentences"));
+        assertEquals("Tokens", 1229, kc.numberOf("tokens"));
+
+        kr = kc.search(sq);
         assertEquals((long) 39, kr.getTotalResults());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
index 003b129..b4ec124 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
@@ -21,90 +21,93 @@
 
 
 public class TestClass {
-	KrillIndex ki;
-	Result kr;
-	Krill ks;
-	
-	@Test
-	public void queryJSONpoly1() throws QueryException, IOException {
-		
-		String jsonPath = getClass().getResource("/queries/poly1.json").getFile();
-		String jsonQuery = readFile(jsonPath);
-		SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson(
-				jsonQuery
-		);
-		
-		SpanNextQuery sq = (SpanNextQuery) sqwi.toQuery();
-		//System.out.println(sq.toString());
-		
-		ki = new KrillIndex();
-	    ki.addDoc(
-	    	getClass().getResourceAsStream("/wiki/JJJ-00785.json.gz"),true);
-	    ki.addDoc(
-		        getClass().getResourceAsStream("/wiki/DDD-01402.json.gz"),true);
-		ki.commit();
-		kr = ki.search(sq, (short) 10);
+    KrillIndex ki;
+    Result kr;
+    Krill ks;
 
-		assertEquals(61, kr.getMatch(0).getStartPos());
-		assertEquals(64, kr.getMatch(0).getEndPos());
-		assertEquals("... Bruckner (Wien) und Mathis Lussy (Paris). [{1:Inspiriert} " +
-				"{2:durch die}] additiven Modelle arabischer Rhythmik (er half ...", 
-				kr.getMatch(0).getSnippetBrackets());
-		
-		assertEquals(31, kr.getMatch(1).getStartPos());
-		assertEquals(34, kr.getMatch(1).getEndPos());
-		assertEquals("... des Sendens wird ein unhörbarer Unterton [{1:mitgesendet}, " +
-				"{2:auf den}] das angesprochene Funkgerät reagiert. Die Abkürzung ...", 
-				kr.getMatch(1).getSnippetBrackets());
-	}
 
     @Test
-	public void queryJSONpoly4() throws QueryException, IOException {
-		
-		String jsonPath = getClass().getResource("/queries/poly4.json").getFile();
-		String jsonQuery = readFile(jsonPath);
-		SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson(
-				jsonQuery
-		);
-		SpanQuery sq = sqwi.toQuery();
-		
-		// System.out.println(sq.toString());
-		
+    public void queryJSONpoly1 () throws QueryException, IOException {
 
-		ki = new KrillIndex();
-	    ki.addDoc(
-	    	getClass().getResourceAsStream("/wiki/SSS-09803.json.gz"), true);
-	    
-	    ki.commit();
-		kr = ki.search(sq, (short) 10);
-				
-		/*
-		for (Match km : kr.getMatches()){
-			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
-					+km.getSnippetBrackets()
-			);
-		}
-		*/
-		assertEquals((long) 495, kr.getTotalResults());
-		assertEquals(3, kr.getMatch(0).getStartPos());
-		assertEquals(5, kr.getMatch(0).getEndPos());
-		
-		//fail("Tests have to be updated");
-	}
-	
-	
-	private String readFile(String path) {
-		StringBuilder sb = new StringBuilder();
-		try {
-		    BufferedReader in = new BufferedReader(new FileReader(path));
-		    String str;
-		    while ((str = in.readLine()) != null) {
-		    	sb.append(str);
-		    };
-		    in.close();
-		} catch (IOException e) {
-		    fail(e.getMessage());
-		}
-		return sb.toString();
-	}
+        String jsonPath = getClass().getResource("/queries/poly1.json")
+                .getFile();
+        String jsonQuery = readFile(jsonPath);
+        SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson(jsonQuery);
+
+        SpanNextQuery sq = (SpanNextQuery) sqwi.toQuery();
+        //System.out.println(sq.toString());
+
+        ki = new KrillIndex();
+        ki.addDoc(getClass().getResourceAsStream("/wiki/JJJ-00785.json.gz"),
+                true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/DDD-01402.json.gz"),
+                true);
+        ki.commit();
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(61, kr.getMatch(0).getStartPos());
+        assertEquals(64, kr.getMatch(0).getEndPos());
+        assertEquals(
+                "... Bruckner (Wien) und Mathis Lussy (Paris). [{1:Inspiriert} "
+                        + "{2:durch die}] additiven Modelle arabischer Rhythmik (er half ...",
+                kr.getMatch(0).getSnippetBrackets());
+
+        assertEquals(31, kr.getMatch(1).getStartPos());
+        assertEquals(34, kr.getMatch(1).getEndPos());
+        assertEquals(
+                "... des Sendens wird ein unhörbarer Unterton [{1:mitgesendet}, "
+                        + "{2:auf den}] das angesprochene Funkgerät reagiert. Die Abkürzung ...",
+                kr.getMatch(1).getSnippetBrackets());
+    }
+
+
+    @Test
+    public void queryJSONpoly4 () throws QueryException, IOException {
+
+        String jsonPath = getClass().getResource("/queries/poly4.json")
+                .getFile();
+        String jsonQuery = readFile(jsonPath);
+        SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson(jsonQuery);
+        SpanQuery sq = sqwi.toQuery();
+
+        // System.out.println(sq.toString());
+
+
+        ki = new KrillIndex();
+        ki.addDoc(getClass().getResourceAsStream("/wiki/SSS-09803.json.gz"),
+                true);
+
+        ki.commit();
+        kr = ki.search(sq, (short) 10);
+
+        /*
+        for (Match km : kr.getMatches()){
+        	System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+        			+km.getSnippetBrackets()
+        	);
+        }
+        */
+        assertEquals((long) 495, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(0).getStartPos());
+        assertEquals(5, kr.getMatch(0).getEndPos());
+
+        //fail("Tests have to be updated");
+    }
+
+
+    private String readFile (String path) {
+        StringBuilder sb = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(path));
+            String str;
+            while ((str = in.readLine()) != null) {
+                sb.append(str);
+            };
+            in.close();
+        }
+        catch (IOException e) {
+            fail(e.getMessage());
+        }
+        return sb.toString();
+    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
index bb5b236..c2da28b 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -27,137 +27,135 @@
 public class TestHighlight { // extends LuceneTestCase {
 
     @Test
-    public void checkHighlights () throws IOException, QueryException  {
+    public void checkHighlights () throws IOException, QueryException {
 
         KrillIndex ki = new KrillIndex();
-        String json = new String(
-"{" +
-"  \"fields\" : [" +
-"    { "+
-"      \"primaryData\" : \"abc\"" +
-"    }," +
-"    {" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" +
-"      ]" +
-"    }" +
-"  ]" +
-"}");
+        String json = new String("{" + "  \"fields\" : [" + "    { "
+                + "      \"primaryData\" : \"abc\"" + "    }," + "    {"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" + "      ]"
+                + "    }" + "  ]" + "}");
 
         FieldDocument fd = ki.addDoc(json);
         ki.commit();
 
 
         QueryBuilder kq = new QueryBuilder("tokens");
-        Result kr = ki.search(
-            (SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).toQuery()
-        );
+        Result kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b")))
+                .toQuery());
         Match km = kr.getMatch(0);
-        assertEquals(km.getStartPos(),  1);
-        assertEquals(km.getEndPos(),    2);
+        assertEquals(km.getStartPos(), 1);
+        assertEquals(km.getEndPos(), 2);
         assertEquals(km.getStartPos(1), 1);
-        assertEquals(km.getEndPos(1),   2);
-        assertEquals("<span class=\"context-left\">a</span><mark><mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">c</span>", km.getSnippetHTML());
+        assertEquals(km.getEndPos(1), 2);
+        assertEquals(
+                "<span class=\"context-left\">a</span><mark><mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">c</span>",
+                km.getSnippetHTML());
 
-        kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b"))).append(kq._(2, kq.seg("s:c"))).toQuery());
+        kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seg("s:b")))
+                .append(kq._(2, kq.seg("s:c"))).toQuery());
         km = kr.getMatch(0);
-        assertEquals(km.getStartPos(),  1);
-        assertEquals(km.getEndPos(),    3);
+        assertEquals(km.getStartPos(), 1);
+        assertEquals(km.getEndPos(), 3);
         assertEquals(km.getStartPos(1), 1);
-        assertEquals(km.getEndPos(1),   2);
+        assertEquals(km.getEndPos(1), 2);
         assertEquals(km.getStartPos(2), 2);
-        assertEquals(km.getEndPos(2),   3);
-        assertEquals("<span class=\"context-left\">a</span><mark><mark class=\"class-1 level-0\">b</mark><mark class=\"class-2 level-0\">c</mark></mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(km.getEndPos(2), 3);
+        assertEquals(
+                "<span class=\"context-left\">a</span><mark><mark class=\"class-1 level-0\">b</mark><mark class=\"class-2 level-0\">c</mark></mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
 
 
-        kr = ki.search((SpanQuery) kq.seq(kq._(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b")))).append(kq._(2, kq.seg("s:c"))).toQuery());
+        kr = ki.search((SpanQuery) kq
+                .seq(kq._(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b"))))
+                .append(kq._(2, kq.seg("s:c"))).toQuery());
         km = kr.getMatch(0);
         assertEquals(km.getStartPos(), 0);
-        assertEquals(km.getEndPos(),   3);
+        assertEquals(km.getEndPos(), 3);
         assertEquals(km.getStartPos(1), 0);
-        assertEquals(km.getEndPos(1),   2);
+        assertEquals(km.getEndPos(1), 2);
         assertEquals(km.getStartPos(2), 2);
-        assertEquals(km.getEndPos(2),   3);
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-1 level-0\">ab</mark><mark class=\"class-2 level-0\">c</mark></mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(km.getEndPos(2), 3);
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-1 level-0\">ab</mark><mark class=\"class-2 level-0\">c</mark></mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
 
 
-        kr = ki.search((SpanQuery) kq._(3, kq.seq(kq._(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b")))).append(kq._(2, kq.seg("s:c")))).toQuery());
+        kr = ki.search((SpanQuery) kq._(
+                3,
+                kq.seq(kq._(1, kq.seq(kq.seg("s:a")).append(kq.seg("s:b"))))
+                        .append(kq._(2, kq.seg("s:c")))).toQuery());
         km = kr.getMatch(0);
         assertEquals(km.getStartPos(), 0);
-        assertEquals(km.getEndPos(),   3);
+        assertEquals(km.getEndPos(), 3);
         assertEquals(km.getStartPos(1), 0);
-        assertEquals(km.getEndPos(1),   2);
+        assertEquals(km.getEndPos(1), 2);
         assertEquals(km.getStartPos(2), 2);
-        assertEquals(km.getEndPos(2),   3);
+        assertEquals(km.getEndPos(2), 3);
         assertEquals(km.getStartPos(3), 0);
-        assertEquals(km.getEndPos(3),   3);
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-3 level-0\"><mark class=\"class-1 level-1\">ab</mark><mark class=\"class-2 level-1\">c</mark></mark></mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(km.getEndPos(3), 3);
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-3 level-0\"><mark class=\"class-1 level-1\">ab</mark><mark class=\"class-2 level-1\">c</mark></mark></mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
     };
 
+
     @Test
-    public void checkHighlightsManually () throws IOException, QueryException  {
+    public void checkHighlightsManually () throws IOException, QueryException {
 
         KrillIndex ki = new KrillIndex();
-        String json = new String(
-"{" +
-"  \"fields\" : [" +
-"    { "+
-"      \"primaryData\" : \"abc\"" +
-"    }," +
-"    {" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" +
-"      ]" +
-"    }" +
-"  ]" +
-"}");
+        String json = new String("{" + "  \"fields\" : [" + "    { "
+                + "      \"primaryData\" : \"abc\"" + "    }," + "    {"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" + "      ]"
+                + "    }" + "  ]" + "}");
 
         FieldDocument fd = ki.addDoc(json);
         ki.commit();
 
         QueryBuilder kq = new QueryBuilder("tokens");
 
-        Result kr = ki.search((SpanQuery) kq.seq(kq.seg("s:a")).append(kq.seg("s:b")).append(kq.seg("s:c")).toQuery());
+        Result kr = ki.search((SpanQuery) kq.seq(kq.seg("s:a"))
+                .append(kq.seg("s:b")).append(kq.seg("s:c")).toQuery());
         Match km = kr.getMatch(0);
         km.addHighlight(0, 1, (short) 7);
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\">ab</mark>c</mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\">ab</mark>c</mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
 
         km.addHighlight(1, 2, (short) 6);
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\">a<mark class=\"class-6 level-1\">b</mark></mark><mark class=\"class-6 level-1\">c</mark></mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\">a<mark class=\"class-6 level-1\">b</mark></mark><mark class=\"class-6 level-1\">c</mark></mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
 
         km.addHighlight(0, 1, (short) 5);
         assertEquals("[{7:{5:a{6:b}}}{6:c}]", km.getSnippetBrackets());
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\"><mark class=\"class-5 level-1\">a<mark class=\"class-6 level-2\">b</mark></mark></mark><mark class=\"class-6 level-2\">c</mark></mark><span class=\"context-right\"></span>", km.getSnippetHTML());
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-7 level-0\"><mark class=\"class-5 level-1\">a<mark class=\"class-6 level-2\">b</mark></mark></mark><mark class=\"class-6 level-2\">c</mark></mark><span class=\"context-right\"></span>",
+                km.getSnippetHTML());
 
     };
 
+
     @Test
-    public void highlightMissingBug () throws IOException, QueryException  {
+    public void highlightMissingBug () throws IOException, QueryException {
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addString("UID", "1");
-        fd.addTV("base",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("base", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addString("UID", "2");
-        fd.addTV("base",
-                 "aba",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]");
+        fd.addTV("base", "aba", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]");
         ki.addDoc(fd);
 
         // Commit!
@@ -165,38 +163,33 @@
         fd = new FieldDocument();
         fd.addString("ID", "doc-3");
         fd.addString("UID", "3");
-        fd.addTV("base",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("base", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
-        
+
         // Commit!
         ki.commit();
         fd = new FieldDocument();
         fd.addString("ID", "doc-4");
         fd.addString("UID", "4");
-        fd.addTV("base",
-                 "aba",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]");
+        fd.addTV("base", "aba", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]");
         ki.addDoc(fd);
-        
+
         // Commit!
         ki.commit();
 
         QueryBuilder kq = new QueryBuilder("base");
-        SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a"))).or(kq._(2, kq.seg("s:b"))).toQuery();
+        SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a")))
+                .or(kq._(2, kq.seg("s:b"))).toQuery();
         Result kr = ki.search(q);
         assertEquals((long) 14, kr.getTotalResults());
         assertEquals("[{1:a}]bab", kr.getMatch(0).getSnippetBrackets());
         assertEquals("a[{2:b}]ab", kr.getMatch(1).getSnippetBrackets());
         assertEquals("ab[{1:a}]b", kr.getMatch(2).getSnippetBrackets());
         assertEquals("aba[{2:b}]", kr.getMatch(3).getSnippetBrackets());
-        
+
         assertEquals("[{1:a}]ba", kr.getMatch(4).getSnippetBrackets());
         assertEquals("a[{2:b}]a", kr.getMatch(5).getSnippetBrackets());
         assertEquals("ab[{1:a}]", kr.getMatch(6).getSnippetBrackets());
@@ -211,7 +204,8 @@
         assertEquals("ab[{1:a}]", kr.getMatch(13).getSnippetBrackets());
 
         kq = new QueryBuilder("base");
-        q = (SpanQuery) kq.or(kq._(1, kq.seg("i:a"))).or(kq._(2, kq.seg("i:c"))).toQuery();
+        q = (SpanQuery) kq.or(kq._(1, kq.seg("i:a")))
+                .or(kq._(2, kq.seg("i:c"))).toQuery();
         Krill qs = new Krill(q);
         qs.getMeta().getContext().left.setToken(true).setLength((short) 1);
         qs.getMeta().getContext().right.setToken(true).setLength((short) 1);
@@ -245,9 +239,9 @@
         assertEquals("[{1:a}] ...", kr.getMatch(8).getSnippetBrackets());
         assertEquals("... [{2:a}]", kr.getMatch(9).getSnippetBrackets());
 
-        q = (SpanQuery) kq._(
-            3, kq.or(kq._(1, kq.seg("i:a"))).or(kq._(2, kq.seg("i:c")))
-        ).toQuery();
+        q = (SpanQuery) kq._(3,
+                kq.or(kq._(1, kq.seg("i:a"))).or(kq._(2, kq.seg("i:c"))))
+                .toQuery();
         qs = new Krill(q);
         qs.getMeta().getContext().left.setToken(true).setLength((short) 0);
         qs.getMeta().getContext().right.setToken(true).setLength((short) 0);
@@ -266,71 +260,95 @@
         assertEquals("... [{3:{2:a}}]", kr.getMatch(9).getSnippetBrackets());
     };
 
+
     @Test
-    public void highlightGreaterClassBug () throws IOException, QueryException  {
+    public void highlightGreaterClassBug () throws IOException, QueryException {
 
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001", "00002"}) {
+        for (String i : new String[] { "00001", "00002" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
         // 15
-        String json = getString(getClass().getResource("/queries/bugs/greater_highlights_15.jsonld").getFile());
-	
+        String json = getString(getClass().getResource(
+                "/queries/bugs/greater_highlights_15.jsonld").getFile());
+
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
-        assertEquals(kr.getSerialQuery(),"{15: tokens:s:Alphabet}");
-        assertEquals(kr.getTotalResults(),7);
-        assertEquals(kr.getStartIndex(),0);
-        assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{15:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
-        assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-15 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
+        assertEquals(kr.getSerialQuery(), "{15: tokens:s:Alphabet}");
+        assertEquals(kr.getTotalResults(), 7);
+        assertEquals(kr.getStartIndex(), 0);
+        assertEquals(
+                kr.getMatch(0).getSnippetBrackets(),
+                "... 2. Herkunft Die aus dem proto-semitischen [{15:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
+        assertEquals(
+                kr.getMatch(0).getSnippetHTML(),
+                "<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-15 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
 
-        json = getString(getClass().getResource("/queries/bugs/greater_highlights_16.jsonld").getFile());
+        json = getString(getClass().getResource(
+                "/queries/bugs/greater_highlights_16.jsonld").getFile());
 
         // 16
         ks = new Krill(json);
         kr = ks.apply(ki);
-        assertEquals(kr.getSerialQuery(),"{16: tokens:s:Alphabet}");
-        assertEquals(kr.getTotalResults(),7);
-        assertEquals(kr.getStartIndex(),0);
-        assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{16:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
-        assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-16 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
+        assertEquals(kr.getSerialQuery(), "{16: tokens:s:Alphabet}");
+        assertEquals(kr.getTotalResults(), 7);
+        assertEquals(kr.getStartIndex(), 0);
+        assertEquals(
+                kr.getMatch(0).getSnippetBrackets(),
+                "... 2. Herkunft Die aus dem proto-semitischen [{16:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
+        assertEquals(
+                kr.getMatch(0).getSnippetHTML(),
+                "<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-16 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
 
         // 127
-        json = getString(getClass().getResource("/queries/bugs/greater_highlights_127.jsonld").getFile());
-	
+        json = getString(getClass().getResource(
+                "/queries/bugs/greater_highlights_127.jsonld").getFile());
+
         ks = new Krill(json);
         kr = ks.apply(ki);
-        assertEquals(kr.getSerialQuery(),"{127: tokens:s:Alphabet}");
-        assertEquals(kr.getTotalResults(),7);
-        assertEquals(kr.getStartIndex(),0);
-        assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{127:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
-        assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-127 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
+        assertEquals(kr.getSerialQuery(), "{127: tokens:s:Alphabet}");
+        assertEquals(kr.getTotalResults(), 7);
+        assertEquals(kr.getStartIndex(), 0);
+        assertEquals(
+                kr.getMatch(0).getSnippetBrackets(),
+                "... 2. Herkunft Die aus dem proto-semitischen [{127:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
+        assertEquals(
+                kr.getMatch(0).getSnippetHTML(),
+                "<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark><mark class=\"class-127 level-0\">Alphabet</mark></mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
 
         // 255
-        json = getString(getClass().getResource("/queries/bugs/greater_highlights_255.jsonld").getFile());
+        json = getString(getClass().getResource(
+                "/queries/bugs/greater_highlights_255.jsonld").getFile());
 
         ks = new Krill(json);
         kr = ks.apply(ki);
-        assertEquals(kr.getSerialQuery(),"{255: tokens:s:Alphabet}");
-        assertEquals(kr.getTotalResults(),7);
-        assertEquals(kr.getStartIndex(),0);
-        assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [Alphabet] stammende Urform des Buchstaben ist wahrscheinlich ...");
-        assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark>Alphabet</mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
+        assertEquals(kr.getSerialQuery(), "{255: tokens:s:Alphabet}");
+        assertEquals(kr.getTotalResults(), 7);
+        assertEquals(kr.getStartIndex(), 0);
+        assertEquals(
+                kr.getMatch(0).getSnippetBrackets(),
+                "... 2. Herkunft Die aus dem proto-semitischen [Alphabet] stammende Urform des Buchstaben ist wahrscheinlich ...");
+        assertEquals(
+                kr.getMatch(0).getSnippetHTML(),
+                "<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><mark>Alphabet</mark><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
 
         // 300
-        json = getString(getClass().getResource("/queries/bugs/greater_highlights_300.jsonld").getFile());
+        json = getString(getClass().getResource(
+                "/queries/bugs/greater_highlights_300.jsonld").getFile());
 
         ks = new Krill(json);
         kr = ks.apply(ki);
         assertEquals(709, kr.getError(0).getCode());
-        assertEquals("Valid class numbers exceeded", kr.getError(0).getMessage());
+        assertEquals("Valid class numbers exceeded", kr.getError(0)
+                .getMessage());
 
-        assertEquals(kr.getError(0).getMessage(),"Valid class numbers exceeded");
+        assertEquals(kr.getError(0).getMessage(),
+                "Valid class numbers exceeded");
     };
 };
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 2172288..fb61883 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
@@ -24,28 +24,31 @@
     private Result kr;
     private FieldDocument fd;
 
-    public TestAttributeIndex() throws IOException {
+
+    public TestAttributeIndex () throws IOException {
         ki = new KrillIndex();
     }
 
-    private FieldDocument createFieldDoc0() {
+
+    private FieldDocument createFieldDoc0 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-0");
         fd.addTV(
-				"base",
-				"bcbabd",
-				"[(0-1)s:a|_1#0-1|<>:s#0-5$<i>5<s>-1|<>:div#0-3$<i>3<s>1|<>:div#0-2$<i>2<s>2|@:class=header$<i>3<s>1|@:class=header$<i>2<s>2]"
-						+ "[(1-2)s:e|_2#1-2|<>:a#1-2$<i>2<s>1|@:class=header$<i>2<s>1]"
-						+ "[(2-3)s:e|_3#2-3|<>:div#2-3$<i>5<s>1|@:class=time$<i>5<s>1]"
-						+ "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=header$<i>5<s>1]"
-						+ "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|<>:a#4-5$<i>5<s>2|@:class=header$<i>5<s>2]"
-						+ "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>1|<>:div#5-6$<i>6<s>-1|@:class=header$<i>6<s>1]"
-						+ "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<i>7<s>1|@:class=header$<i>7<s>2]");
+                "base",
+                "bcbabd",
+                "[(0-1)s:a|_1#0-1|<>:s#0-5$<i>5<s>-1|<>:div#0-3$<i>3<s>1|<>:div#0-2$<i>2<s>2|@:class=header$<i>3<s>1|@:class=header$<i>2<s>2]"
+                        + "[(1-2)s:e|_2#1-2|<>:a#1-2$<i>2<s>1|@:class=header$<i>2<s>1]"
+                        + "[(2-3)s:e|_3#2-3|<>:div#2-3$<i>5<s>1|@:class=time$<i>5<s>1]"
+                        + "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=header$<i>5<s>1]"
+                        + "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|<>:a#4-5$<i>5<s>2|@:class=header$<i>5<s>2]"
+                        + "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>1|<>:div#5-6$<i>6<s>-1|@:class=header$<i>6<s>1]"
+                        + "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<i>7<s>1|@:class=header$<i>7<s>2]");
 
         return fd;
     }
 
-    private FieldDocument createFieldDoc1() {
+
+    private FieldDocument createFieldDoc1 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addTV(
@@ -55,37 +58,39 @@
                         + "[(1-2)s:c|_2#1-2|<>:div#1-2$<i>2<s>1|@:class=header$<i>2<s>1|@:class=title$<i>2<s>1]"
                         + "[(2-3)s:b|_3#2-3|<>:div#2-3$<i>5<s>1|@:class=book$<i>5<s>1]"
                         + "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=title$<i>5<s>1]"
-						+ "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|@:class=header$<i>5<s>1|@:class=book$<i>5<s>1|@:class=title$<i>5<s>1]"
+                        + "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|@:class=header$<i>5<s>1|@:class=book$<i>5<s>1|@:class=title$<i>5<s>1]"
                         + "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>-1|<>:div#5-6$<i>6<s>1|@:class=header$<i>6<s>1]"
                         + "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<i>7<s>1|@:class=title$<i>7<s>1]");
 
         return fd;
     }
 
-    private FieldDocument createFieldDoc2() {
+
+    private FieldDocument createFieldDoc2 () {
         fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addTV(
                 "base",
                 "bcbabd",
-				"[(0-1)s:b|_1#0-1|<>:s#0-5$<i>5<s>1|<>:div#0-3$<i>3<s>2|@:class=header$<i>3<s>2|@:class=book$<i>5<s>1|@:class=book$<i>3<s>2]"
-						+ "[(1-2)s:e|_2#1-2|<>:div#1-2$<i>2<s>1|<>:a#1-2$<i>2<s>2|@:class=book$<i>2<s>2|@:class=header$<i>2<s>1]"
-						+ "[(2-3)s:b|_3#2-3|<>:div#2-3$<i>5<s>1|<>:a#1-2$<i>2<s>2|@:class=header$<i>2<s>2|@:class=book$<i>5<s>1]"
-						+ "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=title$<i>5<s>1]"
-						+ "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|@:class=header$<i>5<s>1|@:class=book$<i>5<s>1]"
-						+ "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>-1|<>:div#5-6$<i>6<s>1|@:class=header$<i>6<s>1]"
-						+ "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<i>7<s>1|@:class=book$<i>7<s>2]");
+                "[(0-1)s:b|_1#0-1|<>:s#0-5$<i>5<s>1|<>:div#0-3$<i>3<s>2|@:class=header$<i>3<s>2|@:class=book$<i>5<s>1|@:class=book$<i>3<s>2]"
+                        + "[(1-2)s:e|_2#1-2|<>:div#1-2$<i>2<s>1|<>:a#1-2$<i>2<s>2|@:class=book$<i>2<s>2|@:class=header$<i>2<s>1]"
+                        + "[(2-3)s:b|_3#2-3|<>:div#2-3$<i>5<s>1|<>:a#1-2$<i>2<s>2|@:class=header$<i>2<s>2|@:class=book$<i>5<s>1]"
+                        + "[(3-4)s:a|_4#3-4|<>:div#3-5$<i>5<s>1|@:class=title$<i>5<s>1]"
+                        + "[(4-5)s:b|_5#4-5|<>:div#4-5$<i>5<s>1|@:class=header$<i>5<s>1|@:class=book$<i>5<s>1]"
+                        + "[(5-6)s:d|_6#5-6|<>:s#5-6$<i>6<s>-1|<>:div#5-6$<i>6<s>1|@:class=header$<i>6<s>1]"
+                        + "[(6-7)s:d|_7#6-7|<>:s#6-7$<i>7<s>2|<>:div#6-7$<i>7<s>1|@:class=header$<i>7<s>1|@:class=book$<i>7<s>2]");
 
         return fd;
     }
 
+
     /**
      * Test matching elementRef
      * 
      * @throws IOException
      * */
     @Test
-    public void testCase1() throws IOException {
+    public void testCase1 () throws IOException {
         ki.addDoc(createFieldDoc0());
         ki.commit();
 
@@ -109,13 +114,14 @@
         assertEquals(7, kr.getMatch(3).getEndPos());
     }
 
+
     /**
      * Test multiple attributes and negation
      * 
      * @throws IOException
      * */
     @Test
-    public void testCase2() throws IOException {
+    public void testCase2 () throws IOException {
         ki.addDoc(createFieldDoc1());
         ki.commit();
         // header and title
@@ -171,56 +177,58 @@
         assertEquals(6, kr.getMatch(0).getEndPos());
     }
 
-	/**
-	 * Element with only not attributes
-	 * 
-	 * @throws IOException
-	 * */
-	@Test
-	public void testcase9() throws IOException {
 
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
+    /**
+     * Element with only not attributes
+     * 
+     * @throws IOException
+     * */
+    @Test
+    public void testcase9 () throws IOException {
 
-		SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
-				new Term("base", "@:class=book")), true, true);
-		SpanQuery sq = new SpanWithAttributeQuery(new SpanElementQuery("base",
-				"div"), saq, true);
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
 
-		kr = ki.search(sq, (short) 10);
-		assertEquals(4, kr.getTotalResults());
-		assertEquals(1, kr.getMatch(0).getStartPos());
-		assertEquals(2, kr.getMatch(0).getEndPos());
-		assertEquals(3, kr.getMatch(1).getStartPos());
-		assertEquals(5, kr.getMatch(1).getEndPos());
-		assertEquals(5, kr.getMatch(2).getStartPos());
-		assertEquals(6, kr.getMatch(2).getEndPos());
-		assertEquals(6, kr.getMatch(3).getStartPos());
-		assertEquals(7, kr.getMatch(3).getEndPos());
+        SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
+                new Term("base", "@:class=book")), true, true);
+        SpanQuery sq = new SpanWithAttributeQuery(new SpanElementQuery("base",
+                "div"), saq, true);
 
-		List<SpanQuery> sql = new ArrayList<>();
-		sql.add(saq);
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=header")), true, true));
-		sq = new SpanWithAttributeQuery(new SpanElementQuery("base", "div"),
-				sql, true);
+        kr = ki.search(sq, (short) 10);
+        assertEquals(4, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+        assertEquals(5, kr.getMatch(2).getStartPos());
+        assertEquals(6, kr.getMatch(2).getEndPos());
+        assertEquals(6, kr.getMatch(3).getStartPos());
+        assertEquals(7, kr.getMatch(3).getEndPos());
 
-		kr = ki.search(sq, (short) 10);
-		assertEquals(1, kr.getTotalResults());
-		assertEquals(3, kr.getMatch(0).getStartPos());
-		assertEquals(5, kr.getMatch(0).getEndPos());
+        List<SpanQuery> sql = new ArrayList<>();
+        sql.add(saq);
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=header")), true, true));
+        sq = new SpanWithAttributeQuery(new SpanElementQuery("base", "div"),
+                sql, true);
 
-//		for (int i = 0; i < kr.getTotalResults(); i++) {
-//			System.out.println(kr.getMatch(i).getLocalDocID() + " "
-//					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
-//		}
-	}
+        kr = ki.search(sq, (short) 10);
+        assertEquals(1, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(0).getStartPos());
+        assertEquals(5, kr.getMatch(0).getEndPos());
+
+        //		for (int i = 0; i < kr.getTotalResults(); i++) {
+        //			System.out.println(kr.getMatch(i).getLocalDocID() + " "
+        //					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
+        //		}
+    }
+
 
     /**
      * same attribute types referring to different element types
      * */
     @Test
-    public void testCase3() throws IOException {
+    public void testCase3 () throws IOException {
         ki.addDoc(createFieldDoc2());
         ki.commit();
 
@@ -243,9 +251,10 @@
         assertEquals(7, kr.getMatch(2).getEndPos());
     }
 
+
     /** Test skipto doc for spanWithAttribute */
     @Test
-    public void testCase4() throws IOException {
+    public void testCase4 () throws IOException {
         ki.addDoc(createFieldDoc1());
         ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc2());
@@ -274,112 +283,116 @@
         assertEquals(5, kr.getMatch(0).getEndPos());
     }
 
+
     /**
-	 * Arbitrary elements with a specific attribute.
-	 * */
+     * Arbitrary elements with a specific attribute.
+     * */
     @Test
-    public void testCase5() throws IOException {
-		ki.addDoc(createFieldDoc2());
+    public void testCase5 () throws IOException {
+        ki.addDoc(createFieldDoc2());
         ki.commit();
-		SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
-				new Term("base", "@:class=book")), true);
+        SpanAttributeQuery saq = new SpanAttributeQuery(new SpanTermQuery(
+                new Term("base", "@:class=book")), true);
 
-		SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(saq, true);
-		kr = ki.search(swaq, (short) 10);
-		assertEquals(6, kr.getTotalResults());
+        SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(saq, true);
+        kr = ki.search(swaq, (short) 10);
+        assertEquals(6, kr.getTotalResults());
 
-		assertEquals(0, kr.getMatch(0).getStartPos());
-		assertEquals(3, kr.getMatch(0).getEndPos());
-		assertEquals(0, kr.getMatch(1).getStartPos());
-		assertEquals(5, kr.getMatch(1).getEndPos());
-		assertEquals(1, kr.getMatch(2).getStartPos());
-		assertEquals(2, kr.getMatch(2).getEndPos());
-		assertEquals(2, kr.getMatch(3).getStartPos());
-		assertEquals(5, kr.getMatch(3).getEndPos());
-		assertEquals(4, kr.getMatch(4).getStartPos());
-		assertEquals(5, kr.getMatch(4).getEndPos());
-		assertEquals(6, kr.getMatch(5).getStartPos());
-		assertEquals(7, kr.getMatch(5).getEndPos());
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(0, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+        assertEquals(1, kr.getMatch(2).getStartPos());
+        assertEquals(2, kr.getMatch(2).getEndPos());
+        assertEquals(2, kr.getMatch(3).getStartPos());
+        assertEquals(5, kr.getMatch(3).getEndPos());
+        assertEquals(4, kr.getMatch(4).getStartPos());
+        assertEquals(5, kr.getMatch(4).getEndPos());
+        assertEquals(6, kr.getMatch(5).getStartPos());
+        assertEquals(7, kr.getMatch(5).getEndPos());
     }
 
-	/**
-	 * Arbitrary elements with multiple attributes.
-	 * */
-	@Test
-	public void testCase6() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
 
-		List<SpanQuery> sql = new ArrayList<>();
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=header")), true));
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=book")), true));
+    /**
+     * Arbitrary elements with multiple attributes.
+     * */
+    @Test
+    public void testCase6 () throws IOException {
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
 
-		SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
-		kr = ki.search(swaq, (short) 10);
-		assertEquals(2, kr.getTotalResults());
+        List<SpanQuery> sql = new ArrayList<>();
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=header")), true));
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=book")), true));
 
-		assertEquals(0, kr.getMatch(0).getStartPos());
-		assertEquals(3, kr.getMatch(0).getEndPos());
-		assertEquals(4, kr.getMatch(1).getStartPos());
-		assertEquals(5, kr.getMatch(1).getEndPos());
+        SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
+        kr = ki.search(swaq, (short) 10);
+        assertEquals(2, kr.getTotalResults());
 
-//		for (int i = 0; i < kr.getTotalResults(); i++) {
-//			System.out.println(kr.getMatch(i).getLocalDocID() + " "
-//					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
-//		}
-	}
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(4, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
 
-	/**
-	 * Arbitrary elements with an attribute and a not attribute.
-	 * */
-	@Test
-	public void testCase7() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
+        //		for (int i = 0; i < kr.getTotalResults(); i++) {
+        //			System.out.println(kr.getMatch(i).getLocalDocID() + " "
+        //					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
+        //		}
+    }
 
-		List<SpanQuery> sql = new ArrayList<>();
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=header")), true, true));
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=book")), true));
 
-		SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
-		kr = ki.search(swaq, (short) 10);
-		assertEquals(4, kr.getTotalResults());
+    /**
+     * Arbitrary elements with an attribute and a not attribute.
+     * */
+    @Test
+    public void testCase7 () throws IOException {
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
 
-		assertEquals(0, kr.getMatch(0).getStartPos());
-		assertEquals(5, kr.getMatch(0).getEndPos());
-		assertEquals(1, kr.getMatch(1).getStartPos());
-		assertEquals(2, kr.getMatch(1).getEndPos());
-		assertEquals(2, kr.getMatch(2).getStartPos());
-		assertEquals(5, kr.getMatch(2).getEndPos());
-		assertEquals(6, kr.getMatch(3).getStartPos());
-		assertEquals(7, kr.getMatch(3).getEndPos());
+        List<SpanQuery> sql = new ArrayList<>();
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=header")), true, true));
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=book")), true));
 
-//		for (int i = 0; i < kr.getTotalResults(); i++) {
-//			System.out.println(kr.getMatch(i).getLocalDocID() + " "
-//					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
-//		}
-	}
+        SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
+        kr = ki.search(swaq, (short) 10);
+        assertEquals(4, kr.getTotalResults());
 
-	/**
-	 * Arbitrary elements with only not attributes.
-	 * */
-	@Test(expected = IllegalArgumentException.class)
-	public void testCase8() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(5, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(2, kr.getMatch(1).getEndPos());
+        assertEquals(2, kr.getMatch(2).getStartPos());
+        assertEquals(5, kr.getMatch(2).getEndPos());
+        assertEquals(6, kr.getMatch(3).getStartPos());
+        assertEquals(7, kr.getMatch(3).getEndPos());
 
-		List<SpanQuery> sql = new ArrayList<>();
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=header")), true, true));
-		sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
-				"@:class=book")), true, true));
+        //		for (int i = 0; i < kr.getTotalResults(); i++) {
+        //			System.out.println(kr.getMatch(i).getLocalDocID() + " "
+        //					+ kr.getMatch(i).startPos + " " + kr.getMatch(i).endPos);
+        //		}
+    }
 
-		SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
-		kr = ki.search(swaq, (short) 10);
-	}
+
+    /**
+     * Arbitrary elements with only not attributes.
+     * */
+    @Test(expected = IllegalArgumentException.class)
+    public void testCase8 () throws IOException {
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        List<SpanQuery> sql = new ArrayList<>();
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=header")), true, true));
+        sql.add(new SpanAttributeQuery(new SpanTermQuery(new Term("base",
+                "@:class=book")), true, true));
+
+        SpanWithAttributeQuery swaq = new SpanWithAttributeQuery(sql, true);
+        kr = ki.search(swaq, (short) 10);
+    }
 
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
index 274cc25..42b56b6 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
@@ -34,257 +34,266 @@
 
     @Test
     public void indexExample1 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// 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]");
-	ki.addDoc(fd);
+        // 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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
-	Result kr;
+        SpanQuery sq;
+        Result kr;
 
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:b")),
-            new SpanTermQuery(new Term("base", "s:a"))
-        );
-	kr = ki.search(sq, (short) 10);
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")),
+                new SpanTermQuery(new Term("base", "s:a")));
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... bcabca[ba]c", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\">" +
-			"</span>bcabca</span><mark>ba</mark><span class=\"context-right" +
-			"\">c</span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "... bcabca[ba]c", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\"><span class=\"more\">"
+                        + "</span>bcabca</span><mark>ba</mark><span class=\"context-right"
+                        + "\">c</span>", kr.getMatch(0).getSnippetHTML());
 
-	sq = new SpanTermQuery(new Term("base", "s:b"));
-	kr = ki.search(sq, (short) 10);
+        sq = new SpanTermQuery(new Term("base", "s:b"));
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.getMatch(0)
+                .getSnippetBrackets());
 
 
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\">a</span><mark>" +
-			"b</mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", 
-			kr.getMatch(0).getSnippetHTML());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\">a</span><mark>"
+                        + "b</mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[b]cabac", kr.getMatch(1).getSnippetBrackets());
-	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	assertEquals("SnippetBrackets (2)", "... bcabca[b]ac", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abca[b]cabac", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+        assertEquals("SnippetBrackets (2)", "... bcabca[b]ac", kr.getMatch(2)
+                .getSnippetBrackets());
 
-	sq = new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")));
-	kr = ki.search(sq, (short) 10);
+        sq = new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")));
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("snippetBrackets (0)", "a[{1:b}]cabcab ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("snippetHTML (0)", "<span class=\"context-left\">a</span><mark>" +
-			"<mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span " +
-			"class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("snippetBrackets (0)", "a[{1:b}]cabcab ...", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "snippetHTML (0)",
+                "<span class=\"context-left\">a</span><mark>"
+                        + "<mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span "
+                        + "class=\"more\"></span></span>", kr.getMatch(0)
+                        .getSnippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("snippetBrackets (1)", "abca[{1:b}]cabac", kr.getMatch(1).getSnippetBrackets());
-	
-	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	assertEquals("snippetBrackets (2)", "... bcabca[{1:b}]ac", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("snippetBrackets (1)", "abca[{1:b}]cabac", kr.getMatch(1)
+                .getSnippetBrackets());
+
+        assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+        assertEquals("snippetBrackets (2)", "... bcabca[{1:b}]ac",
+                kr.getMatch(2).getSnippetBrackets());
 
 
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 1)
-        );
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        (byte) 1));
 
-	kr = ki.search(sq, (short) 10);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "[a{1:b}]cabcab ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "[a{1:b}]cabcab ...", kr
+                .getMatch(0).getSnippetBrackets());
 
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><mark>a<mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\"></span><mark>a<mark class=\"class-1 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abc[a{1:b}]cabac", kr.getMatch(1).getSnippetBrackets());
-	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	assertEquals("SnippetBrackets (2)", "abcabc[a{1:b}]ac", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abc[a{1:b}]cabac", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+        assertEquals("SnippetBrackets (2)", "abcabc[a{1:b}]ac", kr.getMatch(2)
+                .getSnippetBrackets());
 
 
-	// abcabcabac
-	sq = new SpanNextQuery(
-	    new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
-            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-        );
+        // abcabcabac
+        sq = new SpanNextQuery(new SpanClassQuery(new SpanTermQuery(new Term(
+                "base", "s:a")), (byte) 2), new SpanClassQuery(
+                new SpanTermQuery(new Term("base", "s:b")), (byte) 3));
 
-	kr = ki.search(sq, (short) 10);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "[{2:a}{3:b}]cabcab ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abc[{2:a}{3:b}]cabac", kr.getMatch(1).getSnippetBrackets());
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "[{2:a}{3:b}]cabcab ...", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abc[{2:a}{3:b}]cabac", kr
+                .getMatch(1).getSnippetBrackets());
 
-	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	assertEquals("SnippetBrackets (2)", "abcabc[{2:a}{3:b}]ac", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+        assertEquals("SnippetBrackets (2)", "abcabc[{2:a}{3:b}]ac", kr
+                .getMatch(2).getSnippetBrackets());
 
-	// abcabcabac
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-            new SpanClassQuery(
-	        new SpanNextQuery(
-		    new SpanTermQuery(new Term("base", "s:b")),
-	    	    new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")))
-		), (byte) 2
-	));
+        // abcabcabac
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanClassQuery(new SpanNextQuery(new SpanTermQuery(
+                        new Term("base", "s:b")), new SpanClassQuery(
+                        new SpanTermQuery(new Term("base", "s:a")))), (byte) 2));
 
-	kr = ki.search(sq, (short) 10);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "abcabc[a{2:b{1:a}}]c", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\">abcabc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "abcabc[a{2:b{1:a}}]c", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\">abcabc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	// Offset tokens
-	kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>", kr.getMatch(0).getSnippetHTML());
+        // Offset tokens
+        kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\"><span class=\"more\"></span>bc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	// Offset Characters
-	kr = ki.search(sq, 0, (short) 10, false, (short) 2, false, (short) 2);
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>", kr.getMatch(0).getSnippetHTML());
+        // Offset Characters
+        kr = ki.search(sq, 0, (short) 10, false, (short) 2, false, (short) 2);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\"><span class=\"more\"></span>bc</span><mark>a<mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>",
+                kr.getMatch(0).getSnippetHTML());
 
 
-	// System.err.println(kr.toJSON());
+        // System.err.println(kr.toJSON());
 
-	sq = new SpanNextQuery(
-	    new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 1),
-            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:c")), (byte) 2)
-        );
+        sq = new SpanNextQuery(new SpanClassQuery(new SpanTermQuery(new Term(
+                "base", "s:b")), (byte) 1), new SpanClassQuery(
+                new SpanTermQuery(new Term("base", "s:c")), (byte) 2));
 
-	kr = ki.search(sq, (short) 10);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("Document count", 1, ki.numberOf("base", "documents"));
-	assertEquals("Token count", 10, ki.numberOf("base", "t"));
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+
+        assertEquals("Document count", 1, ki.numberOf("base", "documents"));
+        assertEquals("Token count", 10, ki.numberOf("base", "t"));
 
 
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-            new SpanClassQuery(
-	      new SpanNextQuery(
-	        new SpanTermQuery(new Term("base", "s:b")),
-	        new SpanTermQuery(new Term("base", "s:c"))
-	      )
-	   )
-        );
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanClassQuery(new SpanNextQuery(new SpanTermQuery(
+                        new Term("base", "s:b")), new SpanTermQuery(new Term(
+                        "base", "s:c")))));
 
-	kr = ki.search(sq, (short) 2);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        kr = ki.search(sq, (short) 2);
 
-	assertEquals(1, ki.numberOf("base", "documents"));
-	assertEquals(10, ki.numberOf("base", "t"));
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+
+        assertEquals(1, ki.numberOf("base", "documents"));
+        assertEquals(10, ki.numberOf("base", "t"));
     };
 
 
     @Test
     public void indexExample2 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// 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]");
-	ki.addDoc(fd);
+        // 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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
-	Result kr;
+        SpanQuery sq;
+        Result kr;
 
-	/*
-	sq = new SpanNextQuery(
-	       new SpanTermQuery(new Term("base", "s:c")),
- 	       new SpanElementQuery("base", "x")
-	);
-	
-	kr = ki.search(sq, (short) 10);
-	assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
-	System.err.println();
-	*/
-
-	/*
-	sq = new SpanNextQuery(
-	       new SpanElementQuery("base", "x"),
-	       new SpanTermQuery(new Term("base", "s:b"))
-	);
-	
-	kr = ki.search(sq, (short) 10);
-	assertEquals("abc[abcab}ac]", kr.getMatch(0).getSnippetBrackets());
-	System.err.println();
-
-	*/
-
-	/*
-	sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "x"),
-            new SpanClassQuery(
-              new SpanTermQuery(new Term("base", "s:a"))
-            )
+        /*
+        sq = new SpanNextQuery(
+               new SpanTermQuery(new Term("base", "s:c")),
+               new SpanElementQuery("base", "x")
         );
+        
+        kr = ki.search(sq, (short) 10);
+        assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
+        System.err.println();
+        */
 
-	       //	       new SpanTermQuery(new Term("base", "s:a")),
-	    //            new SpanClassQuery(
-	    //            )
-	    //        );
+        /*
+        sq = new SpanNextQuery(
+               new SpanElementQuery("base", "x"),
+               new SpanTermQuery(new Term("base", "s:b"))
+        );
+        
+        kr = ki.search(sq, (short) 10);
+        assertEquals("abc[abcab}ac]", kr.getMatch(0).getSnippetBrackets());
+        System.err.println();
 
-	*/
+        */
+
+        /*
+        sq = new SpanWithinQuery(
+                new SpanElementQuery("base", "x"),
+                new SpanClassQuery(
+                  new SpanTermQuery(new Term("base", "s:a"))
+                )
+            );
+
+               //	       new SpanTermQuery(new Term("base", "s:a")),
+            //            new SpanClassQuery(
+            //            )
+            //        );
+
+        */
 
     }
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
index d97e44a..6309d59 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
@@ -19,200 +19,194 @@
 public class TestDistanceExclusionIndex {
 
     private KrillIndex ki;
-	private Result kr;
+    private Result kr;
 
-	/** Ordered, unordered
-	 * */
-	@Test
-    public void testCase1() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+
+    /**
+     * Ordered, unordered
+     * */
+    @Test
+    public void testCase1 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         SpanQuery sq;
         //ordered distance 0 to 1
-        sq = createQuery("s:c","s:e",0,1,true);                
-        kr = ki.search(sq, (short) 10);        
-        assertEquals((long) 3, kr.getTotalResults());	    
-	    assertEquals(2, kr.getMatch(0).getStartPos());
-	    assertEquals(3, kr.getMatch(0).getEndPos());
-	    assertEquals(3, kr.getMatch(1).getStartPos());
-	    assertEquals(4, kr.getMatch(1).getEndPos());
-	    assertEquals(5, kr.getMatch(2).getStartPos());
-	    assertEquals(6, kr.getMatch(2).getEndPos());
-        
+        sq = createQuery("s:c", "s:e", 0, 1, true);
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(2, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getStartPos());
+        assertEquals(4, kr.getMatch(1).getEndPos());
+        assertEquals(5, kr.getMatch(2).getStartPos());
+        assertEquals(6, kr.getMatch(2).getEndPos());
+
         // Unordered
-        sq = createQuery("s:c","s:e",0,1,false);                
+        sq = createQuery("s:c", "s:e", 0, 1, false);
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 2, kr.getTotalResults());
     }
-	
-	/** Multiple docs, unordered
-	 * 	No more secondSpans
-	 * */
-	@Test
-    public void testCase2() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+
+
+    /**
+     * Multiple docs, unordered
+     * No more secondSpans
+     * */
+    @Test
+    public void testCase2 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc1());
         ki.commit();
         SpanQuery sq;
         // ---- Distance 0 to 1
-        sq = createQuery("s:c","s:e",0,1,false);                
-        kr = ki.search(sq, (short) 10);        
-        assertEquals((long) 5, kr.getTotalResults());	    
-	    assertEquals(1, kr.getMatch(3).getLocalDocID());
-	}
-	
-	/** Secondspans' document number is bigger than firstspans' 
-	 * 	Actual distance is smaller than min distance.
-	 * */
-	@Test
-    public void testCase3() throws IOException{
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());
-		ki.addDoc(createFieldDoc0());        
-        ki.commit();
-        
-        SpanQuery sq;
-        // Unordered
-        sq = createQuery("s:c","s:e",2,2,false);                
+        sq = createQuery("s:c", "s:e", 0, 1, false);
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 5, kr.getTotalResults());
-	}
-	
-	/** Unordered: firstspan in on the right side of the secondspan, 
-	 * 	but within max distance.
-	 * */
-	@Test
-    public void testCase4() throws IOException{
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc2());		        
+        assertEquals(1, kr.getMatch(3).getLocalDocID());
+    }
+
+
+    /**
+     * Secondspans' document number is bigger than firstspans'
+     * Actual distance is smaller than min distance.
+     * */
+    @Test
+    public void testCase3 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-        
+
         SpanQuery sq;
         // Unordered
-        sq = createQuery("s:b","s:c",2,2,false);                
+        sq = createQuery("s:c", "s:e", 2, 2, false);
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 5, kr.getTotalResults());
+    }
+
+
+    /**
+     * Unordered: firstspan in on the right side of the secondspan,
+     * but within max distance.
+     * */
+    @Test
+    public void testCase4 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        SpanQuery sq;
+        // Unordered
+        sq = createQuery("s:b", "s:c", 2, 2, false);
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 1, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).getStartPos());
-	    assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
     }
-	
-	/**	Element queries
-	 * */
-	@Test
-    public void testCase5() throws IOException{
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());		        
+
+
+    /**
+     * Element queries
+     * */
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-        
-        SpanDistanceQuery sq;        
-        sq = new SpanDistanceQuery(
-        		new SpanElementQuery("base", "x"),
-        		new SpanElementQuery("base", "y"),
-        		new DistanceConstraint(0, 1, false, true),
-        		true);        
-        
+
+        SpanDistanceQuery sq;
+        sq = new SpanDistanceQuery(new SpanElementQuery("base", "x"),
+                new SpanElementQuery("base", "y"), new DistanceConstraint(0, 1,
+                        false, true), true);
+
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 1, kr.getTotalResults());
         assertEquals(9, kr.getMatch(0).getStartPos());
-	    assertEquals(10, kr.getMatch(0).getEndPos());
+        assertEquals(10, kr.getMatch(0).getEndPos());
     }
-	
-	// Add skipTo test	
-	@Test
-	public void testCase6() throws IOException{
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());
-		ki.addDoc(createFieldDoc2());
+
+
+    // Add skipTo test	
+    @Test
+    public void testCase6 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
         ki.commit();
-        
+
         SpanQuery sq;
         //ordered distance 0 to 1
-        sq = createQuery("s:d","s:b",0,1,true);
+        sq = createQuery("s:d", "s:b", 0, 1, true);
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 4, kr.getTotalResults());
-        
-		SpanTermQuery stq = new SpanTermQuery(new Term("base", "s:c"));
-		kr = ki.search(stq, (short) 10);
-		assertEquals((long) 6, kr.getTotalResults());
-		
-		SpanNextQuery snq = new SpanNextQuery(stq,sq);		
+
+        SpanTermQuery stq = new SpanTermQuery(new Term("base", "s:c"));
+        kr = ki.search(stq, (short) 10);
+        assertEquals((long) 6, kr.getTotalResults());
+
+        SpanNextQuery snq = new SpanNextQuery(stq, sq);
         kr = ki.search(snq, (short) 10);
         assertEquals((long) 2, kr.getTotalResults());
         assertEquals(3, kr.getMatch(0).getStartPos());
-	    assertEquals(5, kr.getMatch(0).getEndPos());
-	    assertEquals(8, kr.getMatch(1).getStartPos());
-	    assertEquals(10, kr.getMatch(1).getEndPos());
-	    
+        assertEquals(5, kr.getMatch(0).getEndPos());
+        assertEquals(8, kr.getMatch(1).getStartPos());
+        assertEquals(10, kr.getMatch(1).getEndPos());
+
         /*System.out.print(kr.getTotalResults()+"\n");
-		for (int i=0; i< kr.getTotalResults(); i++){
-			System.out.println(
-				kr.getMatch(i).getLocalDocID()+" "+
-				kr.getMatch(i).startPos + " " +
-				kr.getMatch(i).endPos
-		    );
-		}*/
-	}
-	
-    private SpanQuery createQuery(String x, String y, int min, int max, boolean isOrdered){
-    	SpanDistanceQuery sq = new SpanDistanceQuery(
-        		new SpanTermQuery(new Term("base",x)),
-        		new SpanTermQuery(new Term("base",y)),
-        		new DistanceConstraint(min, max, isOrdered,true),
-        		true
-        );    	
-    	return sq;
+        for (int i=0; i< kr.getTotalResults(); i++){
+        	System.out.println(
+        		kr.getMatch(i).getLocalDocID()+" "+
+        		kr.getMatch(i).startPos + " " +
+        		kr.getMatch(i).endPos
+            );
+        }*/
     }
-    
-    private FieldDocument createFieldDoc0(){
-    	FieldDocument fd = new FieldDocument();
+
+
+    private SpanQuery createQuery (String x, String y, int min, int max,
+            boolean isOrdered) {
+        SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(
+                new Term("base", x)), new SpanTermQuery(new Term("base", y)),
+                new DistanceConstraint(min, max, isOrdered, true), true);
+        return sq;
+    }
+
+
+    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:e|_8#7-8|<>:x#7-9$<i>9]" + 
-            "[(8-9)s:e|_9#8-9]" + 
-            "[(9-10)s:d|_10#9-10|<>:x#9-10$<i>10]");
+        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]"
+                + "[(9-10)s:d|_10#9-10|<>:x#9-10$<i>10]");
         return fd;
     }
-    
-    private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
+
+
+    private FieldDocument createFieldDoc1 () {
+        FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        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#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]");
         return fd;
-	}
-    
-    private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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:c|_3#2-3]" +
-            "[(3-4)s:c|_4#3-4]" + 
-            "[(4-5)s:b|_5#4-5]" +             
-            "[(5-6)s:d|_6#5-6]" + 
-            "[(6-7)s:b|_7#6-7]" +
-            "[(7-8)s:d|_8#7-8]" + 
-            "[(8-9)s:c|_9#8-9]" + 
-            "[(9-10)s:d|_10#9-10]");
+        fd.addTV("base", "text", "[(0-1)s:b|_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:b|_5#4-5]" + "[(5-6)s:d|_6#5-6]"
+                + "[(6-7)s:b|_7#6-7]" + "[(7-8)s:d|_8#7-8]"
+                + "[(8-9)s:c|_9#8-9]" + "[(9-10)s:d|_10#9-10]");
         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 df9b00e..70900f2 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
@@ -21,303 +21,299 @@
 @RunWith(JUnit4.class)
 public class TestDistanceIndex {
     Result kr;
-    KrillIndex ki;   
- 
-    private FieldDocument createFieldDoc0() {
-    	FieldDocument fd = new FieldDocument();
+    KrillIndex ki;
+
+
+    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#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]");
         return fd;
-	}
-    
-    private FieldDocument createFieldDoc1(){
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
     }
-    
-    private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
+
+
+    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#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]");
         return fd;
-	}
-    
-    private SpanQuery createQuery(String x, String y, int min, int max, boolean isOrdered){    	
-    	SpanQuery sq = new SpanDistanceQuery(
-        		new SpanTermQuery(new Term("base",x)),
-        		new SpanTermQuery(new Term("base",y)),
-        		new DistanceConstraint(min, max, isOrdered, false),
-        		true
-        );
-    	return sq;
     }
-    
-    private SpanQuery createElementQuery(String x, String y, int min, int max, boolean isOrdered){
-    	SpanQuery sq = new SpanDistanceQuery(
-        		new SpanElementQuery("base",x),
-        		new SpanElementQuery("base",y),
-        		new DistanceConstraint(min, max, isOrdered, false),
-        		true
-        );
-    	return sq;
+
+
+    private SpanQuery createQuery (String x, String y, int min, int max,
+            boolean isOrdered) {
+        SpanQuery sq = new SpanDistanceQuery(new SpanTermQuery(new Term("base",
+                x)), new SpanTermQuery(new Term("base", y)),
+                new DistanceConstraint(min, max, isOrdered, false), true);
+        return sq;
     }
-    
-    /**	- Intersection 
-     * 	- Multiple occurrences in the same doc  
-     *  - hasMoreFirstSpans = false for the current secondspan  
+
+
+    private SpanQuery createElementQuery (String x, String y, int min, int max,
+            boolean isOrdered) {
+        SpanQuery sq = new SpanDistanceQuery(new SpanElementQuery("base", x),
+                new SpanElementQuery("base", y), new DistanceConstraint(min,
+                        max, isOrdered, false), true);
+        return sq;
+    }
+
+
+    /**
+     * - Intersection
+     * - Multiple occurrences in the same doc
+     * - hasMoreFirstSpans = false for the current secondspan
      * */
     @Test
-    public void testCase1() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    public void testCase1 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         SpanQuery sq;
         // ---- Distance 0 to 1
-        sq = createQuery("s:b","s:c",0,1,true);                
+        sq = createQuery("s:b", "s:c", 0, 1, true);
         kr = ki.search(sq, (short) 10);
-//        System.out.println(sq);
+        //        System.out.println(sq);
         assertEquals(kr.getTotalResults(), 2);
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(1, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
         assertEquals(3, kr.getMatch(1).endPos);
-        
+
         // ---- Distance 2 to 2
-        sq = createQuery("s:b","s:c",2,2,true);                
+        sq = createQuery("s:b", "s:c", 2, 2, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 2);
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(3, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
         assertEquals(4, kr.getMatch(1).endPos);
-        
+
         // ---- Distance 2 to 3
-        sq = createQuery("s:b","s:c",2,3,true);                
+        sq = createQuery("s:b", "s:c", 2, 3, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 3);
-        
+
         ki.close();
     }
-    
-    /** - Check candidate list: 
-     * 	- CandidateList should not contain firstspans that are too far from 
-     * 	  the current secondspan
-     * 	- Add new candidates  
-     * */
-    @Test
-    public void testCase2() throws IOException{
-    	ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.commit();    
-	    
-	    // ---- Distance 1 to 3
-	    // Candidate list for the current secondspan, is empty
-	    SpanQuery sq = createQuery("s:c","s:d",1,3,true);                
-	    kr = ki.search(sq, (short) 10);
-	        	    
-	    assertEquals((long) 4, kr.getTotalResults());
-	    assertEquals(2, kr.getMatch(0).startPos);
-	    assertEquals(5, kr.getMatch(0).endPos);
-	    assertEquals(3, kr.getMatch(2).startPos);
-	    assertEquals(7, kr.getMatch(2).endPos);
-	    
-	    ki.addDoc(createFieldDoc0());
-	    ki.commit();
 
-	    // ---- Distance 3 to 3
-	    // Candidate list is empty, but there are secondspans in the other doc
-	    sq = createQuery("s:c","s:d",3,3,true);                
-	    kr = ki.search(sq, (short) 10);
-	    assertEquals((long) 2, kr.getTotalResults());
-	    
-	    ki.close();
-    }
-        
-    /** - Ensure the same document
-     *  - Multiple matches in multiple documents and atomic indices
+
+    /**
+     * - Check candidate list:
+     * - CandidateList should not contain firstspans that are too far
+     * from
+     * the current secondspan
+     * - Add new candidates
      * */
     @Test
-    public void testCase3() throws IOException{
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());
+    public void testCase2 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        // ---- Distance 1 to 3
+        // Candidate list for the current secondspan, is empty
+        SpanQuery sq = createQuery("s:c", "s:d", 1, 3, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals((long) 4, kr.getTotalResults());
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(5, kr.getMatch(0).endPos);
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(7, kr.getMatch(2).endPos);
+
+        ki.addDoc(createFieldDoc0());
+        ki.commit();
+
+        // ---- Distance 3 to 3
+        // Candidate list is empty, but there are secondspans in the other doc
+        sq = createQuery("s:c", "s:d", 3, 3, true);
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 2, kr.getTotalResults());
+
+        ki.close();
+    }
+
+
+    /**
+     * - Ensure the same document
+     * - Multiple matches in multiple documents and atomic indices
+     * */
+    @Test
+    public void testCase3 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         ki.addDoc(createFieldDoc2());
         ki.addDoc(createFieldDoc1());
         ki.commit();
-        
+
         SpanQuery sq;
-        sq = createQuery("s:c","s:d",3,3,true);    
+        sq = createQuery("s:c", "s:d", 3, 3, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 2);
     }
-    
-    /** - Firstspan.next() is in the other doc, but there is
-     *    still a secondspans in the same doc
-     *  - hasMoreFirstSpan and secondspans.next() are true,
-     *    but ensureSameDoc() = false 
-     * */ 
+
+
+    /**
+     * - Firstspan.next() is in the other doc, but there is
+     * still a secondspans in the same doc
+     * - hasMoreFirstSpan and secondspans.next() are true,
+     * but ensureSameDoc() = false
+     * */
     @Test
-    public void testCase4() throws IOException{
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());
+    public void testCase4 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         ki.addDoc(createFieldDoc2());
         ki.addDoc(createFieldDoc1());
         ki.commit();
-               
+
         // ---- Distance 1 to 2
-        SpanQuery sq = createQuery("s:b","s:c",1,2,true);                
+        SpanQuery sq = createQuery("s:b", "s:c", 1, 2, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getMatch(0).startPos);
-	    assertEquals(3, kr.getMatch(0).endPos);
-	    assertEquals(1, kr.getMatch(1).startPos);
-	    assertEquals(3, kr.getMatch(1).endPos);
-	    assertEquals(1, kr.getMatch(2).startPos);
-	    assertEquals(4, kr.getMatch(2).endPos);
-	    ki.close();      
+        assertEquals(3, kr.getMatch(0).endPos);
+        assertEquals(1, kr.getMatch(1).startPos);
+        assertEquals(3, kr.getMatch(1).endPos);
+        assertEquals(1, kr.getMatch(2).startPos);
+        assertEquals(4, kr.getMatch(2).endPos);
+        ki.close();
     }
-    
-    /** ElementQueries */    
+
+
+    /** ElementQueries */
     @Test
-    public void testCase5() throws IOException{    	
-    	ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.commit();    
-	    
-	    // Intersection ---- Distance 0:0
-	    SpanQuery sq = createElementQuery("x","y",0,0,true);                
-	    kr = ki.search(sq, (short) 10);
-    	
-	    assertEquals(kr.getTotalResults(), 4);
-	    assertEquals(2, kr.getMatch(0).startPos);
-	    assertEquals(7, kr.getMatch(0).endPos);
-	    assertEquals(3, kr.getMatch(1).startPos);
-	    assertEquals(7, kr.getMatch(1).endPos);
-	    assertEquals(3, kr.getMatch(2).startPos);
-	    assertEquals(8, kr.getMatch(2).endPos);
-    	
-	    // Next to ---- Distance 1:1
-	    sq = createElementQuery("y","x",1,1,true);                
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 1);
-	    assertEquals(5, kr.getMatch(0).startPos);
-	    assertEquals(10, kr.getMatch(0).endPos);
-	    
-	    // ---- Distance 1:2
-	    sq = createElementQuery("y","x",1,2,true);                
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 2);	    
-	    assertEquals(4, kr.getMatch(0).startPos);
-	    assertEquals(9, kr.getMatch(0).endPos);
-	    assertEquals(5, kr.getMatch(1).startPos);
-	    assertEquals(10, kr.getMatch(1).endPos);
-	    
-	    // The same element type ---- Distance 1:2
-	    sq = createElementQuery("x","x",1,2,true);
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 2);
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        // Intersection ---- Distance 0:0
+        SpanQuery sq = createElementQuery("x", "y", 0, 0, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 4);
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(7, kr.getMatch(0).endPos);
+        assertEquals(3, kr.getMatch(1).startPos);
+        assertEquals(7, kr.getMatch(1).endPos);
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(8, kr.getMatch(2).endPos);
+
+        // Next to ---- Distance 1:1
+        sq = createElementQuery("y", "x", 1, 1, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(5, kr.getMatch(0).startPos);
+        assertEquals(10, kr.getMatch(0).endPos);
+
+        // ---- Distance 1:2
+        sq = createElementQuery("y", "x", 1, 2, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(4, kr.getMatch(0).startPos);
+        assertEquals(9, kr.getMatch(0).endPos);
+        assertEquals(5, kr.getMatch(1).startPos);
+        assertEquals(10, kr.getMatch(1).endPos);
+
+        // The same element type ---- Distance 1:2
+        sq = createElementQuery("x", "x", 1, 2, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 2);
     }
-    
-    /** Skip to */    
+
+
+    /** Skip to */
     @Test
-    public void testCase6() throws IOException{    	
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc2());
-	    ki.addDoc(createFieldDoc1());
-	    ki.commit();
-	    	    
-	    SpanQuery firstClause = createQuery("s:d", "s:e", 3, 4,true);
-	    kr = ki.search(firstClause, (short) 10); 
-	    
-	    assertEquals(kr.getTotalResults(), 3);
-	    assertEquals(0, kr.getMatch(0).getLocalDocID());
-	    assertEquals(2, kr.getMatch(0).startPos);
-	    assertEquals(6, kr.getMatch(0).endPos);
-	    assertEquals(1, kr.getMatch(1).getLocalDocID());
-	    assertEquals(4, kr.getMatch(1).startPos);
-	    assertEquals(8, kr.getMatch(1).endPos);
-	    assertEquals(4, kr.getMatch(2).startPos);
-	    assertEquals(9, kr.getMatch(2).endPos);	    
-	    
-		// The secondspans is skipped to doc# of the current firstspans
-		SpanQuery sq = new SpanSegmentQuery(
-	    		createQuery("s:d","s:e",3,4,true),
-	    		createElementQuery("y","x",1,2,true)
-		);	    
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 1);
-	    assertEquals(4, kr.getMatch(0).startPos);
-	    assertEquals(9, kr.getMatch(0).endPos);	    
+    public void testCase6 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc2());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanQuery firstClause = createQuery("s:d", "s:e", 3, 4, true);
+        kr = ki.search(firstClause, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 3);
+        assertEquals(0, kr.getMatch(0).getLocalDocID());
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(6, kr.getMatch(0).endPos);
+        assertEquals(1, kr.getMatch(1).getLocalDocID());
+        assertEquals(4, kr.getMatch(1).startPos);
+        assertEquals(8, kr.getMatch(1).endPos);
+        assertEquals(4, kr.getMatch(2).startPos);
+        assertEquals(9, kr.getMatch(2).endPos);
+
+        // The secondspans is skipped to doc# of the current firstspans
+        SpanQuery sq = new SpanSegmentQuery(createQuery("s:d", "s:e", 3, 4,
+                true), createElementQuery("y", "x", 1, 2, true));
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(4, kr.getMatch(0).startPos);
+        assertEquals(9, kr.getMatch(0).endPos);
     }
-    
+
+
     /** Same tokens */
     @Test
-    public void testCase7() throws IOException{    	
-    	ki = new KrillIndex();    	
-	    ki.addDoc(createFieldDoc1());
-	    ki.commit();
-	    	    
-	    SpanQuery sq = createQuery("s:c", "s:c", 1, 2,true);
-	    kr = ki.search(sq, (short) 10); 
-    
-	    assertEquals(kr.getTotalResults(), 3);
+    public void testCase7 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanQuery sq = createQuery("s:c", "s:c", 1, 2, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getMatch(0).startPos);
-	    assertEquals(3, kr.getMatch(0).endPos);
-	    assertEquals(2, kr.getMatch(1).startPos);
-	    assertEquals(4, kr.getMatch(1).endPos);
-	    assertEquals(3, kr.getMatch(2).startPos);
-	    assertEquals(6, kr.getMatch(2).endPos);
-	    
-	    ki.addDoc(createFieldDoc2());
-	    ki.commit();
-	    
-	    // with order
-	    sq = createQuery("s:e", "s:e", 1, 1,true);
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 1);
-	    
-	    // without order
-	    sq = createQuery("s:e", "s:e", 1, 1,false);
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 2);
-    }    
-    
+        assertEquals(3, kr.getMatch(0).endPos);
+        assertEquals(2, kr.getMatch(1).startPos);
+        assertEquals(4, kr.getMatch(1).endPos);
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(6, kr.getMatch(2).endPos);
+
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        // with order
+        sq = createQuery("s:e", "s:e", 1, 1, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 1);
+
+        // without order
+        sq = createQuery("s:e", "s:e", 1, 1, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 2);
+    }
+
 }
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 0ac7bad..13309d6 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
@@ -17,105 +17,96 @@
 import de.ids_mannheim.korap.query.SpanNextQuery;
 
 public class TestElementDistanceExclusionIndex {
-	
+
     Result kr;
-    KrillIndex ki; 
-    
-    private SpanQuery createQuery(String e, String x, String y, int min, int max, boolean isOrdered,
-    		boolean exclusion){
-    	SpanElementQuery eq = new SpanElementQuery("base",e);
-    	SpanDistanceQuery sq = new SpanDistanceQuery(        		
-        		new SpanTermQuery(new Term("base",x)),
-        		new SpanTermQuery(new Term("base",y)),
-        		new DistanceConstraint(eq, min, max, isOrdered, exclusion),
-        		true
-        );
-    	return sq;
+    KrillIndex ki;
+
+
+    private SpanQuery createQuery (String e, String x, String y, int min,
+            int max, boolean isOrdered, boolean exclusion) {
+        SpanElementQuery eq = new SpanElementQuery("base", e);
+        SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(
+                new Term("base", x)), new SpanTermQuery(new Term("base", y)),
+                new DistanceConstraint(eq, min, max, isOrdered, exclusion),
+                true);
+        return sq;
     }
-	
-	private FieldDocument createFieldDoc0(){
-    	FieldDocument fd = new FieldDocument();
+
+
+    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#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]");
         return fd;
     }
-    
-	private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
+
+
+    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]");
-        return fd;
-	}
-	
-	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", "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]");
         return fd;
     }
-	
-    /** Distance Zero, unordered
-     * 	There is a secondspan on the right side
+
+
+    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]");
+        return fd;
+    }
+
+
+    /**
+     * Distance Zero, unordered
+     * There is a secondspan on the right side
      * */
     @Test
-    public void testCase1() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    public void testCase1 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         SpanQuery sq;
-        sq = createQuery("s","s:d","s:c",0,0,false,true);                
+        sq = createQuery("s", "s:d", "s:c", 0, 0, false, true);
         kr = ki.search(sq, (short) 10);
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(6, kr.getMatch(0).startPos);
         assertEquals(7, kr.getMatch(0).endPos);
     }
-    
-    /** There is another firstspan within max distance
-     * 	Unordered
+
+
+    /**
+     * There is another firstspan within max distance
+     * Unordered
      * */
     @Test
-    public void testCase2() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    public void testCase2 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-        SpanQuery sq;       
-		        
-	    sq = createQuery("s","s:c","s:d",0,0,false,true);                
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 4);
-	    assertEquals(0, kr.getMatch(0).startPos);
+        SpanQuery sq;
+
+        sq = createQuery("s", "s:c", "s:d", 0, 0, false, true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 4);
+        assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(1, kr.getMatch(0).endPos);
         assertEquals(2, kr.getMatch(1).startPos);
         assertEquals(3, kr.getMatch(1).endPos);
@@ -124,24 +115,26 @@
         assertEquals(8, kr.getMatch(3).startPos);
         assertEquals(9, kr.getMatch(3).endPos);
     }
-    
-    /** Distance 0-1, ordered, unordered
+
+
+    /**
+     * Distance 0-1, ordered, unordered
      * */
     @Test
-    public void testCase3() throws IOException{
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    public void testCase3 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
         SpanQuery sq;
         // unordered
-        sq = createQuery("s","s:c","s:e",0,1,false,true);                
+        sq = createQuery("s", "s:c", "s:e", 0, 1, false, true);
         kr = ki.search(sq, (short) 10);
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(5, kr.getMatch(0).startPos);
         assertEquals(6, kr.getMatch(0).endPos);
-        
+
         //ordered 
-        sq = createQuery("s","s:c","s:e",0,1,true,true);                
+        sq = createQuery("s", "s:c", "s:e", 0, 1, true, true);
         kr = ki.search(sq, (short) 10);
         assertEquals(kr.getTotalResults(), 3);
         assertEquals(2, kr.getMatch(0).startPos);
@@ -149,58 +142,62 @@
         assertEquals(3, kr.getMatch(1).startPos);
         assertEquals(4, kr.getMatch(1).endPos);
     }
-    
-	/** Multiple documents, ordered
-	 * 	No more secondspans, but there is still a firstspan
-	 * */
-	@Test
-    public void testCase4() throws IOException{
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());
-        ki.addDoc(createFieldDoc1()); 
+
+
+    /**
+     * Multiple documents, ordered
+     * No more secondspans, but there is still a firstspan
+     * */
+    @Test
+    public void testCase4 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
         ki.commit();
         SpanQuery sq;
-        
-        sq = createQuery("s","s:d","s:e",1,1,true,true);                
+
+        sq = createQuery("s", "s:d", "s:e", 1, 1, true, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 3);
-	    assertEquals(4, kr.getMatch(0).startPos);
+        assertEquals(4, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).getLocalDocID());
         assertEquals(2, kr.getMatch(1).startPos);
         assertEquals(3, kr.getMatch(1).endPos);
         assertEquals(8, kr.getMatch(2).startPos);
         assertEquals(9, kr.getMatch(2).endPos);
-	}
-    
-	/** Skip to
-	 * */
-	@Test
-    public void testCase5() throws IOException{
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());
+    }
+
+
+    /**
+     * Skip to
+     * */
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc1());
         ki.addDoc(createFieldDoc0());
-        ki.addDoc(createFieldDoc2());        
+        ki.addDoc(createFieldDoc2());
         ki.commit();
-        
-        SpanQuery sq = createQuery("s","s:c","s:d",1,1,false,true);
+
+        SpanQuery sq = createQuery("s", "s:c", "s:d", 1, 1, false, true);
         kr = ki.search(sq, (short) 10);
 
-        assertEquals(kr.getTotalResults(), 3);        
+        assertEquals(kr.getTotalResults(), 3);
         assertEquals(3, kr.getMatch(2).getLocalDocID());
         assertEquals(3, kr.getMatch(2).startPos);
         assertEquals(4, kr.getMatch(2).endPos);
-        
+
         sq = new SpanNextQuery(
-        		createQuery("s","s:c","s:d",1,1,false,true), 
-        		new SpanTermQuery(new Term("base", "s:a")));
-        
+                createQuery("s", "s:c", "s:d", 1, 1, false, true),
+                new SpanTermQuery(new Term("base", "s:a")));
+
         kr = ki.search(sq, (short) 10);
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(3, kr.getMatch(0).getLocalDocID());
         assertEquals(3, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
-	}
+    }
 }
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 8b52266..4ee6b09 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -29,212 +29,208 @@
 
 @RunWith(JUnit4.class)
 public class TestElementDistanceIndex {
-	
-	Result kr;
-    KrillIndex ki;   
-    
-	private FieldDocument createFieldDoc0() {
-    	FieldDocument fd = new FieldDocument();
+
+    Result kr;
+    KrillIndex ki;
+
+
+    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#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]");
         return fd;
-	}
-		
-	private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc3() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	public SpanQuery createQuery(String elementType, String x, String y, 
-			int min, int max, boolean isOrdered){
-		
-		SpanElementQuery e = new SpanElementQuery("base", elementType);
-		return new SpanDistanceQuery(        		 
-        		new SpanTermQuery(new Term("base",x)), 
-        		new SpanTermQuery(new Term("base",y)), 
-        		new DistanceConstraint( e, min, max, isOrdered, false),
-        		true);
-	}
-	
-	
-	/**	Multiple documents
-	 * 	Ensure terms and elements are in the same doc
-	 * 	Ensure terms are in elements
-	 *  Check filter candidate list
-	 * */
-	@Test
-	public void testCase1() throws IOException{
-		//System.out.println("testCase1");
-		ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
-        ki.addDoc(createFieldDoc1());        
+    }
+
+
+    public SpanQuery createQuery (String elementType, String x, String y,
+            int min, int max, boolean isOrdered) {
+
+        SpanElementQuery e = new SpanElementQuery("base", elementType);
+        return new SpanDistanceQuery(new SpanTermQuery(new Term("base", x)),
+                new SpanTermQuery(new Term("base", y)), new DistanceConstraint(
+                        e, min, max, isOrdered, false), true);
+    }
+
+
+    /**
+     * Multiple documents
+     * Ensure terms and elements are in the same doc
+     * Ensure terms are in elements
+     * Check filter candidate list
+     * */
+    @Test
+    public void testCase1 () throws IOException {
+        //System.out.println("testCase1");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
         ki.commit();
-        
-        SpanQuery sq;        
-        sq = createQuery("s", "s:b", "s:c", 0, 2,true);        
+
+        SpanQuery sq;
+        sq = createQuery("s", "s:b", "s:c", 0, 2, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 4);
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(1, kr.getMatch(0).endPos);
         assertEquals(0, kr.getMatch(1).startPos);
-        assertEquals(3, kr.getMatch(1).endPos);         
-	}
-	
-	/** Ensure terms and elements are in the same doc
-	 * */
-	@Test
-	public void testCase2() throws IOException{
-		//System.out.println("testCase2");
-		ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+        assertEquals(3, kr.getMatch(1).endPos);
+    }
+
+
+    /**
+     * Ensure terms and elements are in the same doc
+     * */
+    @Test
+    public void testCase2 () throws IOException {
+        //System.out.println("testCase2");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc1());
         ki.addDoc(createFieldDoc2());
         ki.commit();
-        
+
         SpanQuery sq;
-        sq = createQuery("p", "s:b", "s:d", 1, 1,true);
+        sq = createQuery("p", "s:b", "s:d", 1, 1, true);
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(2, kr.getMatch(0).getLocalDocID());
         assertEquals(2, kr.getMatch(0).startPos);
         assertEquals(4, kr.getMatch(0).endPos);
-        
-	}	
-	
-	/** Skip to */
-	@Test
-	public void testCase3() throws IOException{
-		//System.out.println("testCase3");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
+
+    }
+
+
+    /** Skip to */
+    @Test
+    public void testCase3 () throws IOException {
+        //System.out.println("testCase3");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc1());
         ki.addDoc(createFieldDoc3());
         ki.commit();
-        
+
         SpanQuery sq, edq;
-        edq = createQuery("s", "s:b", "s:c", 1, 1,true);
-		
-        sq = new SpanNextQuery(edq, 
-        		new SpanTermQuery(new Term("base", "s:d")));
-        
+        edq = createQuery("s", "s:b", "s:c", 1, 1, true);
+
+        sq = new SpanNextQuery(edq, new SpanTermQuery(new Term("base", "s:d")));
+
         kr = ki.search(sq, (short) 10);
-        
+
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(2, kr.getMatch(0).getLocalDocID());
         assertEquals(2, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
-        
-	}
-	
-	/** Same tokens in different elements */
-	@Test
-	public void testCase4() throws IOException{
-		//System.out.println("testCase4");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());       
+
+    }
+
+
+    /** Same tokens in different elements */
+    @Test
+    public void testCase4 () throws IOException {
+        //System.out.println("testCase4");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-        
+
         SpanQuery sq;
-        sq = createQuery("s", "s:b", "s:b", 1, 2,true);
+        sq = createQuery("s", "s:b", "s:b", 1, 2, true);
         kr = ki.search(sq, (short) 10);
-    		
+
         assertEquals(kr.getTotalResults(), 2);
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(4, kr.getMatch(0).endPos);
         assertEquals(3, kr.getMatch(1).startPos);
         assertEquals(5, kr.getMatch(1).endPos);
-        
+
     }
-	
-	/** Test query from json */
-	@Test
-	public void testCase5() throws Exception{
-		//System.out.println("testCase4");
-		ki = new KrillIndex();
-		ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"),true);       
+
+
+    /** Test query from json */
+    @Test
+    public void testCase5 () throws Exception {
+        //System.out.println("testCase4");
+        ki = new KrillIndex();
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
         ki.commit();
-        
-        InputStream is = getClass().getResourceAsStream("/queries/cosmas1.json");        
-        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+
+        InputStream is = getClass()
+                .getResourceAsStream("/queries/cosmas1.json");
+        BufferedReader bufferedReader = new BufferedReader(
+                new InputStreamReader(is, "UTF-8"));
         StringBuilder sb = new StringBuilder();
         String json;
-        while((json = bufferedReader.readLine()) != null){
+        while ((json = bufferedReader.readLine()) != null) {
             sb.append(json);
-        }                
+        }
         json = sb.toString();
-        
+
         SpanQueryWrapper sqwi;
-        try {    	    
-    	    sqwi = new KrillQuery("tokens").fromJson(json);
-    	}
-    	catch (QueryException e) {
-    	    fail(e.getMessage());
-    	    sqwi = new QueryBuilder("tokens").seg("???");
-    	};        
-    	
-        
+        try {
+            sqwi = new KrillQuery("tokens").fromJson(json);
+        }
+        catch (QueryException e) {
+            fail(e.getMessage());
+            sqwi = new QueryBuilder("tokens").seg("???");
+        };
+
+
         SpanQuery sq;
         sq = sqwi.toQuery();
         kr = ki.search(sq, (short) 10);
-    	
+
         assertEquals((long) 3, kr.getTotalResults());
         assertEquals(14, kr.getMatch(0).startPos);
         assertEquals(19, kr.getMatch(0).endPos);
         assertEquals(30, kr.getMatch(1).startPos);
         assertEquals(33, kr.getMatch(1).endPos);
-        
-      /*  for (Match km : kr.getMatches()){		
-        	System.out.println(km.getStartPos() +","+km.getEndPos()+" "
-        			+km.getSnippetBrackets());
-        }*/
+
+        /*  for (Match km : kr.getMatches()){		
+          	System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+          			+km.getSnippetBrackets());
+          }*/
     }
-	
-		
+
+
 }
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 cf869c1..b2ec752 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
@@ -31,383 +31,323 @@
 
     @Test
     public void indexExample1 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// <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]" +
-		 "[(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);
+        // <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]"
+                        + "[(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);
 
-	// <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]" +
-		 "[(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]");
-	ki.addDoc(fd);
+        // <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]"
+                        + "[(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]");
+        ki.addDoc(fd);
 
-	// Save documents
-	ki.commit();
+        // Save documents
+        ki.commit();
 
-	assertEquals(2, ki.numberOf("documents"));
+        assertEquals(2, ki.numberOf("documents"));
 
-	SpanQuery sq = new SpanElementQuery("base", "a");
+        SpanQuery sq = new SpanElementQuery("base", "a");
 
-	Result kr = ki.search(sq, (short) 10);
+        Result kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 6);
+        assertEquals("totalResults", kr.getTotalResults(), 6);
 
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 9, kr.getMatch(1).endPos);
-	assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 6, kr.getMatch(2).endPos);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 9, kr.getMatch(1).endPos);
+        assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 6, kr.getMatch(2).endPos);
 
-	assertEquals("StartPos (0)", 0, kr.getMatch(3).startPos);
-	assertEquals("EndPos (0)", 12, kr.getMatch(3).endPos);
-	assertEquals("StartPos (1)", 1, kr.getMatch(4).startPos);
-	assertEquals("EndPos (1)", 9, kr.getMatch(4).endPos);
-	assertEquals("StartPos (2)", 2, kr.getMatch(5).startPos);
-	assertEquals("EndPos (2)", 6, kr.getMatch(5).endPos);
+        assertEquals("StartPos (0)", 0, kr.getMatch(3).startPos);
+        assertEquals("EndPos (0)", 12, kr.getMatch(3).endPos);
+        assertEquals("StartPos (1)", 1, kr.getMatch(4).startPos);
+        assertEquals("EndPos (1)", 9, kr.getMatch(4).endPos);
+        assertEquals("StartPos (2)", 2, kr.getMatch(5).startPos);
+        assertEquals("EndPos (2)", 6, kr.getMatch(5).endPos);
 
-	// System.err.println(kr.toJSON());
+        // System.err.println(kr.toJSON());
     };
 
+
     @Test
     public void indexExample2 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// <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]");
-	ki.addDoc(fd);
+        // <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]");
+        ki.addDoc(fd);
 
-	// Save documents
-	ki.commit();
+        // Save documents
+        ki.commit();
 
-	assertEquals(1, ki.numberOf("documents"));
+        assertEquals(1, ki.numberOf("documents"));
 
-	SpanQuery sq = new SpanElementQuery("base", "a");
+        SpanQuery sq = new SpanElementQuery("base", "a");
 
-	Result kr = ki.search(sq, (short) 10);
+        Result kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 9, kr.getMatch(2).endPos);
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 9, kr.getMatch(2).endPos);
     };
 
+
     @Test
     public void indexExample3 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// <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]");
-	ki.addDoc(fd);
+        // <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]");
+        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]" +
-		 "[(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]");
-	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]"
+                        + "[(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]");
+        ki.addDoc(fd);
 
-	// xyz
-	fd = new FieldDocument();
-	fd.addTV("base",
-		 "x  y  z  ",
-		 "[(0-3)s:x]" +
-		 "[(3-6)s:y]" +
-		 "[(6-9)s:z]");
-	ki.addDoc(fd);
+        // xyz
+        fd = new FieldDocument();
+        fd.addTV("base", "x  y  z  ", "[(0-3)s:x]" + "[(3-6)s:y]"
+                + "[(6-9)s:z]");
+        ki.addDoc(fd);
 
-	// <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]" +
-		 "[(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]");
-	ki.addDoc(fd);
+        // <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]"
+                        + "[(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]");
+        ki.addDoc(fd);
 
-	// <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]" +
-		 "[(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);
+        // <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]"
+                        + "[(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);
 
-	// xyz
-	fd = new FieldDocument();
-	fd.addTV("base",
-		 "a  b  c  ",
-		 "[(0-3)s:a]" +
-		 "[(3-6)s:b]" +
-		 "[(6-9)s:c]");
-	ki.addDoc(fd);
+        // xyz
+        fd = new FieldDocument();
+        fd.addTV("base", "a  b  c  ", "[(0-3)s:a]" + "[(3-6)s:b]"
+                + "[(6-9)s:c]");
+        ki.addDoc(fd);
 
 
-	// Save documents
-	ki.commit();
+        // Save documents
+        ki.commit();
 
-	assertEquals(6, ki.numberOf("documents"));
+        assertEquals(6, ki.numberOf("documents"));
 
-	SpanQuery sq = new SpanElementQuery("base", "a");
+        SpanQuery sq = new SpanElementQuery("base", "a");
 
-	Result kr = ki.search(sq, (short) 15);
+        Result kr = ki.search(sq, (short) 15);
 
-	// System.err.println(kr.toJSON());
+        // System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", kr.getTotalResults(), 12);
+        assertEquals("totalResults", kr.getTotalResults(), 12);
 
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 0, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 0, kr.getMatch(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 0, kr.getMatch(2).endPos);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 0, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 0, kr.getMatch(1).endPos);
+        assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 0, kr.getMatch(2).endPos);
 
-	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
-	assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
-	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
-	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
+        assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+        assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
+        assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+        assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+        assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+        assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
 
-	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
-	assertEquals("EndPos (6)", 12, kr.getMatch(6).endPos);
-	assertEquals("StartPos (7)", 1, kr.getMatch(7).startPos);
-	assertEquals("EndPos (7)", 9, kr.getMatch(7).endPos);
-	assertEquals("StartPos (8)", 2, kr.getMatch(8).startPos);
-	assertEquals("EndPos (8)", 6, kr.getMatch(8).endPos);
+        assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+        assertEquals("EndPos (6)", 12, kr.getMatch(6).endPos);
+        assertEquals("StartPos (7)", 1, kr.getMatch(7).startPos);
+        assertEquals("EndPos (7)", 9, kr.getMatch(7).endPos);
+        assertEquals("StartPos (8)", 2, kr.getMatch(8).startPos);
+        assertEquals("EndPos (8)", 6, kr.getMatch(8).endPos);
 
-	assertEquals("StartPos (9)", 0, kr.getMatch(9).startPos);
-	assertEquals("EndPos (9)", 3, kr.getMatch(9).endPos);
-	assertEquals("StartPos (10)", 0, kr.getMatch(10).startPos);
-	assertEquals("EndPos (10)", 6, kr.getMatch(10).endPos);
-	assertEquals("StartPos (11)", 0, kr.getMatch(11).startPos);
-	assertEquals("EndPos (11)", 9, kr.getMatch(11).endPos);
+        assertEquals("StartPos (9)", 0, kr.getMatch(9).startPos);
+        assertEquals("EndPos (9)", 3, kr.getMatch(9).endPos);
+        assertEquals("StartPos (10)", 0, kr.getMatch(10).startPos);
+        assertEquals("EndPos (10)", 6, kr.getMatch(10).endPos);
+        assertEquals("StartPos (11)", 0, kr.getMatch(11).startPos);
+        assertEquals("EndPos (11)", 9, kr.getMatch(11).endPos);
     };
 
 
     @Test
     public void indexExample4 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        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]");
-	ki.addDoc(fd);
+        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]");
+        ki.addDoc(fd);
 
-	// Save documents
-	ki.commit();
+        // Save documents
+        ki.commit();
 
-	assertEquals(1, ki.numberOf("documents"));
+        assertEquals(1, ki.numberOf("documents"));
 
-	SpanQuery sq = new SpanElementQuery("base", "a");
+        SpanQuery sq = new SpanElementQuery("base", "a");
 
-	Result kr = ki.search(sq, 0, (short) 15, false, (short) 3, false, (short) 3);
-	
-	assertEquals("... ccc[222222]fff ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... fff[333333]iii ...", kr.getMatch(1).getSnippetBrackets());
+        Result kr = ki.search(sq, 0, (short) 15, false, (short) 3, false,
+                (short) 3);
+
+        assertEquals("... ccc[222222]fff ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... fff[333333]iii ...", kr.getMatch(1)
+                .getSnippetBrackets());
     };
 
 
     @Test
     public void indexExample5 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	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]");
-	ki.addDoc(fd);
+        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]");
+        ki.addDoc(fd);
 
-	// Save documents
-	ki.commit();
+        // Save documents
+        ki.commit();
 
-	assertEquals(1, ki.numberOf("documents"));
+        assertEquals(1, ki.numberOf("documents"));
 
-	SpanQuery sq = new SpanElementQuery("base", "a");
+        SpanQuery sq = new SpanElementQuery("base", "a");
 
-	Result kr = ki.search(sq, 0, (short) 15, false, (short) 3, false, (short) 3);
+        Result kr = ki.search(sq, 0, (short) 15, false, (short) 3, false,
+                (short) 3);
 
-	assertEquals("[111111]ccc ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... ccc[222222]fff ...", kr.getMatch(1).getSnippetBrackets());
-	assertEquals("... fff[333333]iii ...", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("[111111]ccc ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("... ccc[222222]fff ...", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("... fff[333333]iii ...", kr.getMatch(2)
+                .getSnippetBrackets());
     };
 
 
     @Test
     public void indexExample6 () throws IOException {
 
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// <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
-	ki.addDoc(fd);
+        // <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
+        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
-	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
+        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
-	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
-	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
+        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
-	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
+        ki.addDoc(fd);
 
-	// Save documents
-	ki.commit();
+        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
+        ki.addDoc(fd);
 
-	SpanQuery sq;
-	Result kr;
+        // Save documents
+        ki.commit();
 
-	sq = new SpanElementQuery("base", "a");
-	kr = ki.search(sq, (short) 15);
+        SpanQuery sq;
+        Result kr;
 
-	// System.err.println(kr.toJSON());
-	
-	assertEquals(5, ki.numberOf("documents"));
-	assertEquals("totalResults", kr.getTotalResults(), 7);
+        sq = new SpanElementQuery("base", "a");
+        kr = ki.search(sq, (short) 15);
+
+        // System.err.println(kr.toJSON());
+
+        assertEquals(5, ki.numberOf("documents"));
+        assertEquals("totalResults", kr.getTotalResults(), 7);
     };
 };
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 38d53e4..00b9874 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -43,212 +43,198 @@
 
     @Test
     public void indexExample1 () throws IOException {
-	FieldDocument fd = new FieldDocument();
+        FieldDocument fd = new FieldDocument();
 
-	fd.addString("corpusID", "WPD");
-	fd.addString("ID", "WPD-AAA-00001");
-	fd.addText("textClass", "music entertainment");
-	fd.addText("author", "Peter Frankenfeld");
-	fd.addInt("pubDate", 20130617);
-	fd.addText("title", "Wikipedia");
-	fd.addText("subTitle", "Die freie Enzyklopädie");
-	fd.addStored("layerInfo", "opennlp/p=pos");
-	fd.addString("pubPlace", "Bochum");
-	fd.addInt("lastModified", 20130717);
-	fd.addTV("tokens",
-		 "abc",
-		 "[(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]");
+        fd.addString("corpusID", "WPD");
+        fd.addString("ID", "WPD-AAA-00001");
+        fd.addText("textClass", "music entertainment");
+        fd.addText("author", "Peter Frankenfeld");
+        fd.addInt("pubDate", 20130617);
+        fd.addText("title", "Wikipedia");
+        fd.addText("subTitle", "Die freie Enzyklopädie");
+        fd.addStored("layerInfo", "opennlp/p=pos");
+        fd.addString("pubPlace", "Bochum");
+        fd.addInt("lastModified", 20130717);
+        fd.addTV("tokens", "abc", "[(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]");
 
-	assertEquals(fd.doc.getField("title").name(), "title");
-	assertEquals(fd.doc.getField("title").stringValue(), "Wikipedia");
+        assertEquals(fd.doc.getField("title").name(), "title");
+        assertEquals(fd.doc.getField("title").stringValue(), "Wikipedia");
 
-	assertEquals(fd.doc.getField("corpusID").name(), "corpusID");
-	assertEquals(fd.doc.getField("corpusID").stringValue(), "WPD");
+        assertEquals(fd.doc.getField("corpusID").name(), "corpusID");
+        assertEquals(fd.doc.getField("corpusID").stringValue(), "WPD");
 
-	assertEquals(fd.doc.getField("ID").name(), "ID");
-	assertEquals(fd.doc.getField("ID").stringValue(), "WPD-AAA-00001");
+        assertEquals(fd.doc.getField("ID").name(), "ID");
+        assertEquals(fd.doc.getField("ID").stringValue(), "WPD-AAA-00001");
 
-	assertEquals(fd.doc.getField("subTitle").name(), "subTitle");
-	assertEquals(fd.doc.getField("subTitle").stringValue(), "Die freie Enzyklopädie");
+        assertEquals(fd.doc.getField("subTitle").name(), "subTitle");
+        assertEquals(fd.doc.getField("subTitle").stringValue(),
+                "Die freie Enzyklopädie");
 
-	assertEquals(fd.doc.getField("pubPlace").name(), "pubPlace");
-	assertEquals(fd.doc.getField("pubPlace").stringValue(), "Bochum");
+        assertEquals(fd.doc.getField("pubPlace").name(), "pubPlace");
+        assertEquals(fd.doc.getField("pubPlace").stringValue(), "Bochum");
 
-	assertEquals(fd.doc.getField("lastModified").name(), "lastModified");
-	assertEquals(fd.doc.getField("lastModified").stringValue(), "20130717");
+        assertEquals(fd.doc.getField("lastModified").name(), "lastModified");
+        assertEquals(fd.doc.getField("lastModified").stringValue(), "20130717");
 
-	assertEquals(fd.doc.getField("tokens").name(), "tokens");
-	assertEquals(fd.doc.getField("tokens").stringValue(), "abc");
+        assertEquals(fd.doc.getField("tokens").name(), "tokens");
+        assertEquals(fd.doc.getField("tokens").stringValue(), "abc");
 
-	assertEquals(fd.doc.getField("author").name(), "author");
-	assertEquals(fd.doc.getField("author").stringValue(), "Peter Frankenfeld");
+        assertEquals(fd.doc.getField("author").name(), "author");
+        assertEquals(fd.doc.getField("author").stringValue(),
+                "Peter Frankenfeld");
 
-	assertEquals(fd.doc.getField("layerInfo").name(), "layerInfo");
-	assertEquals(fd.doc.getField("layerInfo").stringValue(), "opennlp/p=pos");
+        assertEquals(fd.doc.getField("layerInfo").name(), "layerInfo");
+        assertEquals(fd.doc.getField("layerInfo").stringValue(),
+                "opennlp/p=pos");
 
-	assertEquals(fd.doc.getField("textClass").name(), "textClass");
-	assertEquals(fd.doc.getField("textClass").stringValue(), "music entertainment");
+        assertEquals(fd.doc.getField("textClass").name(), "textClass");
+        assertEquals(fd.doc.getField("textClass").stringValue(),
+                "music entertainment");
     };
 
+
     @Test
     public void indexExample2 () throws Exception {
 
-	String json = new String(
-"{" +
-"  \"fields\" : [" +
-"    { "+
-"      \"primaryData\" : \"abc\"" +
-"    }," +
-"    {" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" +
-"      ]" +
-"    }" +
-"  ]," +
-"  \"corpusID\"  : \"WPD\"," +
-"  \"ID\"        : \"WPD-AAA-00001\"," +
-"  \"textClass\" : \"music entertainment\"," +
-"  \"author\"    : \"Peter Frankenfeld\"," +
-"  \"pubDate\"   : 20130617," +
-"  \"title\"     : \"Wikipedia\"," +
-"  \"subTitle\"  : \"Die freie Enzyklopädie\"," +
-"  \"pubPlace\"  : \"Bochum\"" +
-"}");
+        String json = new String("{" + "  \"fields\" : [" + "    { "
+                + "      \"primaryData\" : \"abc\"" + "    }," + "    {"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" + "      ]"
+                + "    }" + "  ]," + "  \"corpusID\"  : \"WPD\","
+                + "  \"ID\"        : \"WPD-AAA-00001\","
+                + "  \"textClass\" : \"music entertainment\","
+                + "  \"author\"    : \"Peter Frankenfeld\","
+                + "  \"pubDate\"   : 20130617,"
+                + "  \"title\"     : \"Wikipedia\","
+                + "  \"subTitle\"  : \"Die freie Enzyklopädie\","
+                + "  \"pubPlace\"  : \"Bochum\"" + "}");
 
-	KrillIndex ki = new KrillIndex();
-	FieldDocument fd = ki.addDoc(json);
+        KrillIndex ki = new KrillIndex();
+        FieldDocument fd = ki.addDoc(json);
 
-	ki.commit();
+        ki.commit();
 
-	assertEquals(fd.getPrimaryData(),"abc");
-	assertEquals(fd.getCorpusID(),"WPD");
-	assertEquals(fd.getID(),"WPD-AAA-00001");
-	assertEquals(fd.getTextClass(),"music entertainment");
-	assertEquals(fd.getAuthor(),"Peter Frankenfeld");
-	assertEquals(fd.getTitle(),"Wikipedia");
-	assertEquals(fd.getSubTitle(),"Die freie Enzyklopädie");
-	assertEquals(fd.getPubPlace(),"Bochum");
-	assertEquals(fd.getPubDate().toDisplay(),"2013-06-17");
+        assertEquals(fd.getPrimaryData(), "abc");
+        assertEquals(fd.getCorpusID(), "WPD");
+        assertEquals(fd.getID(), "WPD-AAA-00001");
+        assertEquals(fd.getTextClass(), "music entertainment");
+        assertEquals(fd.getAuthor(), "Peter Frankenfeld");
+        assertEquals(fd.getTitle(), "Wikipedia");
+        assertEquals(fd.getSubTitle(), "Die freie Enzyklopädie");
+        assertEquals(fd.getPubPlace(), "Bochum");
+        assertEquals(fd.getPubDate().toDisplay(), "2013-06-17");
 
-	QueryBuilder kq = new QueryBuilder("tokens");
-	Result kr = ki.search((SpanQuery) kq.seq(kq._(3, kq.seg("s:b"))).toQuery());
+        QueryBuilder kq = new QueryBuilder("tokens");
+        Result kr = ki.search((SpanQuery) kq.seq(kq._(3, kq.seg("s:b")))
+                .toQuery());
 
-	Match km = kr.getMatch(0);
+        Match km = kr.getMatch(0);
 
-	assertEquals(km.getPrimaryData(),"abc");
-	assertEquals(km.getCorpusID(),"WPD");
-	assertEquals(km.getDocID(),"WPD-AAA-00001");
-	assertEquals(km.getTextClass(),"music entertainment");
-	assertEquals(km.getAuthor(),"Peter Frankenfeld");
-	assertEquals(km.getTitle(),"Wikipedia");
-	assertEquals(km.getSubTitle(),"Die freie Enzyklopädie");
-	assertEquals(km.getPubPlace(),"Bochum");
-	assertEquals(km.getPubDate().toDisplay(),"2013-06-17");
+        assertEquals(km.getPrimaryData(), "abc");
+        assertEquals(km.getCorpusID(), "WPD");
+        assertEquals(km.getDocID(), "WPD-AAA-00001");
+        assertEquals(km.getTextClass(), "music entertainment");
+        assertEquals(km.getAuthor(), "Peter Frankenfeld");
+        assertEquals(km.getTitle(), "Wikipedia");
+        assertEquals(km.getSubTitle(), "Die freie Enzyklopädie");
+        assertEquals(km.getPubPlace(), "Bochum");
+        assertEquals(km.getPubDate().toDisplay(), "2013-06-17");
 
-	assertEquals(km.getSnippetBrackets(),"a[{3:b}]c");
+        assertEquals(km.getSnippetBrackets(), "a[{3:b}]c");
     };
 
 
     @Test
     public void indexExample3 () throws IOException {
 
-	// Construct index
-	KrillIndex ki = new KrillIndex();
+        // Construct index
+        KrillIndex ki = new KrillIndex();
 
-	// Indexing test files
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	    FieldDocument fd = ki.addDoc(
-	        getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
-	};
-	ki.commit();
+        // Indexing test files
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            FieldDocument fd = ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("tokens");
+        QueryBuilder kq = new QueryBuilder("tokens");
 
-	Krill ks;
-	Result kr;
+        Krill ks;
+        Result kr;
 
-	// Start creating query
-	// within(<s>, {1: {2: [mate/p=ADJA & mate/m=number:sg]}[opennlp/p=NN & tt/p=NN]})
+        // Start creating query
+        // within(<s>, {1: {2: [mate/p=ADJA & mate/m=number:sg]}[opennlp/p=NN & tt/p=NN]})
 
-	ks = new Krill(kq.within(
-              kq.tag("s"),
-              kq._(1,
-                kq.seq(
-	          kq.seg("mate/p:ADJA")
-                ).append(
-		  kq.seg("opennlp/p:NN")
-	        )
-	      )
-            ));
-	
-    KrillMeta meta = ks.getMeta();
-	meta.setCount(1);
-	meta.setCutOff(true);
+        ks = new Krill(kq.within(
+                kq.tag("s"),
+                kq._(1,
+                        kq.seq(kq.seg("mate/p:ADJA")).append(
+                                kq.seg("opennlp/p:NN")))));
 
-	meta.getContext().left.setCharacter(true).setLength(6);
-	meta.getContext().right.setToken(true).setLength(6);
+        KrillMeta meta = ks.getMeta();
+        meta.setCount(1);
+        meta.setCutOff(true);
 
-	assertEquals("... okal. [Der Buchstabe A hat in {1:deutschen Texten} eine durchschnittliche Häufigkeit von 6,51 %.] Er ist damit der sechsthäufigste Buchstabe ...", ks.apply(ki).getMatch(0).getSnippetBrackets());
+        meta.getContext().left.setCharacter(true).setLength(6);
+        meta.getContext().right.setToken(true).setLength(6);
+
+        assertEquals(
+                "... okal. [Der Buchstabe A hat in {1:deutschen Texten} eine durchschnittliche Häufigkeit von 6,51 %.] Er ist damit der sechsthäufigste Buchstabe ...",
+                ks.apply(ki).getMatch(0).getSnippetBrackets());
     };
 
+
     @Test
     public void queryJSONBsp18 () throws Exception {
 
-	// Construct index
-	KrillIndex ki = new KrillIndex();
+        // Construct index
+        KrillIndex ki = new KrillIndex();
 
-	// Indexing test files
-	for (String i : new String[] {"00001",
-				      "00002",
-				      "00003",
-				      "00004",
-				      "00005",
-				      "00006",
-				      "02439"}) {
-	    FieldDocument fd = ki.addDoc(
-	        getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
-	};
-	ki.commit();
+        // Indexing test files
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            FieldDocument fd = ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
 
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp18.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp18.jsonld").getFile());
 
-	Result kr = ki.search(sqwi.toQuery(), 0, (short) 5, true, (short) 2, false, (short) 5);
+        Result kr = ki.search(sqwi.toQuery(), 0, (short) 5, true, (short) 2,
+                false, (short) 5);
 
-	// Bug:
-	// System.err.println(kr.toJSON());
+        // Bug:
+        // System.err.println(kr.toJSON());
     };
 
+
     public static String getString (String path) {
-	StringBuilder contentBuilder = new StringBuilder();
-	try {
-	    BufferedReader in = new BufferedReader(new FileReader(path));
-	    String str;
-	    while ((str = in.readLine()) != null) {
-		contentBuilder.append(str);
-	    };
-	    in.close();
-	} catch (IOException e) {
-	    fail(e.getMessage());
-	}
-	return contentBuilder.toString();
+        StringBuilder contentBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(path));
+            String str;
+            while ((str = in.readLine()) != null) {
+                contentBuilder.append(str);
+            };
+            in.close();
+        }
+        catch (IOException e) {
+            fail(e.getMessage());
+        }
+        return contentBuilder.toString();
     };
 
+
     public static SpanQueryWrapper jsonQuery (String jsonFile) {
         SpanQueryWrapper sqwi;
-	
+
         try {
             String json = getString(jsonFile);
             sqwi = new KrillQuery("tokens").fromJson(json);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
index 59b779f..97f132b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
@@ -74,724 +74,625 @@
 
     private Directory index = new RAMDirectory();
 
+
     @Test
     public void multiTermToken () throws CorpusDataException {
-	MultiTermToken test = new MultiTermToken("hunde", "pos:n", "m:gen:pl");
-	assertEquals(test.terms.get(0).term, "hunde");
-	assertEquals(test.terms.get(1).term, "pos:n");
-	assertEquals(test.terms.get(2).term, "m:gen:pl");
+        MultiTermToken test = new MultiTermToken("hunde", "pos:n", "m:gen:pl");
+        assertEquals(test.terms.get(0).term, "hunde");
+        assertEquals(test.terms.get(1).term, "pos:n");
+        assertEquals(test.terms.get(2).term, "m:gen:pl");
 
-	test = new MultiTermToken("hunde", "pos:n", "m:gen:pl");
-	assertEquals(test.terms.get(0).term, "hunde");
-	assertEquals(test.terms.get(1).term, "pos:n");
-	assertEquals(test.terms.get(2).term, "m:gen:pl");
+        test = new MultiTermToken("hunde", "pos:n", "m:gen:pl");
+        assertEquals(test.terms.get(0).term, "hunde");
+        assertEquals(test.terms.get(1).term, "pos:n");
+        assertEquals(test.terms.get(2).term, "m:gen:pl");
     };
 
+
     private List initIndexer () throws IOException {
-	List<Map<String, String>> list = new ArrayList<>();
+        List<Map<String, String>> list = new ArrayList<>();
 
-	Map<String, String> d1 = new HashMap<String, String>();
-	d1.put("id",        "w1");
-	d1.put("corpus",    "wiki");
-	d1.put("author",    "Nils Diewald");
-	d1.put("title",     "Wikipedia");
-	d1.put("subtitle",  "A test");
-	d1.put("pubDate",   "20130701");
-	d1.put("pubPlace",  "Mannheim");
-	d1.put("textClass", "news sports");
-	d1.put("textStr",   "Er nahm den Hunden die Angst.");
-	d1.put("text",      "Er#0-2|PPER|er|c:nom;p:3;n:sg;g:masc|<>:s#0-29$<i>7 " +
-                            "nahm#3-7|VVFIN|nehmen|p:3;n:sg;t:past;m:ind| " +
-                            "den#8-11|ART|der|c:acc;n:sg;g:masc| " +
-                            "Hunden#12-18|NN|hund|c:acc;n:sg;g:masc| " +
-	                    "die#19-22|ART|der|c:nom;n:sg;g:fem| " +
-                            "Angst#23-28|NN|angst|c:nom;n:sg;g:fem| " +
-	                    ".#28-29|$.|.||");
-	list.add(d1);
+        Map<String, String> d1 = new HashMap<String, String>();
+        d1.put("id", "w1");
+        d1.put("corpus", "wiki");
+        d1.put("author", "Nils Diewald");
+        d1.put("title", "Wikipedia");
+        d1.put("subtitle", "A test");
+        d1.put("pubDate", "20130701");
+        d1.put("pubPlace", "Mannheim");
+        d1.put("textClass", "news sports");
+        d1.put("textStr", "Er nahm den Hunden die Angst.");
+        d1.put("text", "Er#0-2|PPER|er|c:nom;p:3;n:sg;g:masc|<>:s#0-29$<i>7 "
+                + "nahm#3-7|VVFIN|nehmen|p:3;n:sg;t:past;m:ind| "
+                + "den#8-11|ART|der|c:acc;n:sg;g:masc| "
+                + "Hunden#12-18|NN|hund|c:acc;n:sg;g:masc| "
+                + "die#19-22|ART|der|c:nom;n:sg;g:fem| "
+                + "Angst#23-28|NN|angst|c:nom;n:sg;g:fem| " + ".#28-29|$.|.||");
+        list.add(d1);
 
-	Map<String, String> d2 = new HashMap<String, String>();
+        Map<String, String> d2 = new HashMap<String, String>();
 
-	d2.put("id",        "w2");
-	d2.put("corpus",    "wiki");
-	d2.put("author",    "Peter Thomas");
-	d2.put("title",     "Waldartikel");
-	d2.put("subtitle",  "Another test");
-	d2.put("pubDate",   "20130723");
-	d2.put("pubPlace",  "Bielefeld");
-	d2.put("textClass", "news");
-	d2.put("textStr",   "Sie liefen durch den Wald.");
-	d2.put("text",      "Sie#0-3|PPER|sie|c:nom;p:3;n:pl;g:all|<>:s#0-26$<i>6 " +
-                            "liefen#4-10|VVFIN|laufen|p:3;n:pl;t:past;m:ind| " +
-                            "durch#11-16|APPR|durch|| " +
-                            "den#17-20|ART|der|c:acc;n:sg;g:masc| " +
-	                    "Wald#21-25|NN|wald|c:acc;n:sg;g:masc| " +
-	                    ".#25-26|$.|.||");
-	list.add(d2);
+        d2.put("id", "w2");
+        d2.put("corpus", "wiki");
+        d2.put("author", "Peter Thomas");
+        d2.put("title", "Waldartikel");
+        d2.put("subtitle", "Another test");
+        d2.put("pubDate", "20130723");
+        d2.put("pubPlace", "Bielefeld");
+        d2.put("textClass", "news");
+        d2.put("textStr", "Sie liefen durch den Wald.");
+        d2.put("text", "Sie#0-3|PPER|sie|c:nom;p:3;n:pl;g:all|<>:s#0-26$<i>6 "
+                + "liefen#4-10|VVFIN|laufen|p:3;n:pl;t:past;m:ind| "
+                + "durch#11-16|APPR|durch|| "
+                + "den#17-20|ART|der|c:acc;n:sg;g:masc| "
+                + "Wald#21-25|NN|wald|c:acc;n:sg;g:masc| " + ".#25-26|$.|.||");
+        list.add(d2);
 
-	Map<String, String> d3 = new HashMap<String, String>();
-	d3.put("id",        "w3");
-	d3.put("corpus",    "zeitung");
-	d3.put("author",    "Michael Meier");
-	d3.put("title",     "Angst");
-	d3.put("subtitle",  "Starr vor Angst");
-	d3.put("pubDate",   "20130713");
-	d3.put("pubPlace",  "Bielefeld");
-	d3.put("textClass", "sports");
-	d3.put("textStr",   "Er wagte nicht, sich zu ruehren. Er war starr vor Angst.");
-	d3.put("text",      "Er#0-2|PPER|er|c:nom;n:sg;g:masc;p:3|<>:s#0-32$<i>8 " +
-	                    "wagte#3-8|VVFIN|wagen|p:3;n:sg;t:past;m:ind| " +
-	                    "nicht#9-14|PTKNEG|nicht|| " +
-	                    ",#14-15|$,|,|| " +
-                            "sich#16-20|PRF|sich|c:acc;p:3;n:sg| " +
-	                    "zu#21-23|PTKZU|zu|| " +
-	                    "ruehren#24-31|VVFIN|ruehren|| " +
-	                    ".#31-32|$.|.|| " +
-	                    "Er#33-35|PPER|er|c:nom;p:3;n:sg;g:masc|<>:s#33-56$<i>14 " +
-	                    "war#36-39|VAFIN|sein|p:3;n:sg;t:past;m:ind| " +
-	                    "starr#40-45|ADJD|starr|comp:pos| " +
-	                    "vor#46-49|APPR|vor|| " +
-	                    "Angst#50-55|NN|angst|c:dat;n:sg;g:fem| " +
-	                    ".#55-56|$.|.||");
-	list.add(d3);
+        Map<String, String> d3 = new HashMap<String, String>();
+        d3.put("id", "w3");
+        d3.put("corpus", "zeitung");
+        d3.put("author", "Michael Meier");
+        d3.put("title", "Angst");
+        d3.put("subtitle", "Starr vor Angst");
+        d3.put("pubDate", "20130713");
+        d3.put("pubPlace", "Bielefeld");
+        d3.put("textClass", "sports");
+        d3.put("textStr",
+                "Er wagte nicht, sich zu ruehren. Er war starr vor Angst.");
+        d3.put("text", "Er#0-2|PPER|er|c:nom;n:sg;g:masc;p:3|<>:s#0-32$<i>8 "
+                + "wagte#3-8|VVFIN|wagen|p:3;n:sg;t:past;m:ind| "
+                + "nicht#9-14|PTKNEG|nicht|| " + ",#14-15|$,|,|| "
+                + "sich#16-20|PRF|sich|c:acc;p:3;n:sg| "
+                + "zu#21-23|PTKZU|zu|| " + "ruehren#24-31|VVFIN|ruehren|| "
+                + ".#31-32|$.|.|| "
+                + "Er#33-35|PPER|er|c:nom;p:3;n:sg;g:masc|<>:s#33-56$<i>14 "
+                + "war#36-39|VAFIN|sein|p:3;n:sg;t:past;m:ind| "
+                + "starr#40-45|ADJD|starr|comp:pos| " + "vor#46-49|APPR|vor|| "
+                + "Angst#50-55|NN|angst|c:dat;n:sg;g:fem| " + ".#55-56|$.|.||");
+        list.add(d3);
 
-	return list;
+        return list;
     };
 
+
     @Test
     public void indexLucene () throws Exception {
 
-	// Base analyzer for searching and indexing
-	StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
+        // Base analyzer for searching and indexing
+        StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_43);
 
-	// Based on
-	// http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/
-	// analysis/Analyzer.html?is-external=true
+        // Based on
+        // http://lucene.apache.org/core/4_0_0/core/org/apache/lucene/
+        // analysis/Analyzer.html?is-external=true
 
-	// Create configuration with base analyzer
-	IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43, analyzer);
+        // Create configuration with base analyzer
+        IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_43,
+                analyzer);
 
-	// Add a document 1 with the correct fields
-	IndexWriter w = new IndexWriter(index, config);
+        // Add a document 1 with the correct fields
+        IndexWriter w = new IndexWriter(index, config);
 
-	Collection docs = initIndexer();
+        Collection docs = initIndexer();
 
-	@SuppressWarnings("unchecked")
-	Iterator<Map<String,String>> i = (Iterator<Map<String,String>>) docs.iterator();
+        @SuppressWarnings("unchecked")
+        Iterator<Map<String, String>> i = (Iterator<Map<String, String>>) docs
+                .iterator();
 
-	for (; i.hasNext(); ) {
-	    addDoc(w, i.next());
-	};
+        for (; i.hasNext();) {
+            addDoc(w, i.next());
+        };
 
-	assertEquals(3, w.numDocs());
+        assertEquals(3, w.numDocs());
 
-	w.close();
+        w.close();
 
-	// Check directory
-	DirectoryReader reader = DirectoryReader.open( index );
-	assertEquals(docs.size(), reader.maxDoc());
-	assertEquals(docs.size(), reader.numDocs());
+        // Check directory
+        DirectoryReader reader = DirectoryReader.open(index);
+        assertEquals(docs.size(), reader.maxDoc());
+        assertEquals(docs.size(), reader.numDocs());
 
-	// Check searcher
-	IndexSearcher searcher = new IndexSearcher( reader );
+        // Check searcher
+        IndexSearcher searcher = new IndexSearcher(reader);
 
-	// textClass
-	// All texts of text class "news"
-	assertEquals(2,
-	  searcher.search(
-	    new TermQuery(
-	      new Term("textClass", "news")
-	    ), 10
-	  ).totalHits
+        // textClass
+        // All texts of text class "news"
+        assertEquals(2, searcher.search(new TermQuery(new Term("textClass",
+                "news")), 10).totalHits);
+
+        // textClass
+        // All texts of text class "sports"
+        assertEquals(2, searcher.search(new TermQuery(new Term("textClass",
+                "sports")), 10).totalHits);
+
+        // TextIndex
+        // All docs containing "l:nehmen"
+        assertEquals(1, searcher.search(new TermQuery(new Term("text",
+                "l:nehmen")), 10).totalHits);
+
+        // TextIndex
+        // All docs containing "s:den"
+        assertEquals(
+                2,
+                searcher.search(new TermQuery(new Term("text", "s:den")), 10).totalHits);
+
+        /*
+        assertEquals(3,
+              searcher.search(
+                new TermQuery(
+                  new Term("text", "T")
+            ), 10
+          ).totalHits
+            );
+        */
+
+        // BooleanQuery
+        // All docs containing "s:den" and "l:sie"
+        TermQuery s_den = new TermQuery(new Term("text", "s:den"));
+        TermQuery l_sie = new TermQuery(new Term("text", "l:sie"));
+        BooleanQuery bool = new BooleanQuery();
+        bool.add(s_den, BooleanClause.Occur.MUST);
+        bool.add(l_sie, BooleanClause.Occur.MUST);
+
+        assertEquals(1, searcher.search(bool, 10).totalHits);
+
+        // BooleanQuery
+        // All docs containing "s:den" or "l:sie"
+        bool = new BooleanQuery();
+        bool.add(s_den, BooleanClause.Occur.SHOULD);
+        bool.add(l_sie, BooleanClause.Occur.SHOULD);
+        assertEquals(2, searcher.search(bool, 10).totalHits);
+
+
+        // RegexpQuery
+        // All docs containing ".{4}en" (liefen und Hunden)
+        RegexpQuery srquery = new RegexpQuery(new Term("text", "s:.{4}en"));
+        assertEquals(2, searcher.search(srquery, 10).totalHits);
+
+        // RegexpQuery
+        // All docs containing "E." (Er) (2x)
+        srquery = new RegexpQuery(new Term("text", "s:E."));
+        assertEquals(2, searcher.search(srquery, 10).totalHits);
+
+        SpanRegexQueryWrapper ssrquery = new SpanRegexQueryWrapper("text",
+                "s:E.");
+        assertEquals(2, searcher.search(ssrquery.toQuery(), 10).totalHits);
+
+
+        // RegexpQuery
+        // All docs containing "E." (er) (0x)
+        srquery = new RegexpQuery(new Term("text", "s:e."));
+        assertEquals(0, searcher.search(srquery, 10).totalHits);
+
+        ssrquery = new SpanRegexQueryWrapper("text", "s:e.");
+        assertEquals(0, searcher.search(ssrquery.toQuery(), 10).totalHits);
+
+        // Check http://comments.gmane.org/gmane.comp.jakarta.lucene.user/52283
+        // for Carstens question on wildcards
+
+        // RegexpQuery
+        // All docs containing "E."/i ([Ee]r) (2x)
+        srquery = new RegexpQuery(new Term("text", "i:e."));
+        assertEquals(2, searcher.search(srquery, 10).totalHits);
+
+        ssrquery = new SpanRegexQueryWrapper("text", "s:e.", true);
+        assertEquals("SpanMultiTermQueryWrapper(text:/i:e./)", ssrquery
+                .toQuery().toString());
+        assertEquals(2, searcher.search(ssrquery.toQuery(), 10).totalHits);
+
+        // All docs containing "ng"/x (Angst) (2x)
+        srquery = new RegexpQuery(new Term("text", "s:.*ng.*"));
+        assertEquals(2, searcher.search(srquery, 10).totalHits);
+
+        // [base=angst]
+        SpanTermQuery stq = new SpanTermQuery(new Term("text", "l:angst"));
+        assertEquals(2, searcher.search(srquery, 10).totalHits);
+
+        // vor Angst
+        // [orth=vor][orth=Angst]
+        SpanNearQuery snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "s:vor")),
+                new SpanTermQuery(new Term("text", "s:Angst")) }, 1, true);
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
+
+        // Spannearquery [p:VVFIN][]{,5}[m:nom:sg:fem]
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:VVFIN")),
+                new SpanSegmentQueryWrapper("text", "m:c:nom", "m:n:sg",
+                        "m:g:fem").toQuery() }, 5,     // slop
+                true   // inOrder
+                     // Possible: CollectPayloads
         );
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
-	// textClass
-	// All texts of text class "sports"
-	assertEquals(2,
-	  searcher.search(
-	    new TermQuery(
-	      new Term("textClass", "sports")
-	    ), 10
-	  ).totalHits
+
+        // Spannearquery [p:VVFIN][m:acc:sg:masc]
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:VVFIN")),
+                new SpanNearQuery(new SpanQuery[] {
+                        new SpanTermQuery(new Term("text", "m:c:acc")),
+                        new SpanNearQuery(
+                                new SpanQuery[] {
+                                        new SpanTermQuery(new Term("text",
+                                                "m:n:sg")),
+                                        new SpanTermQuery(new Term("text",
+                                                "m:g:masc")) }, -1, false) },
+                        -1,     // slop
+                        false   // inOrder
+                // Possible: CollectPayloads
+                )
+        // new SpanTermQuery(new Term("text", "m:-acc:--sg:masc"))
+                }, 0,     // slop
+                true   // inOrder
+                     // Possible: CollectPayloads
         );
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
-	// TextIndex
-	// All docs containing "l:nehmen"
-	assertEquals(1,
-	  searcher.search(
-	    new TermQuery(
-	      new Term("text", "l:nehmen")
-	    ), 10
-	  ).totalHits
+
+        // Spannearquery [p:VVFIN|m:3:sg:past:ind]
+        // Exact match!
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:VVFIN")),
+                new SpanNearQuery(new SpanQuery[] {
+                        new SpanTermQuery(new Term("text", "m:p:3")),
+                        new SpanNearQuery(new SpanQuery[] {
+                                new SpanTermQuery(new Term("text", "m:n:sg")),
+                                new SpanNearQuery(new SpanQuery[] {
+                                        new SpanTermQuery(new Term("text",
+                                                "m:t:past")),
+                                        new SpanTermQuery(new Term("text",
+                                                "m:m:ind")), }, -1, false) },
+                                -1, false) }, -1, false) },
+        // new SpanTermQuery(new Term("text", "m:---3:--sg:past:-ind"))
+                -1,     // slop
+                false   // inOrder
+        // Possible: CollectPayloads
         );
+        assertEquals(2, searcher.search(snquery, 10).totalHits);
 
-	// TextIndex
-	// All docs containing "s:den"
-	assertEquals(2,
-          searcher.search(
-            new TermQuery(
-              new Term("text", "s:den")
-	    ), 10
-	  ).totalHits
+        // To make sure, this is not equal:
+        // Spannearquery [p:VVFIN & m:3:sg:past:ind]
+        // Exact match!
+        // Maybe it IS equal
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:VVFIN")),
+                new SpanTermQuery(new Term("text", "m:p:3")),
+                new SpanTermQuery(new Term("text", "m:n:sg")),
+                new SpanTermQuery(new Term("text", "m:t:past")),
+                new SpanTermQuery(new Term("text", "m:m:ind")), }, -1,     // slop
+                false   // inOrder
+        // Possible: CollectPayloads
         );
+        assertNotEquals(2, searcher.search(snquery, 10).totalHits);
+        // assertEquals(2, searcher.search(snquery, 10).totalHits);
 
-	/*
-	assertEquals(3,
-          searcher.search(
-            new TermQuery(
-              new Term("text", "T")
-	    ), 10
-	  ).totalHits
+        // Spannearquery [p:VVFIN & m:3:sg & past:ind]
+        SpanSegmentQueryWrapper sniquery = new SpanSegmentQueryWrapper("text",
+                "p:VVFIN", "m:p:3", "m:n:sg", "m:t:past", "m:m:ind");
+        assertEquals(2, searcher.search(sniquery.toQuery(), 10).totalHits);
+
+
+        // Todo:
+
+        /*
+        sniquery = new SpanSegmentQuery(
+              "text",
+          "p:VVFIN",
+          "m:p:3",
+          "m:n:sg",
+          "m:t:past",
+          "m:m:ind"
+            );
+        */
+
+        // Spannearquery [p:VVFIN][]{,5}[m:nom:sg:fem]
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:VVFIN")),
+                new SpanSegmentQueryWrapper("text", "m:c:nom", "m:n:sg",
+                        "m:g:fem").toQuery() }, 5,     // slop
+                true   // inOrder
+                     // Possible: CollectPayloads
         );
-	*/
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
-	// BooleanQuery
-	// All docs containing "s:den" and "l:sie"
-	TermQuery s_den = new TermQuery(new Term("text", "s:den"));
-	TermQuery l_sie = new TermQuery(new Term("text", "l:sie"));
-	BooleanQuery bool = new BooleanQuery();
-	bool.add(s_den, BooleanClause.Occur.MUST);
-	bool.add(l_sie, BooleanClause.Occur.MUST);
+        sniquery = new SpanSegmentQueryWrapper("text", "p:VVFIN", "m:p:3",
+                "m:t:past", "m:m:ind", "m:n:sg");
+        assertEquals(2, searcher.search(sniquery.toQuery(), 10).totalHits);
 
-	assertEquals(1, searcher.search(bool, 10).totalHits);
+        // [p = VVFIN & m:p = 3 & m:t = past & m:n != pl] or
+        // [p = VVFIN & m:p = 3 & m:t = past & !m:n = pl]
+        // TODO: Problem: What should happen in case the category does not exist?
+        // pssible solution: & ( m:n != pl & exists(m:n))
+        sniquery = new SpanSegmentQueryWrapper("text", "p:VVFIN", "m:p:3",
+                "m:t:past");
+        SpanQuery snqquery = new SpanNotQuery(sniquery.toQuery(),
+                new SpanTermQuery(new Term("text", "m:n:pl")));
+        assertEquals(2, searcher.search(snqquery, 10).totalHits);
 
-	// BooleanQuery
-	// All docs containing "s:den" or "l:sie"
-	bool = new BooleanQuery();
-	bool.add(s_den, BooleanClause.Occur.SHOULD);
-	bool.add(l_sie, BooleanClause.Occur.SHOULD);
-	assertEquals(2, searcher.search(bool, 10).totalHits);
+        // [p = NN & (m:c: = dat | m:c = acc)]
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanTermQuery(new Term("text", "p:NN")),
+                new SpanOrQuery(new SpanTermQuery(new Term("text", "m:c:nom")),
+                        new SpanTermQuery(new Term("text", "m:c:acc"))) }, -1,
+                false);
+
+        assertEquals(2, searcher.search(snqquery, 10).totalHits);
+
+        // [p = NN & !(m:c: = nom | m:c = acc)]
+        snqquery = new SpanNotQuery(
+                new SpanTermQuery(new Term("text", "p:NN")), new SpanOrQuery(
+                        new SpanTermQuery(new Term("text", "m:c:nom")),
+                        new SpanTermQuery(new Term("text", "m:c:acc"))));
+        assertEquals(1, searcher.search(snqquery, 10).totalHits);
+
+        // [p = NN & !(m:c = nom)]
+        snqquery = new SpanNotQuery(
+                new SpanTermQuery(new Term("text", "p:NN")), new SpanTermQuery(
+                        new Term("text", "m:c:nom")));
+        assertEquals(3, searcher.search(snqquery, 10).totalHits);
+
+        // [p=NN & !(m:c = acc)]
+        snqquery = new SpanNotQuery(
+                new SpanTermQuery(new Term("text", "p:NN")), new SpanTermQuery(
+                        new Term("text", "m:c:acc")));
+        assertEquals(2, searcher.search(snqquery, 10).totalHits);
+
+        // [p=PPER][][p=ART]
+        snquery = new SpanNearQuery(
+                new SpanQuery[] {
+                        new SpanTermQuery(new Term("text", "p:PPER")),
+                        new SpanNearQuery(new SpanQuery[] {
+                                new SpanTermQuery(new Term("text", "T")),
+                                new SpanTermQuery(new Term("text", "p:ART")) },
+                                0, true), }, 0, true);
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
 
-	// RegexpQuery
-	// All docs containing ".{4}en" (liefen und Hunden)
-	RegexpQuery srquery = new RegexpQuery(
-            new Term("text", "s:.{4}en")
-        );
-	assertEquals(2, searcher.search(srquery, 10).totalHits);
+        // Todo:
+        // [orth=się][]{2,4}[base=bać]
+        // [orth=się][orth!="[.!?,:]"]{,5}[base=bać]|[base=bać][base="on|ja|ty|my|wy"]?[orth=się]
+        // [pos=subst & orth="a.*"]{2}
+        // [tag=subst:sg:nom:n]
+        // [case==acc & case==gen] ??
+        // [case~acc & case~gen]
+        // [case~~acc]
+        // [base=bać][orth!=się]+[orth=się] within s
 
-	// RegexpQuery
-	// All docs containing "E." (Er) (2x)
-        srquery = new RegexpQuery(
-            new Term("text", "s:E.")
-        );
-	assertEquals(2, searcher.search(srquery, 10).totalHits);
-
-	SpanRegexQueryWrapper ssrquery = new SpanRegexQueryWrapper("text", "s:E.");
-	assertEquals(2, searcher.search(ssrquery.toQuery(), 10).totalHits);
+        // [][][p:VAFIN] within s
+        // [][p:VAFIN] within s
 
 
-	// RegexpQuery
-	// All docs containing "E." (er) (0x)
-	srquery = new RegexpQuery(
-            new Term("text", "s:e.")
-        );
-	assertEquals(0, searcher.search(srquery, 10).totalHits);
+        // [][][p:VAFIN]
+        snquery = new SpanNearQuery(new SpanQuery[] {
+                new SpanNearQuery(new SpanQuery[] {
+                        new SpanTermQuery(new Term("text", "T")),
+                        new SpanTermQuery(new Term("text", "T")) }, 0, true),
+                new SpanTermQuery(new Term("text", "p:VAFIN")) }, 0, true);
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
-	ssrquery = new SpanRegexQueryWrapper("text", "s:e.");
-	assertEquals(0, searcher.search(ssrquery.toQuery(), 10).totalHits);
+        /*
+        http://stackoverflow.com/questions/1311199/finding-the-position-of-search-hits-from-lucene
+        */
 
-	// Check http://comments.gmane.org/gmane.comp.jakarta.lucene.user/52283
-	// for Carstens question on wildcards
+        StringBuilder payloadString = new StringBuilder();
+        Map<Term, TermContext> termContexts = new HashMap<>();
+        for (AtomicReaderContext atomic : reader.leaves()) {
+            Bits bitset = atomic.reader().getLiveDocs();
+            //	    Spans spans = NearSpansOrdered();
+            Spans spans = snquery.getSpans(atomic, bitset, termContexts);
 
-	// RegexpQuery
-	// All docs containing "E."/i ([Ee]r) (2x)
-	srquery = new RegexpQuery(
-            new Term("text", "i:e.")
-        );
-	assertEquals(2, searcher.search(srquery, 10).totalHits);
-
-	ssrquery = new SpanRegexQueryWrapper("text", "s:e.", true);
-	assertEquals("SpanMultiTermQueryWrapper(text:/i:e./)", ssrquery.toQuery().toString());
-	assertEquals(2, searcher.search(ssrquery.toQuery(), 10).totalHits);
-
-	// All docs containing "ng"/x (Angst) (2x)
-	srquery = new RegexpQuery(
-            new Term("text", "s:.*ng.*")
-        );
-	assertEquals(2, searcher.search(srquery, 10).totalHits);
-
-	// [base=angst]
-	SpanTermQuery stq = new SpanTermQuery(new Term("text", "l:angst"));
-	assertEquals(2, searcher.search(srquery, 10).totalHits);
-
-	// vor Angst
-	// [orth=vor][orth=Angst]
-	SpanNearQuery snquery = new SpanNearQuery(
-          new SpanQuery[] {
-	      new SpanTermQuery(new Term("text", "s:vor")),
-	      new SpanTermQuery(new Term("text", "s:Angst"))
-	  },
-	  1,
-	  true
-        );
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-	// Spannearquery [p:VVFIN][]{,5}[m:nom:sg:fem]
-	snquery = new SpanNearQuery(
-          new SpanQuery[] {
-	    new SpanTermQuery(new Term("text", "p:VVFIN")),
-	    new SpanSegmentQueryWrapper("text", "m:c:nom", "m:n:sg", "m:g:fem").toQuery()
-          },
-	  5,     // slop
-	  true   // inOrder
-          // Possible: CollectPayloads
-	);
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-
-	// Spannearquery [p:VVFIN][m:acc:sg:masc]
-	snquery = new SpanNearQuery(
-          new SpanQuery[] {
-	    new SpanTermQuery(new Term("text", "p:VVFIN")),
-	    new SpanNearQuery(
-	      new SpanQuery[] {
-                new SpanTermQuery(new Term("text", "m:c:acc")),
-	        new SpanNearQuery(
-	          new SpanQuery[] {
-                    new SpanTermQuery(new Term("text", "m:n:sg")),
-                    new SpanTermQuery(new Term("text", "m:g:masc"))
-                  },
-		  -1,
-		  false
-		)
-       	      },
-	      -1,     // slop
-	      false   // inOrder
-	      // Possible: CollectPayloads
-	    )
-            // new SpanTermQuery(new Term("text", "m:-acc:--sg:masc"))
-          },
-	  0,     // slop
-	  true   // inOrder
-          // Possible: CollectPayloads
-	);
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-
-	// Spannearquery [p:VVFIN|m:3:sg:past:ind]
-	// Exact match!
-	snquery = new SpanNearQuery(
-	  new SpanQuery[] {
-	    new SpanTermQuery(new Term("text", "p:VVFIN")),
-            new SpanNearQuery(
-              new SpanQuery[] {
-	        new SpanTermQuery(new Term("text", "m:p:3")),
-	        new SpanNearQuery(
-                  new SpanQuery[] {
-	            new SpanTermQuery(new Term("text", "m:n:sg")),
-	            new SpanNearQuery(
-		      new SpanQuery[] {
-		        new SpanTermQuery(new Term("text", "m:t:past")),
-	                new SpanTermQuery(new Term("text", "m:m:ind")),
-                      },
-		      -1,
-		      false
-		    )
-		  },
-		  -1,
-		  false
-	        )
-              },
-	      -1,
-	      false
-	    )
-	  },
-	  // new SpanTermQuery(new Term("text", "m:---3:--sg:past:-ind"))
-	  -1,     // slop
-	  false   // inOrder
-          // Possible: CollectPayloads
-	);
-	assertEquals(2, searcher.search(snquery, 10).totalHits);
-
-	// To make sure, this is not equal:
-	// Spannearquery [p:VVFIN & m:3:sg:past:ind]
-	// Exact match!
-	// Maybe it IS equal
-	snquery = new SpanNearQuery(
-	  new SpanQuery[] {
-	    new SpanTermQuery(new Term("text", "p:VVFIN")),
-	    new SpanTermQuery(new Term("text", "m:p:3")),
-	    new SpanTermQuery(new Term("text", "m:n:sg")),
-	    new SpanTermQuery(new Term("text", "m:t:past")),
-	    new SpanTermQuery(new Term("text", "m:m:ind")),
-	  },
-	  -1,     // slop
-	  false   // inOrder
-          // Possible: CollectPayloads
-	);
-	assertNotEquals(2, searcher.search(snquery, 10).totalHits);
-	// assertEquals(2, searcher.search(snquery, 10).totalHits);
-
-	// Spannearquery [p:VVFIN & m:3:sg & past:ind]
-	SpanSegmentQueryWrapper sniquery = new SpanSegmentQueryWrapper(
-          "text",
-	  "p:VVFIN",
-	  "m:p:3",
-	  "m:n:sg",
-	  "m:t:past",
-	  "m:m:ind"
-        );
-	assertEquals(2, searcher.search(sniquery.toQuery(), 10).totalHits);
-
-
-	// Todo:
-
-	/*
-	sniquery = new SpanSegmentQuery(
-          "text",
-	  "p:VVFIN",
-	  "m:p:3",
-	  "m:n:sg",
-	  "m:t:past",
-	  "m:m:ind"
-        );
-	*/
-
-	// Spannearquery [p:VVFIN][]{,5}[m:nom:sg:fem]
-	snquery = new SpanNearQuery(
-          new SpanQuery[] {
-	    new SpanTermQuery(new Term("text", "p:VVFIN")),
-	    new SpanSegmentQueryWrapper("text", "m:c:nom", "m:n:sg", "m:g:fem").toQuery()
-          },
-	  5,     // slop
-	  true   // inOrder
-          // Possible: CollectPayloads
-	);
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-	sniquery = new SpanSegmentQueryWrapper("text", "p:VVFIN", "m:p:3", "m:t:past", "m:m:ind", "m:n:sg");
-	assertEquals(2, searcher.search(sniquery.toQuery(), 10).totalHits);
-
-	// [p = VVFIN & m:p = 3 & m:t = past & m:n != pl] or
-	// [p = VVFIN & m:p = 3 & m:t = past & !m:n = pl]
-	// TODO: Problem: What should happen in case the category does not exist?
-	// pssible solution: & ( m:n != pl & exists(m:n))
-	sniquery = new SpanSegmentQueryWrapper("text", "p:VVFIN", "m:p:3", "m:t:past");
-	SpanQuery snqquery = new SpanNotQuery(sniquery.toQuery(), new SpanTermQuery(new Term("text", "m:n:pl")));
-	assertEquals(2, searcher.search(snqquery, 10).totalHits);
-
-	// [p = NN & (m:c: = dat | m:c = acc)]
-	snquery = new SpanNearQuery(
-	    new SpanQuery[] {
-		new SpanTermQuery(new Term("text", "p:NN")),
-  	        new SpanOrQuery(
-			new SpanTermQuery( new Term("text", "m:c:nom" )),
-		        new SpanTermQuery( new Term("text", "m:c:acc" ))
-	        )
-	    },
-	    -1,
-	    false
-	);
-
-	assertEquals(2, searcher.search(snqquery, 10).totalHits);
-
-	// [p = NN & !(m:c: = nom | m:c = acc)]
-	snqquery = new SpanNotQuery(
-	   new SpanTermQuery(new Term("text", "p:NN")),
-	   new SpanOrQuery(
-		new SpanTermQuery( new Term("text", "m:c:nom" )),
-		new SpanTermQuery( new Term("text", "m:c:acc" ))
-	   )
-        );
-	assertEquals(1, searcher.search(snqquery, 10).totalHits);
-
-	// [p = NN & !(m:c = nom)]
-	snqquery = new SpanNotQuery(
-	   new SpanTermQuery( new Term("text", "p:NN")),
-	   new SpanTermQuery( new Term("text", "m:c:nom" ))
-        );
-	assertEquals(3, searcher.search(snqquery, 10).totalHits);
-
-	// [p=NN & !(m:c = acc)]
-	snqquery = new SpanNotQuery(
-	   new SpanTermQuery( new Term("text", "p:NN")),
-	   new SpanTermQuery( new Term("text", "m:c:acc" ))
-        );
-	assertEquals(2, searcher.search(snqquery, 10).totalHits);
-
-	// [p=PPER][][p=ART]
-	snquery = new SpanNearQuery(
-  	    new SpanQuery[] {
-		new SpanTermQuery( new Term("text", "p:PPER")),
-		new SpanNearQuery(
-		    new SpanQuery[] {
-			new SpanTermQuery( new Term("text", "T")),
-			new SpanTermQuery( new Term("text", "p:ART"))
-		    },
-		    0,
-		    true),
-	    },
-	    0, 
-	    true
-        );
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-
-	// Todo:
-	// [orth=się][]{2,4}[base=bać]
-	// [orth=się][orth!="[.!?,:]"]{,5}[base=bać]|[base=bać][base="on|ja|ty|my|wy"]?[orth=się]
-	// [pos=subst & orth="a.*"]{2}
-	// [tag=subst:sg:nom:n]
-	// [case==acc & case==gen] ??
-	// [case~acc & case~gen]
-	// [case~~acc]
-	// [base=bać][orth!=się]+[orth=się] within s
-
-	// [][][p:VAFIN] within s
-	// [][p:VAFIN] within s
-
-
-	// [][][p:VAFIN]
-	snquery = new SpanNearQuery(
-  	    new SpanQuery[] {
-		new SpanNearQuery(
-  	            new SpanQuery[] {
-		        new SpanTermQuery( new Term("text", "T") ),
-		        new SpanTermQuery( new Term("text", "T") )
-                    },
-		    0,
-		    true
- 	        ),
-		new SpanTermQuery( new Term("text", "p:VAFIN") )
-	    },
-	    0,
-	    true
-        );
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
-
-/*
-http://stackoverflow.com/questions/1311199/finding-the-position-of-search-hits-from-lucene
-*/
-
-	StringBuilder payloadString = new StringBuilder();
-	Map<Term, TermContext> termContexts = new HashMap<>();
-	for (AtomicReaderContext atomic : reader.leaves()) {
-	    Bits bitset = atomic.reader().getLiveDocs();
-	    //	    Spans spans = NearSpansOrdered();
-	    Spans spans = snquery.getSpans(atomic, bitset, termContexts);
-
-	    while (spans.next()) {
-		int docid = atomic.docBase + spans.doc();
-		if (spans.isPayloadAvailable()) {
-		    for (byte[] payload : spans.getPayload()) {
-			/* retrieve payload for current matching span */
-			payloadString.append(new String(payload));
-			payloadString.append(" | ");
-		    };
-		};
-	    };
-	};
-	//	assertEquals(33, payloadString.length());
-	assertEquals(0, payloadString.length());
+            while (spans.next()) {
+                int docid = atomic.docBase + spans.doc();
+                if (spans.isPayloadAvailable()) {
+                    for (byte[] payload : spans.getPayload()) {
+                        /* retrieve payload for current matching span */
+                        payloadString.append(new String(payload));
+                        payloadString.append(" | ");
+                    };
+                };
+            };
+        };
+        //	assertEquals(33, payloadString.length());
+        assertEquals(0, payloadString.length());
 
 
 
-	// [][][p:VAFIN]
-	// without collecting payloads
-	snquery = new SpanNearQuery(
-  	    new SpanQuery[] {
-		new SpanNearQuery(
-  	            new SpanQuery[] {
-		        new SpanTermQuery( new Term("text", "T") ),
-		        new SpanTermQuery( new Term("text", "T") )
-                    },
-		    0,
-		    true,
-		    false
- 	        ),
-		new SpanTermQuery( new Term("text", "p:VAFIN") )
-	    },
-	    0,
-	    true,
-	    false
-        );
-	assertEquals(1, searcher.search(snquery, 10).totalHits);
+        // [][][p:VAFIN]
+        // without collecting payloads
+        snquery = new SpanNearQuery(
+                new SpanQuery[] {
+                        new SpanNearQuery(new SpanQuery[] {
+                                new SpanTermQuery(new Term("text", "T")),
+                                new SpanTermQuery(new Term("text", "T")) }, 0,
+                                true, false),
+                        new SpanTermQuery(new Term("text", "p:VAFIN")) }, 0,
+                true, false);
+        assertEquals(1, searcher.search(snquery, 10).totalHits);
 
-	payloadString = new StringBuilder();
-	termContexts = new HashMap<>();
-	for (AtomicReaderContext atomic : reader.leaves()) {
-	    Bits bitset = atomic.reader().getLiveDocs();
-	    //	    Spans spans = NearSpansOrdered();
-	    Spans spans = snquery.getSpans(atomic, bitset, termContexts);
+        payloadString = new StringBuilder();
+        termContexts = new HashMap<>();
+        for (AtomicReaderContext atomic : reader.leaves()) {
+            Bits bitset = atomic.reader().getLiveDocs();
+            //	    Spans spans = NearSpansOrdered();
+            Spans spans = snquery.getSpans(atomic, bitset, termContexts);
 
-	    while (spans.next()) {
-		int docid = atomic.docBase + spans.doc();
-		for (byte[] payload : spans.getPayload()) {
-		    /* retrieve payload for current matching span */
-		    payloadString.append(new String(payload));
-		    payloadString.append(" | ");
-		};
-	    };
-	};
-	assertEquals(0, payloadString.length());
+            while (spans.next()) {
+                int docid = atomic.docBase + spans.doc();
+                for (byte[] payload : spans.getPayload()) {
+                    /* retrieve payload for current matching span */
+                    payloadString.append(new String(payload));
+                    payloadString.append(" | ");
+                };
+            };
+        };
+        assertEquals(0, payloadString.length());
 
 
-	// [][][p:VAFIN] in s
-	// ([e:s:<][]*[T] | [T & e:s:<]) [T] ([p:VAFIN & e:s:>] | [T][]*[e:s:>]
+        // [][][p:VAFIN] in s
+        // ([e:s:<][]*[T] | [T & e:s:<]) [T] ([p:VAFIN & e:s:>] | [T][]*[e:s:>]
 
-	/*
+        /*
 
-	SpanSegmentWithinQuery ssequery = new SpanSegmentWithinQuery(
-	    "text","s", new SpanSegmentSequenceQuery("text", "T", "T", "p:VAFIN")
-        );
-	assertEquals(0, searcher.search(ssequery.toQuery(), 10).totalHits);
+        SpanSegmentWithinQuery ssequery = new SpanSegmentWithinQuery(
+            "text","s", new SpanSegmentSequenceQuery("text", "T", "T", "p:VAFIN")
+            );
+        assertEquals(0, searcher.search(ssequery.toQuery(), 10).totalHits);
 
-	payloadString = new StringBuilder();
-	termContexts = new HashMap<>();
-	for (AtomicReaderContext atomic : reader.leaves()) {
-	    Bits bitset = atomic.reader().getLiveDocs();
-	    // Spans spans = NearSpansOrdered();
-	    Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
+        payloadString = new StringBuilder();
+        termContexts = new HashMap<>();
+        for (AtomicReaderContext atomic : reader.leaves()) {
+            Bits bitset = atomic.reader().getLiveDocs();
+            // Spans spans = NearSpansOrdered();
+            Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
 
-	    while (spans.next()) {
-		int docid = atomic.docBase + spans.doc();
-		for (byte[] payload : spans.getPayload()) {
-		/// retrieve payload for current matching span
-		    payloadString.append(new String(payload));
-		    payloadString.append(" | ");
-		};
-	    };
-	};
-	assertEquals(0, payloadString.length(), 1);
+            while (spans.next()) {
+        	int docid = atomic.docBase + spans.doc();
+        	for (byte[] payload : spans.getPayload()) {
+        	/// retrieve payload for current matching span
+        	    payloadString.append(new String(payload));
+        	    payloadString.append(" | ");
+        	};
+            };
+        };
+        assertEquals(0, payloadString.length(), 1);
 
-	ssequery = new SpanSegmentWithinQuery(
-	    "text","s", new SpanSegmentSequenceQuery("text", "T", "p:VAFIN")
-        );
+        ssequery = new SpanSegmentWithinQuery(
+            "text","s", new SpanSegmentSequenceQuery("text", "T", "p:VAFIN")
+            );
 
-	assertEquals("for " + ssequery.toQuery(),
-		     1, searcher.search(ssequery.toQuery(), 10).totalHits);
+        assertEquals("for " + ssequery.toQuery(),
+        	     1, searcher.search(ssequery.toQuery(), 10).totalHits);
 
-	payloadString = new StringBuilder();
-	termContexts = new HashMap<>();
-	for (AtomicReaderContext atomic : reader.leaves()) {
-	    Bits bitset = atomic.reader().getLiveDocs();
-	    // Spans spans = NearSpansOrdered();
-	    Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
+        payloadString = new StringBuilder();
+        termContexts = new HashMap<>();
+        for (AtomicReaderContext atomic : reader.leaves()) {
+            Bits bitset = atomic.reader().getLiveDocs();
+            // Spans spans = NearSpansOrdered();
+            Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
 
-	    while (spans.next()) {
-		int docid = atomic.docBase + spans.doc();
-		for (byte[] payload : spans.getPayload()) {
-		    // retrieve payload for current matching span
-		    payloadString.append(new String(payload));
-		    payloadString.append(" | ");
-		};
-		fail("Doc: " + docid + " with " + spans.start() + "-" + spans.end() + " || " + payloadString.toString());
-	    };
-	};
-	assertEquals(20, payloadString.length());
+            while (spans.next()) {
+        	int docid = atomic.docBase + spans.doc();
+        	for (byte[] payload : spans.getPayload()) {
+        	    // retrieve payload for current matching span
+        	    payloadString.append(new String(payload));
+        	    payloadString.append(" | ");
+        	};
+        	fail("Doc: " + docid + " with " + spans.start() + "-" + spans.end() + " || " + payloadString.toString());
+            };
+        };
+        assertEquals(20, payloadString.length());
 
-	*/
+        */
 
-	// --------------------______>
+        // --------------------______>
 
 
 
-	//	Spans spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), ssequery.toQuery());
-	/*
-    TopDocs topDocs = is.search(snq, 1);
-    Set<String> payloadSet = new HashSet<String>();
-    for (int i = 0; i < topDocs.scoreDocs.length; i++) {
-      while (spans.next()) {
-        Collection<byte[]> payloads = spans.getPayload();
+        //	Spans spans = MultiSpansWrapper.wrap(searcher.getTopReaderContext(), ssequery.toQuery());
+        /*
+        TopDocs topDocs = is.search(snq, 1);
+        Set<String> payloadSet = new HashSet<String>();
+        for (int i = 0; i < topDocs.scoreDocs.length; i++) {
+          while (spans.next()) {
+            Collection<byte[]> payloads = spans.getPayload();
 
-        for (final byte [] payload : payloads) {
-          payloadSet.add(new String(payload, "UTF-8"));
+            for (final byte [] payload : payloads) {
+              payloadSet.add(new String(payload, "UTF-8"));
+            }
+          }
         }
-      }
-    }
-	*/
+        */
 
 
-	/*
-Alternativ:
-    IndexReader reader = writer.getReader();
-    writer.close();
-    IndexSearcher searcher = newSearcher(reader);
+        /*
+        Alternativ:
+        IndexReader reader = writer.getReader();
+        writer.close();
+        IndexSearcher searcher = newSearcher(reader);
 
-    PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getTopReaderContext());
-    
-    Collection<byte[]> payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
-    if(VERBOSE)
-      System.out.println("Num payloads:" + payloads.size());
-    for (final byte [] bytes : payloads) {
-      if(VERBOSE)
-        System.out.println(new String(bytes, "UTF-8"));
-    }
-*/
+        PayloadSpanUtil psu = new PayloadSpanUtil(searcher.getTopReaderContext());
+        
+        Collection<byte[]> payloads = psu.getPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
+        if(VERBOSE)
+          System.out.println("Num payloads:" + payloads.size());
+        for (final byte [] bytes : payloads) {
+          if(VERBOSE)
+            System.out.println(new String(bytes, "UTF-8"));
+        }
+        */
 
 
 
-	/* new: */
+        /* new: */
 
-	// PayloadHelper helper = new PayloadHelper();
+        // PayloadHelper helper = new PayloadHelper();
 
-	// Map<Term, TermContext> termContexts = new HashMap<>();
-//Spans spans;
-//spans = snquery.getSpans(searcher.getIndexReader());
-//    searcher = helper.setUp(similarity, 1000);
-	/*
-	IndexReader reader = search.getReader(querycontainer.getFoundry());
-	Spans luceneSpans;
-	Bits bitset = atomic.reader().getLiveDocs();
-	for (byte[] payload : luceneSpans.getPayload())
+        // Map<Term, TermContext> termContexts = new HashMap<>();
+        //Spans spans;
+        //spans = snquery.getSpans(searcher.getIndexReader());
+        //    searcher = helper.setUp(similarity, 1000);
+        /*
+        IndexReader reader = search.getReader(querycontainer.getFoundry());
+        Spans luceneSpans;
+        Bits bitset = atomic.reader().getLiveDocs();
+        for (byte[] payload : luceneSpans.getPayload())
 
-	/* Iterate over all matching documents */
-	/*
-	    while (luceneSpans.next() && total < config.getMaxhits()) {
-		Span matchSpan;
-		StringBuilder payloadString = new StringBuilder();
-		int docid = atomic.docBase + luceneSpans.doc();
-		String docname = search.retrieveDocname(docid,
-						querycontainer.getFoundry());
-						total++;
+        /* Iterate over all matching documents */
+        /*
+            while (luceneSpans.next() && total < config.getMaxhits()) {
+        	Span matchSpan;
+        	StringBuilder payloadString = new StringBuilder();
+        	int docid = atomic.docBase + luceneSpans.doc();
+        	String docname = search.retrieveDocname(docid,
+        					querycontainer.getFoundry());
+        					total++;
 
-		for (byte[] payload : luceneSpans.getPayload())
-	*/
-					/* retrieve payload for current matching span */
-	//				payloadString.append(new String(payload));
+        	for (byte[] payload : luceneSpans.getPayload())
+        */
+        /* retrieve payload for current matching span */
+        //				payloadString.append(new String(payload));
 
-				/* create span containing result */
-		/*
-				matchSpan = new Span(docname);
-				matchSpan.setIndexdocid(docid);
-				matchSpan.setLayer(querycontainer.getLayer());
-				matchSpan.storePayloads(payloadString.toString());
-				matchSpans.add(matchSpan);
-*/
-				/*
-				 * topdocs = searcher.search(new ConstantScoreQuery(corpusQ add
-				 * position to list of positions to be considered for later
-				 * searches
-				 */
-				/*
-				validValues.put(docname,
-						matchSpan.getPayload(config.getPrefix()));
-			}
-*/
+        /* create span containing result */
+        /*
+        		matchSpan = new Span(docname);
+        		matchSpan.setIndexdocid(docid);
+        		matchSpan.setLayer(querycontainer.getLayer());
+        		matchSpan.storePayloads(payloadString.toString());
+        		matchSpans.add(matchSpan);
+        */
+        /*
+         * topdocs = searcher.search(new ConstantScoreQuery(corpusQ add
+         * position to list of positions to be considered for later
+         * searches
+         */
+        /*
+        validValues.put(docname,
+        		matchSpan.getPayload(config.getPrefix()));
+        }
+        */
 
 
-	// Todo: API made by add() typisiert für queries, strings
+        // Todo: API made by add() typisiert für queries, strings
 
-	// SpanPayloadCheckQuery for sentences!
+        // SpanPayloadCheckQuery for sentences!
 
-	/* Support regular expression in SpanSegmentQuery */
-	// new Regexp();
-	// new Term();
+        /* Support regular expression in SpanSegmentQuery */
+        // new Regexp();
+        // new Term();
 
-	/*
-	  Vielleicht: spanSegmentQuery(new Term(), new Wildcard(), new Regex());
-	 */
+        /*
+          Vielleicht: spanSegmentQuery(new Term(), new Wildcard(), new Regex());
+         */
 
-	// And Not ->
-	//	SpanTermDiffQuery
+        // And Not ->
+        //	SpanTermDiffQuery
 
-	/*
-	SpanNearQuery poquery = new SpanNearQuery(
+        /*
+        SpanNearQuery poquery = new SpanNearQuery(
 
-	);
-	*/
+        );
+        */
 
-	reader.close();
+        reader.close();
 
 
     };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
index a653358..162e5eb 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKrillDocument.java
@@ -22,6 +22,7 @@
 
     private class KrillRealDocument extends AbstractDocument {};
 
+
     @Test
     public void createDocument () throws IOException {
         KrillRealDocument krd = new KrillRealDocument();
@@ -48,8 +49,7 @@
         try {
             krd.setUID("zzz");
         }
-        catch (NumberFormatException e) {
-        };
+        catch (NumberFormatException e) {};
         assertEquals(561, krd.getUID());
 
         krd.setTitle("An Example");
@@ -61,7 +61,7 @@
         krd.setPrimaryData("We don't need no education");
         assertEquals("We don't need no education", krd.getPrimaryData());
         assertEquals("don't need no education", krd.getPrimaryData(3));
-        assertEquals("do", krd.getPrimaryData(3,5));
+        assertEquals("do", krd.getPrimaryData(3, 5));
         assertEquals(26, krd.getPrimaryDataLength());
 
         krd.setPrimaryData("abc");
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
index f909b42..653549a 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestKrillIndex.java
@@ -36,10 +36,9 @@
         fd.addInt("zahl1", 56);
         fd.addInt("zahl2", "58");
         fd.addText("teaser", "Das ist der Name der Rose");
-        fd.addTV("base",
-                 "ich bau",
-                 "[(0-3)s:ich|l:ich|p:PPER|-:sentences$<i>2]" +
-                 "[(4-7)s:bau|l:bauen|p:VVFIN]");
+        fd.addTV("base", "ich bau",
+                "[(0-3)s:ich|l:ich|p:PPER|-:sentences$<i>2]"
+                        + "[(4-7)s:bau|l:bauen|p:VVFIN]");
         ki.addDoc(fd);
 
         fd = new FieldDocument();
@@ -53,7 +52,7 @@
         mtts.addMultiTermToken("s:sind#4-8", "l:sein", "p:VVFIN");
         mtts.addMeta("sentences", (int) 5);
         fd.addTV("base", "wir sind", mtts);
-        
+
         ki.addDoc(fd);
 
         /* Save documents */
@@ -68,10 +67,8 @@
         fd.addInt("zahl1", 59);
         fd.addInt("zahl2", 65);
         fd.addText("teaser", "Noch ein Versuch");
-        fd.addTV("base",
-                 "ich bau",
-                 "[(0-3)s:der|l:der|p:DET|-:sentences$<i>3]" +
-                 "[(4-8)s:baum|l:baum|p:NN]");
+        fd.addTV("base", "ich bau", "[(0-3)s:der|l:der|p:DET|-:sentences$<i>3]"
+                + "[(4-8)s:baum|l:baum|p:NN]");
         ki.addDoc(fd);
 
         /* Save documents */
@@ -84,16 +81,17 @@
         // ki.search();
     };
 
+
     @Test
     public void indexAlteration () throws IOException {
         KrillIndex ki = new KrillIndex();
-        
+
         assertEquals(0, ki.numberOf("base", "documents"));
 
         FieldDocument fd = new FieldDocument();
         fd.addString("name", "Peter");
         ki.addDoc(fd);
-        
+
         assertEquals(0, ki.numberOf("base", "documents"));
 
         fd = new FieldDocument();
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
index 1b856c9..fcc7ebf 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchCollector.java
@@ -38,52 +38,41 @@
 
     @Test
     public void indexExample1 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addString("ID", "doc-1");
-	fd.addString("UID", "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]" +
-		 "[(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]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addString("ID", "doc-1");
+        fd.addString("UID", "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]" + "[(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]");
+        ki.addDoc(fd);
 
-	fd = new FieldDocument();
-	fd.addString("ID", "doc-2");
-	fd.addString("UID", "2");
-	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]");
-	ki.addDoc(fd);
+        fd = new FieldDocument();
+        fd.addString("ID", "doc-2");
+        fd.addString("UID", "2");
+        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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
+        SpanQuery sq;
 
-	sq = new SpanTermQuery(new Term("base", "s:b"));
-    Krill krill = new Krill(sq);
-    krill.getMeta().setCount((short) 10);
-	MatchCollector mc = ki.collect(
-	  krill,
-	  new MatchCollector()
-	);
+        sq = new SpanTermQuery(new Term("base", "s:b"));
+        Krill krill = new Krill(sq);
+        krill.getMeta().setCount((short) 10);
+        MatchCollector mc = ki.collect(krill, new MatchCollector());
 
-	assertEquals(mc.getTotalResults(), 5);
-	assertEquals(mc.getTotalResultDocs(), 2);
+        assertEquals(mc.getTotalResults(), 5);
+        assertEquals(mc.getTotalResultDocs(), 2);
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
index d3184ae..a77a82b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -20,7 +20,6 @@
 import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.util.QueryException;
 
-
 import de.ids_mannheim.korap.index.FieldDocument;
 
 @RunWith(JUnit4.class)
@@ -28,765 +27,556 @@
 
     @Test
     public void identifierExample1 () throws IOException, QueryException {
-	MatchIdentifier id = new MatchIdentifier("match-c1!d1-p4-20");
-	assertEquals(id.getCorpusID(), "c1");
-	assertEquals(id.getDocID(), "d1");
-	assertEquals(id.getStartPos(), 4);
-	assertEquals(id.getEndPos(), 20);
+        MatchIdentifier id = new MatchIdentifier("match-c1!d1-p4-20");
+        assertEquals(id.getCorpusID(), "c1");
+        assertEquals(id.getDocID(), "d1");
+        assertEquals(id.getStartPos(), 4);
+        assertEquals(id.getEndPos(), 20);
 
-	assertEquals(id.toString(), "match-c1!d1-p4-20");
-	id.addPos(10,14,2);
-	assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14");
-	id.addPos(11,12,5);
-	assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
-	// Ignore
-	id.addPos(11,12,-8);
-	assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
-	id.addPos(11,-12,8);
-	assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
-	id.addPos(-11,12,8);
-	assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
+        assertEquals(id.toString(), "match-c1!d1-p4-20");
+        id.addPos(10, 14, 2);
+        assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14");
+        id.addPos(11, 12, 5);
+        assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
+        // Ignore
+        id.addPos(11, 12, -8);
+        assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
+        id.addPos(11, -12, 8);
+        assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
+        id.addPos(-11, 12, 8);
+        assertEquals(id.toString(), "match-c1!d1-p4-20(2)10-14(5)11-12");
 
-	id = new MatchIdentifier("matc-c1!d1-p4-20");
-	assertNull(id.toString());
-	id = new MatchIdentifier("match-d1-p4-20");
-	assertNull(id.getCorpusID());
-	assertEquals(id.getDocID(), "d1");
-	id = new MatchIdentifier("match-p4-20");
-	assertNull(id.toString());
+        id = new MatchIdentifier("matc-c1!d1-p4-20");
+        assertNull(id.toString());
+        id = new MatchIdentifier("match-d1-p4-20");
+        assertNull(id.getCorpusID());
+        assertEquals(id.getDocID(), "d1");
+        id = new MatchIdentifier("match-p4-20");
+        assertNull(id.toString());
 
-	id = new MatchIdentifier("match-c1!d1-p4-20");
-	assertEquals(id.toString(), "match-c1!d1-p4-20");
+        id = new MatchIdentifier("match-c1!d1-p4-20");
+        assertEquals(id.toString(), "match-c1!d1-p4-20");
 
-	id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8");
-	assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
+        id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8");
+        assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
 
-	id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10");
-	assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
+        id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10");
+        assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8");
 
-	id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6");
-	assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4");
+        id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6");
+        assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4");
 
-	id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8");
-	assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
+        id = new MatchIdentifier(
+                "match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8");
+        assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
 
-	id = new MatchIdentifier("match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8(5)9--10");
-	assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
+        id = new MatchIdentifier(
+                "match-c1!d1-p4-20(5)7-8(-2)9-10(2)3-4(3)-5-6(4)7-8(5)9--10");
+        assertEquals(id.toString(), "match-c1!d1-p4-20(5)7-8(2)3-4(4)7-8");
     };
 
+
     @Test
     public void posIdentifierExample1 () throws IOException {
-	PosIdentifier id = new PosIdentifier();
-	id.setCorpusID("c1");
-	id.setDocID("d1");
-	id.setPos(8);
-	assertEquals(id.getCorpusID(), "c1");
-	assertEquals(id.getDocID(), "d1");
-	assertEquals(id.getPos(), 8);
-	assertEquals(id.toString(), "word-c1!d1-p8");
+        PosIdentifier id = new PosIdentifier();
+        id.setCorpusID("c1");
+        id.setDocID("d1");
+        id.setPos(8);
+        assertEquals(id.getCorpusID(), "c1");
+        assertEquals(id.getDocID(), "d1");
+        assertEquals(id.getPos(), 8);
+        assertEquals(id.toString(), "word-c1!d1-p8");
     };
 
+
     @Test
     public void indexExample1 () throws IOException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("tokens");
-	Krill ks = new Krill(
-	    kq._(2,kq.seq(kq.seg("s:b")).append(kq._(kq.seg("s:a"))))
-        );
-	Result kr = ki.search(ks);
+        QueryBuilder kq = new QueryBuilder("tokens");
+        Krill ks = new Krill(kq._(2,
+                kq.seq(kq.seg("s:b")).append(kq._(kq.seg("s:a")))));
+        Result kr = ki.search(ks);
 
-	assertEquals("totalResults", kr.getTotalResults(),    1);
-	assertEquals("StartPos (0)", kr.getMatch(0).startPos, 7);
-	assertEquals("EndPos (0)",   kr.getMatch(0).endPos,   9);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("StartPos (0)", kr.getMatch(0).startPos, 7);
+        assertEquals("EndPos (0)", kr.getMatch(0).endPos, 9);
 
-	Match km = kr.getMatch(0);
+        Match km = kr.getMatch(0);
 
-	assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", km.getSnippetBrackets());
-	assertEquals("ID (0)", "match-c1!d1-p7-9(2)7-8(1)8-8", km.getID());
+        assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c",
+                km.getSnippetBrackets());
+        assertEquals("ID (0)", "match-c1!d1-p7-9(2)7-8(1)8-8", km.getID());
     };
 
+
     @Test
     public void indexExample2 () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatch("match-c1!d1-p7-9(0)8-8(2)7-8");
+        Match km = ki.getMatch("match-c1!d1-p7-9(0)8-8(2)7-8");
 
-	assertEquals("StartPos (0)", 7, km.getStartPos());
-	assertEquals("EndPos (0)", 9, km.getEndPos());
+        assertEquals("StartPos (0)", 7, km.getStartPos());
+        assertEquals("EndPos (0)", 9, km.getEndPos());
 
-	assertEquals("SnippetBrackets (0)",
-		     "... [{2:b{a}}] ...",
-		     km.getSnippetBrackets());
+        assertEquals("SnippetBrackets (0)", "... [{2:b{a}}] ...",
+                km.getSnippetBrackets());
 
-	assertEquals("ID (0)", "match-c1!d1-p7-9(0)8-8(2)7-8", km.getID());
+        assertEquals("ID (0)", "match-c1!d1-p7-9(0)8-8(2)7-8", km.getID());
 
-	km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8",
-			     "tokens",
-			     "f",
-			     "m",
-			     false,
-			     false);
+        km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8", "tokens", "f",
+                "m", false, false);
 
-	assertEquals("SnippetBrackets (1)",
-		     "... [{f/m:acht:b}{f/m:neun:a}] ...",
-		     km.getSnippetBrackets());
+        assertEquals("SnippetBrackets (1)",
+                "... [{f/m:acht:b}{f/m:neun:a}] ...", km.getSnippetBrackets());
 
 
-	/*
-	km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8",
-			     "tokens",
-			     "f",
-			     null,
-			     false,
-			     false);
+        /*
+        km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8",
+        		     "tokens",
+        		     "f",
+        		     null,
+        		     false,
+        		     false);
 
-	System.err.println(km.toJSON());
-	*/
+        System.err.println(km.toJSON());
+        */
 
-	
-	km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8",
-			     "tokens",
-			     "f",
-			     "m",
-			     false,
-			     true);
 
-	assertEquals("SnippetBrackets (2)",
-		     "... [{2:{f/m:acht:b}{{f/m:neun:a}}}] ...",
-		     km.getSnippetBrackets());
+        km = ki.getMatchInfo("match-c1!d1-p7-9(0)8-8(2)7-8", "tokens", "f",
+                "m", false, true);
 
-	km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
-			     "tokens",
-			     "f",
-			     "m",
-			     false,
-			     true);
+        assertEquals("SnippetBrackets (2)",
+                "... [{2:{f/m:acht:b}{{f/m:neun:a}}}] ...",
+                km.getSnippetBrackets());
 
-	assertEquals("SnippetBrackets (3)",
-		     "... [{2:{f/m:acht:b}{4:{f/m:neun:a}}}] ...",
-		     km.getSnippetBrackets());
+        km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens", "f",
+                "m", false, true);
 
-	km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
-			     "tokens",
-			     "f",
-			     null,
-			     false,
-			     true);
+        assertEquals("SnippetBrackets (3)",
+                "... [{2:{f/m:acht:b}{4:{f/m:neun:a}}}] ...",
+                km.getSnippetBrackets());
 
-	assertEquals("SnippetBrackets (4)",
-		     "... [{2:{f/m:acht:{f/y:eight:b}}{4:{f/m:neun:{f/y:nine:a}}}}] ...",
-		     km.getSnippetBrackets());
+        km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens", "f",
+                null, false, true);
 
-	assertEquals("SnippetHTML (4)",
-		     "<span class=\"context-left\">"+
-		     "<span class=\"more\">"+
-		     "</span>"+
-		     "</span>"+
-		     "<mark>"+
-		     "<mark class=\"class-2 level-0\">"+
-		     "<span title=\"f/m:acht\">"+
-		     "<span title=\"f/y:eight\">"+
-		     "b"+
-		     "</span>"+
-		     "</span>"+
-		     "<mark class=\"class-4 level-1\">"+
-		     "<span title=\"f/m:neun\">"+
-		     "<span title=\"f/y:nine\">"+
-		     "a"+
-		     "</span>"+
-		     "</span>"+
-		     "</mark>"+
-		     "</mark>"+
-		     "</mark>"+
-		     "<span class=\"context-right\">"+
-		     "<span class=\"more\">"+
-		     "</span>"+
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals(
+                "SnippetBrackets (4)",
+                "... [{2:{f/m:acht:{f/y:eight:b}}{4:{f/m:neun:{f/y:nine:a}}}}] ...",
+                km.getSnippetBrackets());
+
+        assertEquals("SnippetHTML (4)", "<span class=\"context-left\">"
+                + "<span class=\"more\">" + "</span>" + "</span>" + "<mark>"
+                + "<mark class=\"class-2 level-0\">"
+                + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+                + "b" + "</span>" + "</span>"
+                + "<mark class=\"class-4 level-1\">"
+                + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+                + "a" + "</span>" + "</span>" + "</mark>" + "</mark>"
+                + "</mark>" + "<span class=\"context-right\">"
+                + "<span class=\"more\">" + "</span>" + "</span>",
+                km.getSnippetHTML());
     };
 
 
     @Test
     public void indexExample3 () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     true);
+        Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens",
+                null, null, false, true);
 
 
-	assertEquals("SnippetHTML (1)",
-		     "<span class=\"context-left\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>" +
-		     "<mark>" +
-		     "<mark class=\"class-2 level-0\">" +
-		     "<span title=\"f/m:acht\">" +
-		     "<span title=\"f/y:eight\">" +
-		     "<span title=\"it/is:8\">" +
-		     "<span title=\"x/o:achtens\">" +
-		     "b" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "<mark class=\"class-4 level-1\">" +
-		     "<span title=\"f/m:neun\">" +
-		     "<span title=\"f/y:nine\">" +
-		     "<span title=\"it/is:9\">" +
-		     "<span title=\"x/o:neuntens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</mark>" +
-		     "</mark>" +
-		     "</mark>" +
-		     "<span class=\"context-right\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
+                + "<span class=\"more\">" + "</span>" + "</span>" + "<mark>"
+                + "<mark class=\"class-2 level-0\">"
+                + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+                + "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
+                + "b" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "<mark class=\"class-4 level-1\">"
+                + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+                + "<span title=\"it/is:9\">" + "<span title=\"x/o:neuntens\">"
+                + "a" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "</mark>" + "</mark>" + "</mark>"
+                + "<span class=\"context-right\">" + "<span class=\"more\">"
+                + "</span>" + "</span>", km.getSnippetHTML());
     };
 
+
     @Test
     public void indexExample4 () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false);
+        Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens",
+                null, null, false, false);
 
 
-	assertEquals("SnippetHTML (1)",
-		     "<span class=\"context-left\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>" +
-		     "<mark>" +
-		     "<span title=\"f/m:acht\">" +
-		     "<span title=\"f/y:eight\">" +
-		     "<span title=\"it/is:8\">" +
-		     "<span title=\"x/o:achtens\">" +
-		     "b" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "<span title=\"f/m:neun\">" +
-		     "<span title=\"f/y:nine\">" +
-		     "<span title=\"it/is:9\">" +
-		     "<span title=\"x/o:neuntens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</mark>" +
-		     "<span class=\"context-right\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
+                + "<span class=\"more\">" + "</span>" + "</span>" + "<mark>"
+                + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+                + "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
+                + "b" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+                + "<span title=\"it/is:9\">" + "<span title=\"x/o:neuntens\">"
+                + "a" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "</mark>" + "<span class=\"context-right\">"
+                + "<span class=\"more\">" + "</span>" + "</span>",
+                km.getSnippetHTML());
     };
 
+
     @Test
     public void indexExample5Spans () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8",
-			     "tokens",
-			     null,
-			     null,
-			     true,
-			     false);
+        Match km = ki.getMatchInfo("match-c1!d1-p7-9(4)8-8(2)7-8", "tokens",
+                null, null, true, false);
 
 
-	assertEquals("SnippetBrackets (1)",
-		     "... [{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}] ...",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (1)",
+                "... [{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}] ...",
+                km.getSnippetBrackets());
     };
 
+
     @Test
     public void indexExample6Spans () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
-			     "tokens",
-			     null,
-			     null,
-			     true,
-			     false);
+        Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8", "tokens",
+                null, null, true, false);
 
 
-	assertEquals("SnippetBrackets (1)",
-		     "... [{x/tag:{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}{f/m:zehn:{f/y:ten:{it/is:10:{x/o:zehntens:c}}}}}]",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (1)",
+                "... [{x/tag:{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}{f/m:zehn:{f/y:ten:{it/is:10:{x/o:zehntens:c}}}}}]",
+                km.getSnippetBrackets());
     };
 
+
     @Test
     public void indexExample7Spans () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8",
-			     "tokens",
-			     null,
-			     null,
-			     true,
-			     true);
+        Match km = ki.getMatchInfo("match-c1!d1-p7-10(4)8-8(2)7-8", "tokens",
+                null, null, true, true);
 
 
-	assertEquals("SnippetBrackets (1)",
-		     "... [{x/tag:{2:{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{4:{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}}}{f/m:zehn:{f/y:ten:{it/is:10:{x/o:zehntens:c}}}}}]",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (1)",
+                "... [{x/tag:{2:{f/m:acht:{f/y:eight:{it/is:8:{x/o:achtens:b}}}}{4:{f/m:neun:{f/y:nine:{it/is:9:{x/o:neuntens:a}}}}}}{f/m:zehn:{f/y:ten:{it/is:10:{x/o:zehntens:c}}}}}]",
+                km.getSnippetBrackets());
 
-	assertEquals("SnippetHTML (1)",
-		     "<span class=\"context-left\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>" +
-		     "<mark>" +
-		     "<span title=\"x/tag\">" +
-		     "<mark class=\"class-2 level-0\">" +
-		     "<span title=\"f/m:acht\">" +
-		     "<span title=\"f/y:eight\">" +
-		     "<span title=\"it/is:8\">" +
-		     "<span title=\"x/o:achtens\">" +
-		     "b" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "<mark class=\"class-4 level-1\">" +
-		     "<span title=\"f/m:neun\">" +
-		     "<span title=\"f/y:nine\">" +
-		     "<span title=\"it/is:9\">" +
-		     "<span title=\"x/o:neuntens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</mark>" +
-		     "</mark>" +
-		     "<span title=\"f/m:zehn\">" +
-		     "<span title=\"f/y:ten\">" +
-		     "<span title=\"it/is:10\">" +
-		     "<span title=\"x/o:zehntens\">" +
-		     "c" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</mark>" +
-		     "<span class=\"context-right\">" +
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals("SnippetHTML (1)", "<span class=\"context-left\">"
+                + "<span class=\"more\">" + "</span>" + "</span>" + "<mark>"
+                + "<span title=\"x/tag\">" + "<mark class=\"class-2 level-0\">"
+                + "<span title=\"f/m:acht\">" + "<span title=\"f/y:eight\">"
+                + "<span title=\"it/is:8\">" + "<span title=\"x/o:achtens\">"
+                + "b" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "<mark class=\"class-4 level-1\">"
+                + "<span title=\"f/m:neun\">" + "<span title=\"f/y:nine\">"
+                + "<span title=\"it/is:9\">" + "<span title=\"x/o:neuntens\">"
+                + "a" + "</span>" + "</span>" + "</span>" + "</span>"
+                + "</mark>" + "</mark>" + "<span title=\"f/m:zehn\">"
+                + "<span title=\"f/y:ten\">" + "<span title=\"it/is:10\">"
+                + "<span title=\"x/o:zehntens\">" + "c" + "</span>" + "</span>"
+                + "</span>" + "</span>" + "</span>" + "</mark>"
+                + "<span class=\"context-right\">" + "</span>",
+                km.getSnippetHTML());
     };
 
+
     @Test
     public void indexExample6Relations () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.commit();
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d1-p0-5(4)8-8(2)7-8",
-			     "tokens",
-			     "x",
-			     null,
-			     true,
-			     false);
+        Match km = ki.getMatchInfo("match-c1!d1-p0-5(4)8-8(2)7-8", "tokens",
+                "x", null, true, false);
 
-	assertEquals("SnippetBrackets (1)",
-		     "[{x/rel:a>3:{x/o:erstens:a}}{x/o:zweitens:b}{x/o:drittens:c}{#3:{x/o:viertens:a}}{x/o:fünftens:b}] ...",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (1)",
+                "[{x/rel:a>3:{x/o:erstens:a}}{x/o:zweitens:b}{x/o:drittens:c}{#3:{x/o:viertens:a}}{x/o:fünftens:b}] ...",
+                km.getSnippetBrackets());
 
-	assertEquals("SnippetBrackets (1)",
-		     "<span class=\"context-left\">" +
-		     "</span>" +
-		     "<mark>" +
-		     "<span xlink:title=\"x/rel:a\" " +
-		     "xlink:type=\"simple\" " +
-		     "xlink:href=\"#word-c1!d1-p3\">" +
-		     "<span title=\"x/o:erstens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "<span title=\"x/o:zweitens\">" +
-		     "b" +
-		     "</span>" +
-		     "<span title=\"x/o:drittens\">" +
-		     "c" +
-		     "</span>" +
-		     "<span xml:id=\"word-c1!d1-p3\">" +
-		     "<span title=\"x/o:viertens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "<span title=\"x/o:fünftens\">" +
-		     "b" +
-		     "</span>" +
-		     "</mark>" +
-		     "<span class=\"context-right\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">"
+                + "</span>" + "<mark>" + "<span xlink:title=\"x/rel:a\" "
+                + "xlink:type=\"simple\" " + "xlink:href=\"#word-c1!d1-p3\">"
+                + "<span title=\"x/o:erstens\">" + "a" + "</span>" + "</span>"
+                + "<span title=\"x/o:zweitens\">" + "b" + "</span>"
+                + "<span title=\"x/o:drittens\">" + "c" + "</span>"
+                + "<span xml:id=\"word-c1!d1-p3\">"
+                + "<span title=\"x/o:viertens\">" + "a" + "</span>" + "</span>"
+                + "<span title=\"x/o:fünftens\">" + "b" + "</span>" + "</mark>"
+                + "<span class=\"context-right\">" + "<span class=\"more\">"
+                + "</span>" + "</span>", km.getSnippetHTML());
 
-	km = ki.getMatchInfo("match-c1!d1-p0-5(7)2-3(4)8-8(2)7-8",
-			     "tokens",
-			     "x",
-			     null,
-			     true,
-			     true);
+        km = ki.getMatchInfo("match-c1!d1-p0-5(7)2-3(4)8-8(2)7-8", "tokens",
+                "x", null, true, true);
 
-	assertEquals("SnippetBrackets (1)",
-		     "<span class=\"context-left\">" +
-		     "</span>" +
-		     "<mark>" +
-		     "<span xlink:title=\"x/rel:a\" " +
-		     "xlink:type=\"simple\" " +
-		     "xlink:href=\"#word-c1!d1-p3\">" +
-		     "<span title=\"x/o:erstens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "<span title=\"x/o:zweitens\">" +
-		     "b" +
-		     "</span>" +
-		     "<mark class=\"class-7 level-0\">" +
-		     "<span title=\"x/o:drittens\">" +
-		     "c" +
-		     "</span>" +
-		     "<span xml:id=\"word-c1!d1-p3\">" +
-		     "<span title=\"x/o:viertens\">" +
-		     "a" +
-		     "</span>" +
-		     "</span>" +
-		     "</mark>" +
-		     "<span title=\"x/o:fünftens\">" +
-		     "b" +
-		     "</span>" +
-		     "</mark>" +
-		     "<span class=\"context-right\">" +
-		     "<span class=\"more\">" +
-		     "</span>" +
-		     "</span>",
-		     km.getSnippetHTML());
+        assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">"
+                + "</span>" + "<mark>" + "<span xlink:title=\"x/rel:a\" "
+                + "xlink:type=\"simple\" " + "xlink:href=\"#word-c1!d1-p3\">"
+                + "<span title=\"x/o:erstens\">" + "a" + "</span>" + "</span>"
+                + "<span title=\"x/o:zweitens\">" + "b" + "</span>"
+                + "<mark class=\"class-7 level-0\">"
+                + "<span title=\"x/o:drittens\">" + "c" + "</span>"
+                + "<span xml:id=\"word-c1!d1-p3\">"
+                + "<span title=\"x/o:viertens\">" + "a" + "</span>" + "</span>"
+                + "</mark>" + "<span title=\"x/o:fünftens\">" + "b" + "</span>"
+                + "</mark>" + "<span class=\"context-right\">"
+                + "<span class=\"more\">" + "</span>" + "</span>",
+                km.getSnippetHTML());
     };
 
 
     @Test
-    public void indexExample7SentenceExpansion () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc());
-	ki.addDoc(createSimpleFieldDoc2());
-	ki.addDoc(createSimpleFieldDoc3());
-	ki.addDoc(createSimpleFieldDoc4());
-	ki.commit();
-	Match km;
+    public void indexExample7SentenceExpansion () throws IOException,
+            QueryException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc());
+        ki.addDoc(createSimpleFieldDoc2());
+        ki.addDoc(createSimpleFieldDoc3());
+        ki.addDoc(createSimpleFieldDoc4());
+        ki.commit();
+        Match km;
 
-	km = ki.getMatchInfo("match-c1!d1-p3-4",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false);
+        km = ki.getMatchInfo("match-c1!d1-p3-4", "tokens", null, null, false,
+                false);
 
-	assertEquals("... [{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}] ...",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "... [{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}] ...",
+                km.getSnippetBrackets());
 
 
-	km = ki.getMatchInfo("match-c1!d1-p3-4",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false,
-			     true); // extendToSentence
+        km = ki.getMatchInfo("match-c1!d1-p3-4", "tokens", null, null, false,
+                false, true); // extendToSentence
 
-	assertEquals("[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}]",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}]",
+                km.getSnippetBrackets());
 
-	km = ki.getMatchInfo("match-c1!d3-p3-4",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false,
-			     true); // extendToSentence
+        km = ki.getMatchInfo("match-c1!d3-p3-4", "tokens", null, null, false,
+                false, true); // extendToSentence
 
-	assertEquals("[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:cc}}}} {f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:aa}}}} {f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:bb}}}}]",
-		     km.getSnippetBrackets());
+        assertEquals(
+                "[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:cc}}}} {f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:aa}}}} {f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:bb}}}}]",
+                km.getSnippetBrackets());
 
 
-	km = ki.getMatchInfo("match-c1!d4-p4-6",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false,
-			     true); // extendToSentence
-	assertEquals("[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}{f/m:sechs:{f/y:six:{it/is:6:{x/o:sechstens:c}}}}{f/m:sieben:{f/y:seven:{it/is:7:{x/o:siebtens:a}}}}]",
-		     km.getSnippetBrackets());
+        km = ki.getMatchInfo("match-c1!d4-p4-6", "tokens", null, null, false,
+                false, true); // extendToSentence
+        assertEquals(
+                "[{f/m:drei:{f/y:three:{it/is:3:{x/o:drittens:c}}}}{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}{f/m:fuenf:{f/y:five:{it/is:5:{x/o:fünftens:b}}}}{f/m:sechs:{f/y:six:{it/is:6:{x/o:sechstens:c}}}}{f/m:sieben:{f/y:seven:{it/is:7:{x/o:siebtens:a}}}}]",
+                km.getSnippetBrackets());
 
     };
 
-    @Test
-    public void indexExample7Dependencies () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc2());
-	ki.commit();
-
-	Match km = ki.getMatchInfo("match-c1!d1-p0-4",
-			     "tokens",
-			     null,
-			     null,
-			     true,
-			     true);
-
-
-	assertEquals("SnippetHTML (2)",
-		     "<span class=\"context-left\">" +
-		     "</span>" +
-		     "<mark>"+
-		     "<span xlink:title=\"x/rel:a\" xlink:type=\"simple\" xlink:href=\"#word-c1!d1-p3\">"+
-		     "<span title=\"f/m:eins\">"+
-		     "<span title=\"f/y:one\">"+
-		     "<span title=\"it/is:1\">" +
-		     "<span title=\"x/o:erstens\">a</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "</span>" +
-		     "<span xlink:title=\"x/rel:b\" xlink:type=\"simple\" xlink:href=\"#word-c1!d1-p3\">"+
-		     "<span title=\"f/m:zwei\">"+
-		     "<span title=\"f/y:two\">"+
-		     "<span title=\"it/is:2\">"+
-		     "<span title=\"x/o:zweitens\">b</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "<span title=\"f/m:drei\">"+
-		     "<span title=\"f/y:three\">"+
-		     "<span title=\"it/is:3\">"+
-		     "<span title=\"x/o:drittens\">c</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "<span xml:id=\"word-c1!d1-p3\">"+
-		     "<span title=\"f/m:vier\">"+
-		     "<span title=\"f/y:four\">"+
-		     "<span title=\"it/is:4\">"+
-		     "<span title=\"x/o:viertens\">a</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</span>"+
-		     "</mark>"+
-		     "<span class=\"context-right\">"+
-		     "<span class=\"more\">"+
-		     "</span>"+
-		     "</span>",
-		     km.getSnippetHTML());
-    };
-
 
     @Test
-    public void indexExampleMultipleFoundries () throws IOException, QueryException {
-	KrillIndex ki = new KrillIndex();
-	ki.addDoc(createSimpleFieldDoc4());
-	ki.commit();
+    public void indexExample7Dependencies () throws IOException, QueryException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc2());
+        ki.commit();
 
-	Match km = ki.getMatchInfo("match-c1!d4-p3-9",
-					"tokens",
-					"f",
-					"m",
-					false,
-					false);
-	assertEquals("f:m info",
-		     km.getSnippetBrackets(),
-		     "... [{f/m:vier:a}{f/m:fuenf:b}{f/m:sechs:c}{f/m:sieben:a}{f/m:acht:b}{f/m:neun:a}] ...");
-
-	km = ki.getMatchInfo("match-c1!d4-p3-9",
-			     "tokens",
-			     "f",
-			     null,
-			     false,
-			     false);
-	assertEquals("f info",
-		     km.getSnippetBrackets(),
-		     "... [{f/m:vier:{f/y:four:a}}{f/m:fuenf:{f/y:five:b}}{f/m:sechs:{f/y:six:c}}{f/m:sieben:{f/y:seven:a}}{f/m:acht:{f/y:eight:b}}{f/m:neun:{f/y:nine:a}}] ..."
-		     );
+        Match km = ki.getMatchInfo("match-c1!d1-p0-4", "tokens", null, null,
+                true, true);
 
 
-	km = ki.getMatchInfo("match-c1!d4-p3-4",
-			     "tokens",
-			     null,
-			     null,
-			     false,
-			     false);
-	assertEquals("all info",
-		     km.getSnippetBrackets(),
-		     "... [{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}] ..."
-		     );
-
-	ArrayList<String> foundryList = new ArrayList<>(2);
-	foundryList.add("f");
-	foundryList.add("x");
-
-	km = ki.getMatchInfo("match-c1!d4-p3-4",
-			     "tokens",
-			     true,
-			     foundryList,
-			     (ArrayList<String>) null,
-			     false,
-			     false,
-			     false);
-	assertEquals("f|x info",
-		     km.getSnippetBrackets(),
-		     "... [{f/m:vier:{f/y:four:{x/o:viertens:a}}}] ..."
-		     );
-
-	foundryList.clear();
-	foundryList.add("y");
-	foundryList.add("x");
-
-	km = ki.getMatchInfo("match-c1!d4-p3-4",
-			     "tokens",
-			     true,
-			     foundryList,
-			     (ArrayList<String>) null,
-			     false,
-			     false,
-			     false);
-	assertEquals("y|x info",
-		     km.getSnippetBrackets(),
-		     "... [{x/o:viertens:a}] ..."
-		     );
-
-
-	foundryList.clear();
-	foundryList.add("f");
-	foundryList.add("it");
-
-	ArrayList<String> layerList = new ArrayList<>(2);
-	layerList.add("is");
-
-	km = ki.getMatchInfo("match-c1!d4-p3-4",
-			     "tokens",
-			     true,
-			     foundryList,
-			     layerList,
-			     false,
-			     false,
-			     false);
-	assertEquals("f|it/is",
-		     km.getSnippetBrackets(),
-		     "... [{it/is:4:a}] ..."
-		     );
-    };
-    
-
-    private FieldDocument createSimpleFieldDoc(){
-	FieldDocument fd = new FieldDocument();
-	fd.addString("corpusID", "c1");
-	fd.addString("ID", "d1");
-	fd.addTV("tokens",
-		 "abcabcabac",
-		 "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]" +
-		 "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#1-2]" +
-		 "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]" +
-		 "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]" +
-		 "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]" +
-		 "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6]" +
-		 "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]" +
-		 "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]" +
-		 "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]" +
-		 "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
-	return fd;
+        assertEquals(
+                "SnippetHTML (2)",
+                "<span class=\"context-left\">"
+                        + "</span>"
+                        + "<mark>"
+                        + "<span xlink:title=\"x/rel:a\" xlink:type=\"simple\" xlink:href=\"#word-c1!d1-p3\">"
+                        + "<span title=\"f/m:eins\">"
+                        + "<span title=\"f/y:one\">"
+                        + "<span title=\"it/is:1\">"
+                        + "<span title=\"x/o:erstens\">a</span>"
+                        + "</span>"
+                        + "</span>"
+                        + "</span>"
+                        + "</span>"
+                        + "<span xlink:title=\"x/rel:b\" xlink:type=\"simple\" xlink:href=\"#word-c1!d1-p3\">"
+                        + "<span title=\"f/m:zwei\">"
+                        + "<span title=\"f/y:two\">"
+                        + "<span title=\"it/is:2\">"
+                        + "<span title=\"x/o:zweitens\">b</span>" + "</span>"
+                        + "</span>" + "</span>" + "</span>"
+                        + "<span title=\"f/m:drei\">"
+                        + "<span title=\"f/y:three\">"
+                        + "<span title=\"it/is:3\">"
+                        + "<span title=\"x/o:drittens\">c</span>" + "</span>"
+                        + "</span>" + "</span>"
+                        + "<span xml:id=\"word-c1!d1-p3\">"
+                        + "<span title=\"f/m:vier\">"
+                        + "<span title=\"f/y:four\">"
+                        + "<span title=\"it/is:4\">"
+                        + "<span title=\"x/o:viertens\">a</span>" + "</span>"
+                        + "</span>" + "</span>" + "</span>" + "</mark>"
+                        + "<span class=\"context-right\">"
+                        + "<span class=\"more\">" + "</span>" + "</span>",
+                km.getSnippetHTML());
     };
 
-    private FieldDocument createSimpleFieldDoc2(){
-	FieldDocument fd = new FieldDocument();
-	fd.addString("corpusID", "c1");
-	fd.addString("ID", "d1");
-	fd.addTV("tokens",
-		 "abcabcabac",
-		 "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]" +
-		 "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|>:x/rel:b$<i>4|_1#1-2]" +
-		 "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]" +
-		 "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]" +
-		 "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]" +
-		 "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6]" +
-		 "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]" +
-		 "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]" +
-		 "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]" +
-		 "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
-	return fd;
+
+    @Test
+    public void indexExampleMultipleFoundries () throws IOException,
+            QueryException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createSimpleFieldDoc4());
+        ki.commit();
+
+        Match km = ki.getMatchInfo("match-c1!d4-p3-9", "tokens", "f", "m",
+                false, false);
+        assertEquals(
+                "f:m info",
+                km.getSnippetBrackets(),
+                "... [{f/m:vier:a}{f/m:fuenf:b}{f/m:sechs:c}{f/m:sieben:a}{f/m:acht:b}{f/m:neun:a}] ...");
+
+        km = ki.getMatchInfo("match-c1!d4-p3-9", "tokens", "f", null, false,
+                false);
+        assertEquals(
+                "f info",
+                km.getSnippetBrackets(),
+                "... [{f/m:vier:{f/y:four:a}}{f/m:fuenf:{f/y:five:b}}{f/m:sechs:{f/y:six:c}}{f/m:sieben:{f/y:seven:a}}{f/m:acht:{f/y:eight:b}}{f/m:neun:{f/y:nine:a}}] ...");
+
+
+        km = ki.getMatchInfo("match-c1!d4-p3-4", "tokens", null, null, false,
+                false);
+        assertEquals("all info", km.getSnippetBrackets(),
+                "... [{f/m:vier:{f/y:four:{it/is:4:{x/o:viertens:a}}}}] ...");
+
+        ArrayList<String> foundryList = new ArrayList<>(2);
+        foundryList.add("f");
+        foundryList.add("x");
+
+        km = ki.getMatchInfo("match-c1!d4-p3-4", "tokens", true, foundryList,
+                (ArrayList<String>) null, false, false, false);
+        assertEquals("f|x info", km.getSnippetBrackets(),
+                "... [{f/m:vier:{f/y:four:{x/o:viertens:a}}}] ...");
+
+        foundryList.clear();
+        foundryList.add("y");
+        foundryList.add("x");
+
+        km = ki.getMatchInfo("match-c1!d4-p3-4", "tokens", true, foundryList,
+                (ArrayList<String>) null, false, false, false);
+        assertEquals("y|x info", km.getSnippetBrackets(),
+                "... [{x/o:viertens:a}] ...");
+
+
+        foundryList.clear();
+        foundryList.add("f");
+        foundryList.add("it");
+
+        ArrayList<String> layerList = new ArrayList<>(2);
+        layerList.add("is");
+
+        km = ki.getMatchInfo("match-c1!d4-p3-4", "tokens", true, foundryList,
+                layerList, false, false, false);
+        assertEquals("f|it/is", km.getSnippetBrackets(),
+                "... [{it/is:4:a}] ...");
     };
 
-    private FieldDocument createSimpleFieldDoc3(){
-	FieldDocument fd = new FieldDocument();
-	fd.addString("corpusID", "c1");
-	fd.addString("ID", "d3");
-	fd.addTV("tokens",
-		 "aa bb cc aa bb cc aa bb aa cc ",
-		 "[(0-2)s:aa|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-2|-:t$<i>10]" +
-		 "[(3-5)s:bb|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#3-5]" +
-		 "[(6-8)s:cc|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#6-8|<>:s#6-14$<i>5]" +
-		 "[(9-11)s:aa|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#9-11]" +
-		 "[(12-14)s:bb|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#12-14]" +
-		 "[(15-17)s:cc|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#15-17]" +
-		 "[(18-20)s:aa|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#18-20]" +
-		 "[(21-23)s:bb|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#21-23]" +
-		 "[(24-26)s:aa|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#24-26]" +
-		 "[(27-29)s:cc|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#27-29]");
-	return fd;
+
+    private FieldDocument createSimpleFieldDoc () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("corpusID", "c1");
+        fd.addString("ID", "d1");
+        fd.addTV(
+                "tokens",
+                "abcabcabac",
+                "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]"
+                        + "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#1-2]"
+                        + "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]"
+                        + "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]"
+                        + "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]"
+                        + "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6]"
+                        + "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]"
+                        + "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]"
+                        + "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]"
+                        + "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
+        return fd;
     };
 
-    private FieldDocument createSimpleFieldDoc4(){
-	FieldDocument fd = new FieldDocument();
-	fd.addString("corpusID", "c1");
-	fd.addString("ID", "d4");
-	fd.addTV("tokens",
-		 "abcabcabac",
-		 "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]" +
-		 "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#1-2]" +
-		 "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]" +
-		 "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]" +
-		 "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]" +
-		 "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6|<>:s#5-7$<i>7]" +
-		 "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]" +
-		 "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]" +
-		 "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]" +
-		 "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
-	return fd;
+
+    private FieldDocument createSimpleFieldDoc2 () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("corpusID", "c1");
+        fd.addString("ID", "d1");
+        fd.addTV(
+                "tokens",
+                "abcabcabac",
+                "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]"
+                        + "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|>:x/rel:b$<i>4|_1#1-2]"
+                        + "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]"
+                        + "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]"
+                        + "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]"
+                        + "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6]"
+                        + "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]"
+                        + "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]"
+                        + "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]"
+                        + "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
+        return fd;
+    };
+
+
+    private FieldDocument createSimpleFieldDoc3 () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("corpusID", "c1");
+        fd.addString("ID", "d3");
+        fd.addTV(
+                "tokens",
+                "aa bb cc aa bb cc aa bb aa cc ",
+                "[(0-2)s:aa|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-2|-:t$<i>10]"
+                        + "[(3-5)s:bb|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#3-5]"
+                        + "[(6-8)s:cc|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#6-8|<>:s#6-14$<i>5]"
+                        + "[(9-11)s:aa|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#9-11]"
+                        + "[(12-14)s:bb|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#12-14]"
+                        + "[(15-17)s:cc|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#15-17]"
+                        + "[(18-20)s:aa|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#18-20]"
+                        + "[(21-23)s:bb|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#21-23]"
+                        + "[(24-26)s:aa|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#24-26]"
+                        + "[(27-29)s:cc|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#27-29]");
+        return fd;
+    };
+
+
+    private FieldDocument createSimpleFieldDoc4 () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("corpusID", "c1");
+        fd.addString("ID", "d4");
+        fd.addTV(
+                "tokens",
+                "abcabcabac",
+                "[(0-1)s:a|i:a|f/m:eins|f/y:one|x/o:erstens|it/is:1|>:x/rel:a$<i>4|_0#0-1|-:t$<i>10]"
+                        + "[(1-2)s:b|i:b|f/m:zwei|f/y:two|x/o:zweitens|it/is:2|_1#1-2]"
+                        + "[(2-3)s:c|i:c|f/m:drei|f/y:three|x/o:drittens|it/is:3|_2#2-3|<>:s#2-5$<i>5]"
+                        + "[(3-4)s:a|i:a|f/m:vier|f/y:four|x/o:viertens|it/is:4|<:x/rel:b$<i>1|_3#3-4]"
+                        + "[(4-5)s:b|i:b|f/m:fuenf|f/y:five|x/o:fünftens|it/is:5|_4#4-5]"
+                        + "[(5-6)s:c|i:c|f/m:sechs|f/y:six|x/o:sechstens|it/is:6|_5#5-6|<>:s#5-7$<i>7]"
+                        + "[(6-7)s:a|i:a|f/m:sieben|f/y:seven|x/o:siebtens|it/is:7|_6#6-7]"
+                        + "[(7-8)s:b|i:b|f/m:acht|f/y:eight|x/o:achtens|it/is:8|<>:x/tag#7-10$<i>10|_7#7-8]"
+                        + "[(8-9)s:a|i:a|f/m:neun|f/y:nine|x/o:neuntens|it/is:9|_8#8-9]"
+                        + "[(9-10)s:c|i:c|f/m:zehn|f/y:ten|x/o:zehntens|it/is:10|_9#9-10]");
+        return fd;
     };
 
 };
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 d253e42..5995ded 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -36,176 +36,169 @@
 
     @Test
     public void indexExample1 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// 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]");
-	ki.addDoc(fd);
+        // 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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
-	Result kr;
+        SpanQuery sq;
+        Result kr;
 
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:b")),
-            new SpanClassQuery(
-              new SpanTermQuery(new Term("base", "s:a"))
-	    )
-        );
-	kr = ki.search(sq, (short) 10);
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a"))));
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... bcabca[b{1:a}]c", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "... bcabca[b{1:a}]c",
+                kr.getMatch(0).getSnippetBrackets());
 
-	assertEquals("Test no 'more' context", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><mark>b<mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\">c</span>", kr.getMatch(0).getSnippetHTML());
-	sq = new SpanFocusQuery(
-  	     new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:b")),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:a"))
-	        )
-            )
-	);
-	kr = ki.search(sq, (short) 10);
+        assertEquals(
+                "Test no 'more' context",
+                "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><mark>b<mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\">c</span>",
+                kr.getMatch(0).getSnippetHTML());
+        sq = new SpanFocusQuery(new SpanNextQuery(new SpanTermQuery(new Term(
+                "base", "s:b")), new SpanClassQuery(new SpanTermQuery(new Term(
+                "base", "s:a")))));
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("StartPos (0)", 8, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... cabcab[{1:a}]c", kr.getMatch(0).getSnippetBrackets());
-	sq = new SpanFocusQuery(
-            new SpanNextQuery(
-	        new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
-                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-            ), (byte) 3
-        );
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("StartPos (0)", 8, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "... cabcab[{1:a}]c", kr
+                .getMatch(0).getSnippetBrackets());
+        sq = new SpanFocusQuery(new SpanNextQuery(new SpanClassQuery(
+                new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        (byte) 3)), (byte) 3);
 
-	kr = ki.search(sq, (short) 10);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", kr.getMatch(0).getSnippetBrackets());
-	
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", kr
+                .getMatch(0).getSnippetBrackets());
 
-	assertEquals("<span class=\"context-left\">a</span><mark><mark class=\"class-3 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{3:b}]cabac", kr.getMatch(1).getSnippetBrackets());
+        assertEquals(
+                "<span class=\"context-left\">a</span><mark><mark class=\"class-3 level-0\">b</mark></mark><span class=\"context-right\">cabcab<span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	assertEquals("<span class=\"context-left\">abca</span><mark><mark class=\"class-3 level-0\">b</mark></mark><span class=\"context-right\">cabac</span>", kr.getMatch(1).getSnippetHTML());
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abca[{3:b}]cabac", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	assertEquals("SnippetBrackets (2)", "... bcabca[{3:b}]ac", kr.getMatch(2).getSnippetBrackets());
+        assertEquals(
+                "<span class=\"context-left\">abca</span><mark><mark class=\"class-3 level-0\">b</mark></mark><span class=\"context-right\">cabac</span>",
+                kr.getMatch(1).getSnippetHTML());
+
+        assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+        assertEquals("SnippetBrackets (2)", "... bcabca[{3:b}]ac",
+                kr.getMatch(2).getSnippetBrackets());
 
 
 
-	// abcabcabac
-	sq = new SpanFocusQuery( 
-            new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:a")),
-                new SpanClassQuery(
-	            new SpanNextQuery(
-	   	        new SpanTermQuery(new Term("base", "s:b")),
-	    	        new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")))
-		    ), (byte) 2
-        )), (byte) 2);
+        // abcabcabac
+        sq = new SpanFocusQuery(
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                        new SpanClassQuery(new SpanNextQuery(new SpanTermQuery(
+                                new Term("base", "s:b")), new SpanClassQuery(
+                                new SpanTermQuery(new Term("base", "s:a")))),
+                                (byte) 2)), (byte) 2);
 
-	kr = ki.search(sq, (short) 10);
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", kr
+                .getMatch(0).getSnippetBrackets());
 
-	assertEquals("SnippetHTML (0) 1", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><mark><mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals(
+                "SnippetHTML (0) 1",
+                "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><mark><mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\">c</span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	// Offset tokens
-	kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "... ca[{2:b{1:a}}]c", kr.getMatch(0).getSnippetBrackets());
+        // Offset tokens
+        kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "... ca[{2:b{1:a}}]c",
+                kr.getMatch(0).getSnippetBrackets());
 
 
 
-	// Offset Characters
-	kr = ki.search(sq, 0, (short) 10, false, (short) 1, false, (short) 0);
-	assertEquals("totalResults", kr.getTotalResults(), 1);
-	assertEquals("SnippetBrackets (0)", "... a[{2:b{1:a}}] ...", kr.getMatch(0).getSnippetBrackets());
+        // Offset Characters
+        kr = ki.search(sq, 0, (short) 10, false, (short) 1, false, (short) 0);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("SnippetBrackets (0)", "... a[{2:b{1:a}}] ...", kr
+                .getMatch(0).getSnippetBrackets());
 
-	assertEquals("SnippetHTML (0) 2", "<span class=\"context-left\"><span class=\"more\"></span>a</span><mark><mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals(
+                "SnippetHTML (0) 2",
+                "<span class=\"context-left\"><span class=\"more\"></span>a</span><mark><mark class=\"class-2 level-0\">b<mark class=\"class-1 level-1\">a</mark></mark></mark><span class=\"context-right\"><span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
-	sq = new SpanFocusQuery(
-            new SpanClassQuery(
-                new SpanNextQuery(
-	            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 1),
-                    new SpanClassQuery(new SpanTermQuery(new Term("base", "s:c")), (byte) 2)
-		), (byte) 3
-            ), (byte) 3
-	);
+        sq = new SpanFocusQuery(new SpanClassQuery(new SpanNextQuery(
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        (byte) 1), new SpanClassQuery(new SpanTermQuery(
+                        new Term("base", "s:c")), (byte) 2)), (byte) 3),
+                (byte) 3);
 
-	kr = ki.search(sq, (short) 10);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{3:{1:b}{2:c}}]abcaba ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{3:{1:b}{2:c}}]abac", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(sq, (short) 10);
 
-	assertEquals("Document count", 1, ki.numberOf("base", "documents"));
-	assertEquals("Token count", 10, ki.numberOf("base", "t"));
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "a[{3:{1:b}{2:c}}]abcaba ...", kr
+                .getMatch(0).getSnippetBrackets());
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abca[{3:{1:b}{2:c}}]abac", kr
+                .getMatch(1).getSnippetBrackets());
 
-	// Don't match the expected class!
-	sq = new SpanFocusQuery(
-            new SpanNextQuery(
-	        new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 1),
-		new SpanClassQuery(new SpanTermQuery(new Term("base", "s:c")), (byte) 2)
-	    ), (byte) 3
-	);
+        assertEquals("Document count", 1, ki.numberOf("base", "documents"));
+        assertEquals("Token count", 10, ki.numberOf("base", "t"));
 
-	kr = ki.search(sq, (short) 10);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 0);
+        // Don't match the expected class!
+        sq = new SpanFocusQuery(new SpanNextQuery(new SpanClassQuery(
+                new SpanTermQuery(new Term("base", "s:b")), (byte) 1),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:c")),
+                        (byte) 2)), (byte) 3);
 
-	sq = new SpanFocusQuery(
-            new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:a")),
-                new SpanClassQuery(
-	            new SpanNextQuery(
-	                new SpanTermQuery(new Term("base", "s:b")),
-	                new SpanTermQuery(new Term("base", "s:c"))
-  	            )
-	       )
-            )
-        );
+        kr = ki.search(sq, (short) 10);
 
-	kr = ki.search(sq, (short) 2);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{1:bc}]abcaba ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{1:bc}]abac", kr.getMatch(1).getSnippetBrackets());
+        assertEquals("totalResults", kr.getTotalResults(), 0);
 
-	assertEquals(1, ki.numberOf("base", "documents"));
-	assertEquals(10, ki.numberOf("base", "t"));
+        sq = new SpanFocusQuery(new SpanNextQuery(new SpanTermQuery(new Term(
+                "base", "s:a")), new SpanClassQuery(new SpanNextQuery(
+                new SpanTermQuery(new Term("base", "s:b")), new SpanTermQuery(
+                        new Term("base", "s:c"))))));
+
+        kr = ki.search(sq, (short) 2);
+
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("SnippetBrackets (0)", "a[{1:bc}]abcaba ...",
+                kr.getMatch(0).getSnippetBrackets());
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        assertEquals("SnippetBrackets (1)", "abca[{1:bc}]abac", kr.getMatch(1)
+                .getSnippetBrackets());
+
+        assertEquals(1, ki.numberOf("base", "documents"));
+        assertEquals(10, ki.numberOf("base", "t"));
     };
 
 
@@ -215,18 +208,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#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]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -234,33 +221,55 @@
         Result kr;
 
         // No contexts:
-        sq = new SpanOrQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-            new SpanTermQuery(new Term("base", "s:c"))
-        );
+        sq = new SpanOrQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanTermQuery(new Term("base", "s:c")));
         kr = ki.search(sq, (short) 20);
 
         assertEquals("totalResults", kr.getTotalResults(), 7);
-        assertEquals("SnippetBrackets (0)", "<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\">bcabca<span class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
-        assertEquals("SnippetBrackets (0)", "[a]bcabca ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (0)",
+                "<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\">bcabca<span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
+        assertEquals("SnippetBrackets (0)", "[a]bcabca ...", kr.getMatch(0)
+                .getSnippetBrackets());
 
-        assertEquals("SnippetBrackets (1)", "ab[c]abcaba ...", kr.getMatch(1).getSnippetBrackets());
-        assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">ab</span><mark>c</mark><span class=\"context-right\">abcaba<span class=\"more\"></span></span>", kr.getMatch(1).getSnippetHTML());
-        
-        assertEquals("SnippetBrackets (6)", "... abcaba[c]", kr.getMatch(6).getSnippetBrackets());
-        assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span>abcaba</span><mark>c</mark><span class=\"context-right\"></span>", kr.getMatch(6).getSnippetHTML());
+        assertEquals("SnippetBrackets (1)", "ab[c]abcaba ...", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (1)",
+                "<span class=\"context-left\">ab</span><mark>c</mark><span class=\"context-right\">abcaba<span class=\"more\"></span></span>",
+                kr.getMatch(1).getSnippetHTML());
+
+        assertEquals("SnippetBrackets (6)", "... abcaba[c]", kr.getMatch(6)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (6)",
+                "<span class=\"context-left\"><span class=\"more\"></span>abcaba</span><mark>c</mark><span class=\"context-right\"></span>",
+                kr.getMatch(6).getSnippetHTML());
 
         kr = ki.search(sq, 0, (short) 20, true, (short) 0, true, (short) 0);
 
         assertEquals("totalResults", kr.getTotalResults(), 7);
-        assertEquals("SnippetBrackets (0)", "[a] ...", kr.getMatch(0).getSnippetBrackets());
-        assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(0).getSnippetHTML());
+        assertEquals("SnippetBrackets (0)", "[a] ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (0)",
+                "<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\"><span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
-        assertEquals("SnippetBrackets (1)", "... [c] ...", kr.getMatch(1).getSnippetBrackets());
-        assertEquals("SnippetHTML (1)", "<span class=\"context-left\"><span class=\"more\"></span></span><mark>c</mark><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(1).getSnippetHTML());
+        assertEquals("SnippetBrackets (1)", "... [c] ...", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetHTML (1)",
+                "<span class=\"context-left\"><span class=\"more\"></span></span><mark>c</mark><span class=\"context-right\"><span class=\"more\"></span></span>",
+                kr.getMatch(1).getSnippetHTML());
 
-        assertEquals("SnippetBrackets (6)", "... [c]", kr.getMatch(6).getSnippetBrackets());
-        assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span></span><mark>c</mark><span class=\"context-right\"></span>", kr.getMatch(6).getSnippetHTML());
+        assertEquals("SnippetBrackets (6)", "... [c]", kr.getMatch(6)
+                .getSnippetBrackets());
+        assertEquals(
+                "SnippetBrackets (6)",
+                "<span class=\"context-left\"><span class=\"more\"></span></span><mark>c</mark><span class=\"context-right\"></span>",
+                kr.getMatch(6).getSnippetHTML());
     };
 
 
@@ -270,18 +279,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#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]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -289,12 +292,16 @@
 
         QueryBuilder kq = new QueryBuilder("base");
 
-        SpanQuery sq = kq._(1,kq.seq(kq.seg("s:b")).append(kq.seg("s:a")).append(kq._(2,kq.seg("s:c")))).toQuery();
-        
+        SpanQuery sq = kq._(
+                1,
+                kq.seq(kq.seg("s:b")).append(kq.seg("s:a"))
+                        .append(kq._(2, kq.seg("s:c")))).toQuery();
+
         kr = ki.search(sq, 0, (short) 20, true, (short) 2, true, (short) 5);
 
         assertEquals("totalResults", kr.getTotalResults(), 1);
-        assertEquals("SnippetBrackets (0)", "... ca[{1:ba{2:c}}]", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("SnippetBrackets (0)", "... ca[{1:ba{2:c}}]",
+                kr.getMatch(0).getSnippetBrackets());
     };
 
 
@@ -304,30 +311,22 @@
 
         // 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#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]");
         ki.addDoc(fd);
         ki.commit();
 
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanFocusQuery(
-            new SpanNextQuery(
-                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
-                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-            ), (byte) 3
-        );
+        sq = new SpanFocusQuery(new SpanNextQuery(new SpanClassQuery(
+                new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        (byte) 3)), (byte) 3);
 
         kr = ki.search(sq, (short) 10);
 
@@ -336,23 +335,22 @@
         Match km = kr.getMatch(0);
         assertEquals("StartPos (0)", 1, km.startPos);
         assertEquals("EndPos (0)", 2, km.endPos);
-        assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", km.getSnippetBrackets());
+        assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...",
+                km.getSnippetBrackets());
 
-        sq = new SpanFocusQuery(
-            new SpanFocusQuery(
-                new SpanNextQuery(
-	            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
-                    new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-                ), (byte) 3
-	        ), (byte) 2
-        );
-	
+        sq = new SpanFocusQuery(new SpanFocusQuery(new SpanNextQuery(
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")),
+                        (byte) 2), new SpanClassQuery(new SpanTermQuery(
+                        new Term("base", "s:b")), (byte) 3)), (byte) 3),
+                (byte) 2);
+
         kr = ki.search(sq, (short) 10);
 
         km = kr.getMatch(0);
         assertEquals("StartPos (0)", 0, km.startPos);
         assertEquals("EndPos (0)", 1, km.endPos);
-        assertEquals("SnippetBrackets (0)", "[{2:a}]bcabca ...", km.getSnippetBrackets());
+        assertEquals("SnippetBrackets (0)", "[{2:a}]bcabca ...",
+                km.getSnippetBrackets());
 
         // TODO: Check ID
     };
@@ -361,45 +359,40 @@
     @Test
     public void indexExampleFocusWithSpan () throws IOException {
         KrillIndex ki = new KrillIndex();
-        
+
         // 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#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]");
         ki.addDoc(fd);
         ki.commit();
 
         SpanQuery sq;
         Result kr;
-        
-        sq = new SpanWithinQuery(
-            new SpanClassQuery(new SpanElementQuery("base", "s"), (byte) 2),
-            new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-        );
+
+        sq = new SpanWithinQuery(new SpanClassQuery(new SpanElementQuery(
+                "base", "s"), (byte) 2), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:b")), (byte) 3));
 
         kr = ki.search(sq, (short) 10);
-        assertEquals(kr.getSerialQuery(), "spanContain({2: <base:s />}, {3: base:s:b})");
-        assertEquals(kr.getMatch(0).getSnippetBrackets(), "a[{2:{3:b}cab}]cabac");
+        assertEquals(kr.getSerialQuery(),
+                "spanContain({2: <base:s />}, {3: base:s:b})");
+        assertEquals(kr.getMatch(0).getSnippetBrackets(),
+                "a[{2:{3:b}cab}]cabac");
 
-        sq = new SpanFocusQuery(
-            new SpanWithinQuery(
-	        new SpanClassQuery(new SpanElementQuery("base", "s"), (byte) 2),
-                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")), (byte) 3)
-            ), (byte) 3
-        );
+        sq = new SpanFocusQuery(new SpanWithinQuery(new SpanClassQuery(
+                new SpanElementQuery("base", "s"), (byte) 2),
+                new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        (byte) 3)), (byte) 3);
 
         kr = ki.search(sq, (short) 10);
-        assertEquals(kr.getSerialQuery(), "focus(3: spanContain({2: <base:s />}, {3: base:s:b}))");
+        assertEquals(kr.getSerialQuery(),
+                "focus(3: spanContain({2: <base:s />}, {3: base:s:b}))");
         assertEquals(kr.getMatch(0).getSnippetBrackets(), "a[{3:b}]cabcab ...");
     };
 
@@ -407,64 +400,47 @@
     @Ignore
     public void indexExampleFocusWithSkip () throws IOException {
         KrillIndex ki = new KrillIndex();
-        
+
         // abcabcabac
         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]" + // |<>: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]");
+        fd.addTV("base", "abcabcabac",
+        // The payload should be ignored
+                "[(0-1)s:a|i:a|_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: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]");
         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]");
+        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]");
         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#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]");
         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]");
+        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]");
         ki.addDoc(fd);
         ki.commit();
 
@@ -475,15 +451,11 @@
         assertEquals("Documents", 4, kc.numberOf("documents"));
 
         // within(<p>, focus(3:within({2:<s>}, {3:a})))
-        sq = new SpanWithinQuery(
-                 new SpanElementQuery("base", "p"),
-                 new SpanFocusQuery(
-                     new SpanWithinQuery(
-                         new SpanClassQuery(new SpanElementQuery("base", "s"), (byte) 2),
-                         new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 3)
-                     ), (byte) 3
-                 )
-             );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "p"),
+                new SpanFocusQuery(new SpanWithinQuery(new SpanClassQuery(
+                        new SpanElementQuery("base", "s"), (byte) 2),
+                        new SpanClassQuery(new SpanTermQuery(new Term("base",
+                                "s:a")), (byte) 3)), (byte) 3));
 
         fail("Skipping may go horribly wrong! (Known issue)");
 
@@ -491,11 +463,16 @@
         //        System.err.println(kr.getOverview());
 
 
-        assertEquals(kr.getSerialQuery(), "spanContain(<base:p />, focus(3: spanContain({2: <base:s />}, {3: base:s:a})))");
+        assertEquals(
+                kr.getSerialQuery(),
+                "spanContain(<base:p />, focus(3: spanContain({2: <base:s />}, {3: base:s:a})))");
         assertEquals(12, kr.getTotalResults());
-        assertEquals("[a{2:bc{3:a}b}cabac]", kr.getMatch(0).getSnippetBrackets());
-        assertEquals("[ab{2:c{3:a}bcab}ac]", kr.getMatch(1).getSnippetBrackets());
-        assertEquals("[ab{2:cabc{3:a}}bac]", kr.getMatch(2).getSnippetBrackets());
+        assertEquals("[a{2:bc{3:a}b}cabac]", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("[ab{2:c{3:a}bcab}ac]", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("[ab{2:cabc{3:a}}bac]", kr.getMatch(2)
+                .getSnippetBrackets());
     };
 
 };
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 666216b..ee97464 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
@@ -23,361 +23,373 @@
 
 @RunWith(JUnit4.class)
 public class TestMultipleDistanceIndex {
-	
-	private KrillIndex ki;
-	private Result kr;
 
-	public SpanQuery createQuery(String x, String y, List<DistanceConstraint> 
-			constraints, boolean isOrdered){
-		
-		SpanQuery sx = new SpanTermQuery(new Term("base",x)); 
-		SpanQuery sy = new SpanTermQuery(new Term("base",y));
-		
-		return new SpanMultipleDistanceQuery(sx, sy, constraints, isOrdered, true);
-	}
-	
-	public DistanceConstraint createConstraint(String unit, int min, int max, 
-			boolean isOrdered, boolean exclusion){
-		
-		if (unit.equals("w")){
-			return new DistanceConstraint(min, max,isOrdered,exclusion);
-		}		
-		return new DistanceConstraint(new SpanElementQuery("base", unit), 
-				min, max, isOrdered, exclusion);	
-	}
-	
-    private FieldDocument createFieldDoc0() {
-    	FieldDocument fd = new FieldDocument();
+    private KrillIndex ki;
+    private Result kr;
+
+
+    public SpanQuery createQuery (String x, String y,
+            List<DistanceConstraint> constraints, boolean isOrdered) {
+
+        SpanQuery sx = new SpanTermQuery(new Term("base", x));
+        SpanQuery sy = new SpanTermQuery(new Term("base", y));
+
+        return new SpanMultipleDistanceQuery(sx, sy, constraints, isOrdered,
+                true);
+    }
+
+
+    public DistanceConstraint createConstraint (String unit, int min, int max,
+            boolean isOrdered, boolean exclusion) {
+
+        if (unit.equals("w")) {
+            return new DistanceConstraint(min, max, isOrdered, exclusion);
+        }
+        return new DistanceConstraint(new SpanElementQuery("base", unit), min,
+                max, isOrdered, exclusion);
+    }
+
+
+    private FieldDocument createFieldDoc0 () {
+        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]" +
-            "[(1-2)s:b|s:c|_2#1-2]" +             
-            "[(2-3)s:c|_3#2-3|<>:s#2-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]" +             
-            "[(5-6)s:e|_6#5-6]");
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                        + "[(1-2)s:b|s:c|_2#1-2]"
+                        + "[(2-3)s:c|_3#2-3|<>:s#2-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]"
+                        + "[(5-6)s:e|_6#5-6]");
         return fd;
-	}
-    
-    private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    private FieldDocument createFieldDoc1 () {
+        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]" +
-            "[(1-2)s:c|s:e|_2#1-2]" +             
-            "[(2-3)s:e|_3#2-3|<>:s#2-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]" +             
-            "[(5-6)s:c|_6#5-6]");
+        fd.addTV("base", "text",
+                "[(0-1)s:c|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                        + "[(1-2)s:c|s:e|_2#1-2]"
+                        + "[(2-3)s:e|_3#2-3|<>:s#2-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]"
+                        + "[(5-6)s:c|_6#5-6]");
         return fd;
-    }   
-    
-    private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    private FieldDocument createFieldDoc2 () {
+        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]" +
-            "[(1-2)s:b|s:e|_2#1-2]" +             
-            "[(2-3)s:e|_3#2-3|<>:s#2-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]" +             
-            "[(5-6)s:d|_6#5-6]" +
-        	"[(6-7)s:b|_7#6-7|<>:s#6-7$<i>7|<>:p#6-7$<i>7]" );
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                        + "[(1-2)s:b|s:e|_2#1-2]"
+                        + "[(2-3)s:e|_3#2-3|<>:s#2-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]"
+                        + "[(5-6)s:d|_6#5-6]"
+                        + "[(6-7)s:b|_7#6-7|<>:s#6-7$<i>7|<>:p#6-7$<i>7]");
         return fd;
-	}
-    
-    private FieldDocument createFieldDoc3() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    private FieldDocument createFieldDoc3 () {
+        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]" +
-            "[(1-2)s:b|s:c|_2#1-2]" +             
-            "[(2-3)s:c|_3#2-3|<>:s#2-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]" );
+        fd.addTV("base", "text",
+                "[(0-1)s:b|_1#0-1|<>:s#0-2$<i>2|<>:p#0-4$<i>4]"
+                        + "[(1-2)s:b|s:c|_2#1-2]"
+                        + "[(2-3)s:c|_3#2-3|<>:s#2-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]");
         return fd;
-	}
-    
-    /** Unordered, same sentence
+    }
+
+
+    /**
+     * Unordered, same sentence
      * */
     @Test
-	public void testCase1() throws IOException {
-    	ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    public void testCase1 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-        
-    	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
- 	    constraints.add(createConstraint("w", 0, 2, false, false));	    
- 	    constraints.add(createConstraint("s", 0, 0, false, false));
- 	    
- 	    SpanQuery mdq;	   
-		mdq = createQuery("s:b", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);
-		// System.out.println(mdq);
-		
-		assertEquals((long) 3, kr.getTotalResults());
-	    assertEquals(0, kr.getMatch(0).getStartPos());
-	    assertEquals(2, kr.getMatch(0).getEndPos());
-	    assertEquals(1, kr.getMatch(1).getStartPos());
-	    assertEquals(2, kr.getMatch(1).getEndPos());
-	    assertEquals(2, kr.getMatch(2).getStartPos());
-	    assertEquals(4, kr.getMatch(2).getEndPos());
+
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 0, 2, false, false));
+        constraints.add(createConstraint("s", 0, 0, false, false));
+
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+        // System.out.println(mdq);
+
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(2, kr.getMatch(1).getEndPos());
+        assertEquals(2, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
     }
-	
-    /** Ordered
-     * 	Unordered
-     * 	Two constraints
-     * 	Three constraints 	
+
+
+    /**
+     * Ordered
+     * Unordered
+     * Two constraints
+     * Three constraints
      * */
-	@Test
-	public void testCase2() throws IOException {
-		ki = new KrillIndex();
-        ki.addDoc(createFieldDoc0()); 
+    @Test
+    public void testCase2 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
         ki.commit();
-		
+
         // Ordered - two constraints
-	    List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(createConstraint("w", 0, 2, true, false));	    
-	    constraints.add(createConstraint("s", 1, 1, true, false));
-	    
-	    SpanQuery mdq;	    
-		mdq = createQuery("s:b", "s:c", constraints,true);
-		kr = ki.search(mdq, (short) 10);		
-	    assertEquals((long) 3, kr.getTotalResults());
-	    assertEquals(0, kr.getMatch(0).getStartPos());
-	    assertEquals(3, kr.getMatch(0).getEndPos());
-	    assertEquals(1, kr.getMatch(1).getStartPos());
-	    assertEquals(3, kr.getMatch(1).getEndPos());
-	    assertEquals(3, kr.getMatch(2).getStartPos());
-	    assertEquals(5, kr.getMatch(2).getEndPos());	   
-	   				
-		// Three constraints
-		constraints.add(createConstraint("p", 0, 0, true, false));		
-		mdq = createQuery("s:b", "s:c", constraints,true);
-		kr = ki.search(mdq, (short) 10);
-		assertEquals((long) 2, kr.getTotalResults());
-		
-		
-		// Unordered - two constraints
-		constraints.clear();
-	    constraints.add(createConstraint("w", 0, 2, false, false));	    
-	    constraints.add(createConstraint("s", 1, 1, false, false));
-	    	   
-	    mdq = createQuery("s:c", "s:b", constraints,false);
-	    kr = ki.search(mdq, (short) 10);
-	    assertEquals((long) 4, kr.getTotalResults());
-	    assertEquals(1, kr.getMatch(2).getStartPos());
-	    assertEquals(4, kr.getMatch(2).getEndPos());
-		
-	    // Three constraints
-		constraints.add(createConstraint("p", 0, 0, false, false));
-		mdq = createQuery("s:b", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);		
-		assertEquals((long) 3, kr.getTotalResults());	
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 0, 2, true, false));
+        constraints.add(createConstraint("s", 1, 1, true, false));
 
-	}
-    
-    /** Multiple documents
-     * 	Ensure same doc (inner term span)
-     * */
-    @Test
-   	public void testCase3() throws IOException {
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0()); 
-    	ki.addDoc(createFieldDoc1());
-    	ki.addDoc(createFieldDoc2());
-    	ki.commit();
-           
-       	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(createConstraint("w", 1, 2, false, false));	    
-	    constraints.add(createConstraint("s", 1, 2, false, false));
-    	    
-	    SpanQuery mdq;	   
-		mdq = createQuery("s:b", "s:e", constraints,false);
-		kr = ki.search(mdq, (short) 10);		
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:c", constraints, true);
+        kr = ki.search(mdq, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(3, kr.getMatch(1).getEndPos());
+        assertEquals(3, kr.getMatch(2).getStartPos());
+        assertEquals(5, kr.getMatch(2).getEndPos());
 
-		assertEquals((long) 5, kr.getTotalResults());		
-	    assertEquals(3, kr.getMatch(0).getStartPos());
-	    assertEquals(6, kr.getMatch(0).getEndPos());
-	    assertEquals(2, kr.getMatch(1).getLocalDocID());
-	    assertEquals(1, kr.getMatch(2).getStartPos());
-	    assertEquals(4, kr.getMatch(2).getEndPos());
-	    assertEquals(3, kr.getMatch(3).getStartPos());
-	    assertEquals(5, kr.getMatch(3).getEndPos());	
-	    assertEquals(4, kr.getMatch(4).getStartPos());
-	    assertEquals(7, kr.getMatch(4).getEndPos());
-	    
-//	    System.out.print(kr.getTotalResults()+"\n");
-//		for (int i=0; i< kr.getTotalResults(); i++){
-//			System.out.println(
-//				kr.match(i).getLocalDocID()+" "+
-//				kr.match(i).startPos + " " +
-//				kr.match(i).endPos
-//		    );
-//		}
-		
-    }
-    
-	/**	Skip to
-     * */
-    @Test
-   	public void testCase4() throws IOException {
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());
-    	ki.addDoc(createFieldDoc3());
-    	ki.addDoc(createFieldDoc1());
-    	ki.addDoc(createFieldDoc2());
-    	ki.commit();
-    	
-    	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(createConstraint("w", 1, 2, false, false));	    
-	    constraints.add(createConstraint("s", 1, 2, false, false));
-		
-	    SpanQuery mdq;	   
-		mdq = createQuery("s:b", "s:c", constraints,false);
-		
-		SpanQuery sq = new SpanNextQuery(mdq, 
-				new SpanTermQuery(new Term("base","s:e")));
-		kr = ki.search(sq, (short) 10);
-		
-		assertEquals((long) 2, kr.getTotalResults());
-	    assertEquals(3, kr.getMatch(0).getStartPos());
-	    assertEquals(6, kr.getMatch(0).getEndPos());
-	    assertEquals(3, kr.getMatch(1).getLocalDocID());
-	    assertEquals(1, kr.getMatch(1).getStartPos());
-	    assertEquals(5, kr.getMatch(1).getEndPos());
+        // Three constraints
+        constraints.add(createConstraint("p", 0, 0, true, false));
+        mdq = createQuery("s:b", "s:c", constraints, true);
+        kr = ki.search(mdq, (short) 10);
+        assertEquals((long) 2, kr.getTotalResults());
+
+
+        // Unordered - two constraints
+        constraints.clear();
+        constraints.add(createConstraint("w", 0, 2, false, false));
+        constraints.add(createConstraint("s", 1, 1, false, false));
+
+        mdq = createQuery("s:c", "s:b", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+        assertEquals((long) 4, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
+
+        // Three constraints
+        constraints.add(createConstraint("p", 0, 0, false, false));
+        mdq = createQuery("s:b", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
 
     }
-    
-    /** Same tokens: ordered and unordered yield the same results
-	 * */
-    @Test
-   	public void testCase5() throws IOException {
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc0());    	
-    	ki.addDoc(createFieldDoc1());    	
-    	ki.commit();
-    	
-    	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(createConstraint("w", 1, 2, false, false));	    
-	    constraints.add(createConstraint("s", 1, 2, false, false));
-		
-	    SpanQuery mdq;	   
-		mdq = createQuery("s:c", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);
-		
-		assertEquals((long) 4, kr.getTotalResults());
-	    assertEquals(1, kr.getMatch(0).getStartPos());
-	    assertEquals(3, kr.getMatch(0).getEndPos());
-	    assertEquals(2, kr.getMatch(1).getStartPos());
-	    assertEquals(5, kr.getMatch(1).getEndPos());
-	    assertEquals(1, kr.getMatch(2).getLocalDocID());
-	    assertEquals(1, kr.getMatch(2).getStartPos());
-	    assertEquals(4, kr.getMatch(2).getEndPos());
-	    assertEquals(3, kr.getMatch(3).getStartPos());
-	    assertEquals(6, kr.getMatch(3).getEndPos());	
 
-    }
-	
-    /** Exclusion
-     * 	Gaps
+
+    /**
+     * Multiple documents
+     * Ensure same doc (inner term span)
      * */
     @Test
-   	public void testCase6() throws IOException {
-    	ki = new KrillIndex();
-    	ki.addDoc(createFieldDoc3());    	
-    	ki.commit();
-    	
-    	// First constraint - token exclusion
-    	SpanQuery sx = new SpanTermQuery(new Term("base","s:b")); 
-		SpanQuery sy = new SpanTermQuery(new Term("base","s:c"));
-		
-		DistanceConstraint dc1 = createConstraint("w", 0, 1, false, true);
-		SpanDistanceQuery sq = new SpanDistanceQuery(sx, sy, dc1, true);
-		
-		kr = ki.search(sq, (short) 10);
-		assertEquals((long) 1, kr.getTotalResults());
-		// 4-5
-		
-    	// Second constraint - element distance
-		DistanceConstraint  dc2 = createConstraint("s", 1, 1, false, false);
-		sq = new SpanDistanceQuery(sx, sy, dc2, true);		
-		kr = ki.search(sq, (short) 10);		
-		// 0-3, 1-3, 1-4, 1-5, 3-7, 4-7
-		assertEquals((long) 6, kr.getTotalResults());
-		
-		
-    	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(dc1);
-	    constraints.add(dc2);
-	    	    
-	    SpanQuery mdq;	   
-		mdq = createQuery("s:b", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);
-		
-		assertEquals((long) 2, kr.getTotalResults());
-	    assertEquals(1, kr.getMatch(0).getStartPos());
-	    assertEquals(5, kr.getMatch(0).getEndPos());
-	    assertEquals(4, kr.getMatch(1).getStartPos());
-	    assertEquals(7, kr.getMatch(1).getEndPos());
+    public void testCase3 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 1, 2, false, false));
+        constraints.add(createConstraint("s", 1, 2, false, false));
+
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:e", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+
+        assertEquals((long) 5, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(0).getStartPos());
+        assertEquals(6, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(1).getLocalDocID());
+        assertEquals(1, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
+        assertEquals(3, kr.getMatch(3).getStartPos());
+        assertEquals(5, kr.getMatch(3).getEndPos());
+        assertEquals(4, kr.getMatch(4).getStartPos());
+        assertEquals(7, kr.getMatch(4).getEndPos());
+
+        //	    System.out.print(kr.getTotalResults()+"\n");
+        //		for (int i=0; i< kr.getTotalResults(); i++){
+        //			System.out.println(
+        //				kr.match(i).getLocalDocID()+" "+
+        //				kr.match(i).startPos + " " +
+        //				kr.match(i).endPos
+        //		    );
+        //		}
+
     }
-    
-    
-    /** Exclusion, multiple documents
+
+
+    /**
+     * Skip to
      * */
     @Test
-    public void testCase7() throws IOException {
-    	ki = new KrillIndex();   	
-    	ki.addDoc(createFieldDoc2());    	
-    	ki.commit();
-    	
-    	SpanQuery sx = new SpanTermQuery(new Term("base","s:b")); 
-		SpanQuery sy = new SpanTermQuery(new Term("base","s:c"));
-    	// Second constraint
-		SpanDistanceQuery sq = new SpanDistanceQuery(sx,sy, 
-				createConstraint("s", 0, 0, false, true),
-				true);
-		kr = ki.search(sq, (short) 10);
-		assertEquals((long) 3, kr.getTotalResults());
-    	// 0-1, 1-2, 6-7
-				
-	    // Exclusion within the same sentence
-    	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
-	    constraints.add(createConstraint("w", 0, 2,false,true));
-	    constraints.add(createConstraint("s", 0, 0,false,true));
+    public void testCase4 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc3());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
 
-	    SpanQuery mdq;	   
-		mdq = createQuery("s:b", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);		
-		assertEquals((long) 2, kr.getTotalResults());
-	    assertEquals(0, kr.getMatch(0).getStartPos());
-	    assertEquals(1, kr.getMatch(0).getEndPos());
-	    assertEquals(6, kr.getMatch(1).getStartPos());
-	    assertEquals(7, kr.getMatch(1).getEndPos());
-		
-	    
-	    // Third constraint
-	    sq = new SpanDistanceQuery(sx, sy, 
-				createConstraint("p", 0, 0, false, true), 
-				true);
-	    kr = ki.search(sq, (short) 10);
-		assertEquals((long) 1, kr.getTotalResults());
-		// 6-7
-	    
-		constraints.add(createConstraint("p", 0, 0, false, true));
-	    mdq = createQuery("s:b", "s:c", constraints,false);
-		kr = ki.search(mdq, (short) 10);			
-		
-	    assertEquals((long) 1, kr.getTotalResults());
-	    assertEquals(6, kr.getMatch(0).getStartPos());
-	    assertEquals(7, kr.getMatch(0).getEndPos());
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 1, 2, false, false));
+        constraints.add(createConstraint("s", 1, 2, false, false));
 
-	}
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:c", constraints, false);
+
+        SpanQuery sq = new SpanNextQuery(mdq, new SpanTermQuery(new Term(
+                "base", "s:e")));
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(0).getStartPos());
+        assertEquals(6, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getLocalDocID());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+
+    }
+
+
+    /**
+     * Same tokens: ordered and unordered yield the same results
+     * */
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 1, 2, false, false));
+        constraints.add(createConstraint("s", 1, 2, false, false));
+
+        SpanQuery mdq;
+        mdq = createQuery("s:c", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+
+        assertEquals((long) 4, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+        assertEquals(1, kr.getMatch(2).getLocalDocID());
+        assertEquals(1, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
+        assertEquals(3, kr.getMatch(3).getStartPos());
+        assertEquals(6, kr.getMatch(3).getEndPos());
+
+    }
+
+
+    /**
+     * Exclusion
+     * Gaps
+     * */
+    @Test
+    public void testCase6 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc3());
+        ki.commit();
+
+        // First constraint - token exclusion
+        SpanQuery sx = new SpanTermQuery(new Term("base", "s:b"));
+        SpanQuery sy = new SpanTermQuery(new Term("base", "s:c"));
+
+        DistanceConstraint dc1 = createConstraint("w", 0, 1, false, true);
+        SpanDistanceQuery sq = new SpanDistanceQuery(sx, sy, dc1, true);
+
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 1, kr.getTotalResults());
+        // 4-5
+
+        // Second constraint - element distance
+        DistanceConstraint dc2 = createConstraint("s", 1, 1, false, false);
+        sq = new SpanDistanceQuery(sx, sy, dc2, true);
+        kr = ki.search(sq, (short) 10);
+        // 0-3, 1-3, 1-4, 1-5, 3-7, 4-7
+        assertEquals((long) 6, kr.getTotalResults());
+
+
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(dc1);
+        constraints.add(dc2);
+
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(5, kr.getMatch(0).getEndPos());
+        assertEquals(4, kr.getMatch(1).getStartPos());
+        assertEquals(7, kr.getMatch(1).getEndPos());
+    }
+
+
+    /**
+     * Exclusion, multiple documents
+     * */
+    @Test
+    public void testCase7 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        SpanQuery sx = new SpanTermQuery(new Term("base", "s:b"));
+        SpanQuery sy = new SpanTermQuery(new Term("base", "s:c"));
+        // Second constraint
+        SpanDistanceQuery sq = new SpanDistanceQuery(sx, sy, createConstraint(
+                "s", 0, 0, false, true), true);
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
+        // 0-1, 1-2, 6-7
+
+        // Exclusion within the same sentence
+        List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
+        constraints.add(createConstraint("w", 0, 2, false, true));
+        constraints.add(createConstraint("s", 0, 0, false, true));
+
+        SpanQuery mdq;
+        mdq = createQuery("s:b", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(1, kr.getMatch(0).getEndPos());
+        assertEquals(6, kr.getMatch(1).getStartPos());
+        assertEquals(7, kr.getMatch(1).getEndPos());
+
+
+        // Third constraint
+        sq = new SpanDistanceQuery(sx, sy, createConstraint("p", 0, 0, false,
+                true), true);
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 1, kr.getTotalResults());
+        // 6-7
+
+        constraints.add(createConstraint("p", 0, 0, false, true));
+        mdq = createQuery("s:b", "s:c", constraints, false);
+        kr = ki.search(mdq, (short) 10);
+
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals(6, kr.getMatch(0).getStartPos());
+        assertEquals(7, kr.getMatch(0).getEndPos());
+
+    }
 }
-
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 0d14991..ffcaed4 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
@@ -45,146 +45,119 @@
 
         // 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#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]");
         ki.addDoc(fd);
         ki.commit();
 
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-            new SpanTermQuery(new Term("base", "s:b"))
-        );
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanTermQuery(new Term("base", "s:b")));
 
-	kr = ki.search(sq, (short) 10);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 3);
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
-	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
-	
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:b")),
-            new SpanTermQuery(new Term("base", "s:c"))
-        );
+        kr = ki.search(sq, (short) 10);
 
-	kr = ki.search(sq, (short) 10);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+        assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
 
-	assertEquals(1, ki.numberOf("base", "documents"));
-	assertEquals(10, ki.numberOf("base", "t"));
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")),
+                new SpanTermQuery(new Term("base", "s:c")));
+
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+
+        assertEquals(1, ki.numberOf("base", "documents"));
+        assertEquals(10, ki.numberOf("base", "t"));
 
 
-	sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:a")),
-	    new SpanNextQuery(
-	      new SpanTermQuery(new Term("base", "s:b")),
-	      new SpanTermQuery(new Term("base", "s:c"))
-	    )
-        );
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")),
+                        new SpanTermQuery(new Term("base", "s:c"))));
 
-	kr = ki.search(sq, (short) 2);
-	
-	assertEquals("totalResults", kr.getTotalResults(), 2);
-	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+        kr = ki.search(sq, (short) 2);
 
-	assertEquals(1, ki.numberOf("base", "documents"));
-	assertEquals(10, ki.numberOf("base", "t"));
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+
+        assertEquals(1, ki.numberOf("base", "documents"));
+        assertEquals(10, ki.numberOf("base", "t"));
 
     };
 
+
     @Test
     public void indexExample2 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// 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]");
-	ki.addDoc(fd);
+        // 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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
-	Result kr;
+        SpanQuery sq;
+        Result kr;
 
-	sq = new SpanNextQuery(
-	       new SpanTermQuery(new Term("base", "s:c")),
- 	       new SpanElementQuery("base", "x")
-	);
-	
-	kr = ki.search(sq, (short) 10);
-	assertEquals("ab[cabca]bac", kr.getMatch(1).getSnippetBrackets());
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:c")),
+                new SpanElementQuery("base", "x"));
+
+        kr = ki.search(sq, (short) 10);
+        assertEquals("ab[cabca]bac", kr.getMatch(1).getSnippetBrackets());
 
     };
 
+
     @Test
     public void indexExample3 () throws IOException {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// 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]");
-	ki.addDoc(fd);
+        // 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]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	SpanQuery sq;
-	Result kr;
+        SpanQuery sq;
+        Result kr;
 
-	sq = new SpanNextQuery(
-	       new SpanElementQuery("base", "x"),
-	       new SpanTermQuery(new Term("base", "s:b"))
-	);
-	
-	kr = ki.search(sq, (short) 10);
-	assertEquals("abc[abcab]ac", kr.getMatch(0).getSnippetBrackets());
+        sq = new SpanNextQuery(new SpanElementQuery("base", "x"),
+                new SpanTermQuery(new Term("base", "s:b")));
+
+        kr = ki.search(sq, (short) 10);
+        assertEquals("abc[abcab]ac", kr.getMatch(0).getSnippetBrackets());
     };
 
+
     @Test
     public void indexExample4 () throws IOException {
         KrillIndex ki = new KrillIndex();
@@ -193,250 +166,217 @@
         // 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#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]");
         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#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]");
         ki.addDoc(fd);
         ki.commit();
 
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanNextQuery(
-            new SpanElementQuery("base", "x"),
-            new SpanTermQuery(new Term("base", "s:b"))
-        );
-	
+        sq = new SpanNextQuery(new SpanElementQuery("base", "x"),
+                new SpanTermQuery(new Term("base", "s:b")));
+
         kr = ki.search(sq, (short) 10);
         assertEquals("TotalResults", kr.getTotalResults(), 2);
         assertEquals("abc[abcab]ac", kr.getMatch(0).getSnippetBrackets());
         assertEquals("xbz[xbzxb]xz", kr.getMatch(1).getSnippetBrackets());
 
-        sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:c")),
-            new SpanElementQuery("base", "x")
-        );
-        
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:c")),
+                new SpanElementQuery("base", "x"));
+
         kr = ki.search(sq, (short) 10);
         assertEquals(kr.getTotalResults(), 1);
         assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
-        
-        sq = new SpanNextQuery(
-            new SpanTermQuery(new Term("base", "s:z")),
-            new SpanElementQuery("base", "x")
-        );
-        
+
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:z")),
+                new SpanElementQuery("base", "x"));
+
         kr = ki.search(sq, (short) 10);
         assertEquals(1, kr.getTotalResults());
         assertEquals("xb[zxbzx]bxz", kr.getMatch(0).getSnippetBrackets());
     };
-    
+
+
     /**
      * Multiple atomic indices
      * Skip to a greater doc#
      * */
-	@Test
-	public void indexExample5 () throws IOException {
-		KrillIndex ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());		
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		ki.addDoc(createFieldDoc3());
-		ki.commit();
-		
-		SpanQuery sq = new SpanNextQuery(
-					new SpanTermQuery(new Term("base","s:d")),
-					new SpanTermQuery(new Term("base","s:b"))
-				);
-		Result kr = ki.search(sq, (short) 10);			
-				
-		assertEquals("totalResults", kr.getTotalResults(), 2);
-		// Match #0
-		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 4, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 6, kr.getMatch(0).endPos);
-		// Match #1
-		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
-		assertEquals("StartPos", 1, kr.getMatch(1).startPos);
-		assertEquals("EndPos", 3, kr.getMatch(1).endPos);
-		
-		sq = new SpanNextQuery(
-				new SpanTermQuery(new Term("base","s:b")),
-				new SpanTermQuery(new Term("base","s:d"))
-			);
-		kr = ki.search(sq, (short) 10);
-		
-		assertEquals("totalResults", kr.getTotalResults(), 1);
-		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 2, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 4, kr.getMatch(0).endPos);
-	}
-	
-	/** Skip to NextSpan */
-	@Test
-	public void indexExample6() throws IOException{
-		KrillIndex ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());		
-		ki.addDoc(createFieldDoc2());		
-		ki.addDoc(createFieldDoc3());
-		ki.commit();
-		
-		SpanQuery sq = new SpanNextQuery(
-				new SpanTermQuery(new Term("base","s:c")), 
-				new SpanNextQuery(
-						new SpanTermQuery(new Term("base","s:d")),
-						new SpanTermQuery(new Term("base","s:b"))
-				)
-			);
-		
-		Result kr = ki.search(sq, (short) 10);			
-		assertEquals("totalResults", kr.getTotalResults(), 1);
-		assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 0, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 3, kr.getMatch(0).endPos);	
-		
-	}
+    @Test
+    public void indexExample5 () throws IOException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+        ki.addDoc(createFieldDoc3());
+        ki.commit();
 
-	@Test
-	public void indexExample7Distances () throws Exception{
-		KrillIndex ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());		
-		ki.addDoc(createFieldDoc2());		
-		ki.addDoc(createFieldDoc3());
-		ki.addDoc(createFieldDoc4());
-		ki.commit();
-		
-		SpanSequenceQueryWrapper sq = new SpanSequenceQueryWrapper("base");
-		sq.append("i:b").append("i:d").withConstraint(1,3);
-		
-		Result kr = ki.search(sq.toQuery(), (short) 10);			
+        SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("base",
+                "s:d")), new SpanTermQuery(new Term("base", "s:b")));
+        Result kr = ki.search(sq, (short) 10);
 
-		assertEquals("totalResults", kr.getTotalResults(), 3);
-		assertEquals("doc-number", "match-doc-0-p2-5", kr.getMatch(0).getID());
-		assertEquals("doc-number", "match-doc-2-p2-4", kr.getMatch(1).getID());
-		assertEquals("doc-number", "match-doc-3-p2-5", kr.getMatch(2).getID());
-	};
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        // Match #0
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 4, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 6, kr.getMatch(0).endPos);
+        // Match #1
+        assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+        assertEquals("StartPos", 1, kr.getMatch(1).startPos);
+        assertEquals("EndPos", 3, kr.getMatch(1).endPos);
 
-	@Test
-	public void indexExample8Distances () throws Exception{
-		KrillIndex ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());		
-		ki.addDoc(createFieldDoc2());		
-		ki.addDoc(createFieldDoc3());
-		ki.addDoc(createFieldDoc4());
-		ki.commit();
-		
-		SpanSequenceQueryWrapper sq = new SpanSequenceQueryWrapper("base");
-		sq.append("i:a").append("i:b").withConstraint(0, 3, "e");
-		
-		Result kr = ki.search(sq.toQuery(), (short) 10);			
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")),
+                new SpanTermQuery(new Term("base", "s:d")));
+        kr = ki.search(sq, (short) 10);
 
-		assertEquals("totalResults", kr.getTotalResults(), 3);
-		assertEquals("doc-number", "match-doc-0-p3-6", kr.getMatch(0).getID());
-		assertEquals("doc-number", "match-doc-1-p1-3", kr.getMatch(1).getID());
-		assertEquals("doc-number", "match-doc-3-p3-6", kr.getMatch(2).getID());
-	};
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 2, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 4, kr.getMatch(0).endPos);
+    }
 
-	@Test
-	public void indexExample9() throws IOException{
-		KrillIndex ki = new KrillIndex();
-		ki.addDoc(createFieldDoc1());	
-		ki.commit();
-		
-		SpanQuery sq = new SpanNextQuery(
-				new SpanOrQuery(
-					new SpanTermQuery(new Term("base","s:a")),
-					new SpanTermQuery(new Term("base","s:b"))),
-				new SpanTermQuery(new Term("base","s:c"))
-			);
-		
-		Result kr = ki.search(sq, (short) 10);
-		
-		assertEquals(0, kr.getMatch(0).getStartPos());
-		assertEquals(2, kr.getMatch(0).getEndPos());
-		assertEquals(3, kr.getMatch(1).getStartPos());
-		assertEquals(5, kr.getMatch(1).getEndPos());
-	}
-	
-	
-	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]");
-		return fd;
-	}
-	
-	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]");
-		return fd;
-	} 
-	
-	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]");
-			 	
-		return fd;
-	}
 
-	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]");
-		return fd;
-	}
-	
-	
+    /** Skip to NextSpan */
+    @Test
+    public void indexExample6 () throws IOException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.addDoc(createFieldDoc3());
+        ki.commit();
+
+        SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("base",
+                "s:c")), new SpanNextQuery(new SpanTermQuery(new Term("base",
+                "s:d")), new SpanTermQuery(new Term("base", "s:b"))));
+
+        Result kr = ki.search(sq, (short) 10);
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 0, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 3, kr.getMatch(0).endPos);
+
+    }
+
+
+    @Test
+    public void indexExample7Distances () throws Exception {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.addDoc(createFieldDoc3());
+        ki.addDoc(createFieldDoc4());
+        ki.commit();
+
+        SpanSequenceQueryWrapper sq = new SpanSequenceQueryWrapper("base");
+        sq.append("i:b").append("i:d").withConstraint(1, 3);
+
+        Result kr = ki.search(sq.toQuery(), (short) 10);
+
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("doc-number", "match-doc-0-p2-5", kr.getMatch(0).getID());
+        assertEquals("doc-number", "match-doc-2-p2-4", kr.getMatch(1).getID());
+        assertEquals("doc-number", "match-doc-3-p2-5", kr.getMatch(2).getID());
+    };
+
+
+    @Test
+    public void indexExample8Distances () throws Exception {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.addDoc(createFieldDoc3());
+        ki.addDoc(createFieldDoc4());
+        ki.commit();
+
+        SpanSequenceQueryWrapper sq = new SpanSequenceQueryWrapper("base");
+        sq.append("i:a").append("i:b").withConstraint(0, 3, "e");
+
+        Result kr = ki.search(sq.toQuery(), (short) 10);
+
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("doc-number", "match-doc-0-p3-6", kr.getMatch(0).getID());
+        assertEquals("doc-number", "match-doc-1-p1-3", kr.getMatch(1).getID());
+        assertEquals("doc-number", "match-doc-3-p3-6", kr.getMatch(2).getID());
+    };
+
+
+    @Test
+    public void indexExample9 () throws IOException {
+        KrillIndex ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanQuery sq = new SpanNextQuery(new SpanOrQuery(new SpanTermQuery(
+                new Term("base", "s:a")), new SpanTermQuery(new Term("base",
+                "s:b"))), new SpanTermQuery(new Term("base", "s:c")));
+
+        Result kr = ki.search(sq, (short) 10);
+
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    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]");
+
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
index d9baef3..c31fa1f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
@@ -40,46 +40,40 @@
         KrillIndex ki = new KrillIndex();
 
         FieldDocument fd = new FieldDocument();
-        fd.addTV("base",
-                 "a b c",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(2-3)s:b|i:b|_1#2-3]" +
-                 "[(4-5)s:c|i:c|_2#4-5]");
+        fd.addTV("base", "a b c", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(2-3)s:b|i:b|_1#2-3]" + "[(4-5)s:c|i:c|_2#4-5]");
         ki.addDoc(fd);
 
         fd = new FieldDocument();
-        fd.addTV("base",
-                 "x  y  z",
-                 "[(0-1)s:x|i:x|_0#0-2|-:t$<i>3]" +
-                 "[(3-4)s:y|i:y|_1#3-4]" +
-                 "[(6-7)s:z|i:z|_2#6-7]");  // 3
+        fd.addTV("base", "x  y  z", "[(0-1)s:x|i:x|_0#0-2|-:t$<i>3]"
+                + "[(3-4)s:y|i:y|_1#3-4]" + "[(6-7)s:z|i:z|_2#6-7]");  // 3
         ki.addDoc(fd);
-                ki.commit();
-        
+        ki.commit();
+
         String field = "base";
         for (AtomicReaderContext atomic : ki.reader().leaves()) {
             PositionsToOffset pto = new PositionsToOffset(atomic, field);
 
-            pto.add(0,1);
-            pto.add(0,2);
-            pto.add(1,2);
-            pto.add(1,1);
-            pto.add(1,20);
+            pto.add(0, 1);
+            pto.add(0, 2);
+            pto.add(1, 2);
+            pto.add(1, 1);
+            pto.add(1, 20);
 
-            assertEquals("Start 0,1", pto.start(0,1), 2);
-            assertEquals("End 0,1", pto.end(0,1), 3);
+            assertEquals("Start 0,1", pto.start(0, 1), 2);
+            assertEquals("End 0,1", pto.end(0, 1), 3);
 
-            assertEquals("Start 0,2", pto.start(0,2), 4);
-            assertEquals("End 0,2", pto.end(0,2), 5);
+            assertEquals("Start 0,2", pto.start(0, 2), 4);
+            assertEquals("End 0,2", pto.end(0, 2), 5);
 
-            assertEquals("Start 1,2", pto.start(1,2), 6);
-            assertEquals("End 1,2", pto.end(1,2), 7);
+            assertEquals("Start 1,2", pto.start(1, 2), 6);
+            assertEquals("End 1,2", pto.end(1, 2), 7);
 
-            assertEquals("Start 1,1", pto.start(1,1), 3);
-            assertEquals("End 1,1", pto.end(1,1), 4);
-            
-            assertEquals("Start 1,20", pto.start(1,20), 0);
-            assertEquals("End 1,20", pto.end(1,20), -1);
+            assertEquals("Start 1,1", pto.start(1, 1), 3);
+            assertEquals("End 1,1", pto.end(1, 1), 4);
+
+            assertEquals("Start 1,20", pto.start(1, 20), 0);
+            assertEquals("End 1,20", pto.end(1, 20), -1);
         };
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
index aa1478e..837da00 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
@@ -22,22 +22,25 @@
     KrillIndex ki;
     Result kr;
     Krill ks;
-	
-    public TestRealIndex() throws IOException {
+
+
+    public TestRealIndex () throws IOException {
         InputStream is = getClass().getResourceAsStream("/server.properties");
         Properties prop = new Properties();
         prop.load(is);
-	
+
         String indexPath = prop.getProperty("lucene.indexDir");
         System.err.println(indexPath);
         MMapDirectory md = new MMapDirectory(new File(indexPath));
         ki = new KrillIndex(md);
     };
 
+
     @Test
-    public void testCase1() throws IOException, QueryException {
+    public void testCase1 () throws IOException, QueryException {
         QueryBuilder kq = new QueryBuilder("tokens");
-        ks = new Krill(kq.within(kq.tag("base/s:s"), kq.seq(kq.re("s:.*")).append(kq._(kq.re("s:.*")))).toQuery());
+        ks = new Krill(kq.within(kq.tag("base/s:s"),
+                kq.seq(kq.re("s:.*")).append(kq._(kq.re("s:.*")))).toQuery());
         ks.getMeta().setTimeOut(10000);
         kr = ks.apply(ki);
         System.err.println(kr.toJsonString());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
index c8bd475..fdb1c81 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -29,258 +29,304 @@
 
     @Test
     public void indexRegex () throws Exception {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addTV("base",
-		 "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
-		 "[(0-4)s:affe|_0#0-4|-:t$<i>10]" +
-		 "[(5-10)s:afffe|_1#5-10]" +
-		 "[(11-15)s:baum|_2#11-15]" +
-		 "[(16-26)s:baumgarten|_3#16-26]" +
-		 "[(27-38)s:steingarten|_4#27-38]" +
-		 "[(39-44)s:franz|_5#39-44]" +
-		 "[(45-49)s:hans|_6#45-49]" +
-		 "[(50-54)s:haus|_7#50-54]" +
-		 "[(55-59)s:efeu|_8#55-59]" +
-		 "[(60-64)s:effe|_9#60-64]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addTV(
+                "base",
+                "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
+                "[(0-4)s:affe|_0#0-4|-:t$<i>10]" + "[(5-10)s:afffe|_1#5-10]"
+                        + "[(11-15)s:baum|_2#11-15]"
+                        + "[(16-26)s:baumgarten|_3#16-26]"
+                        + "[(27-38)s:steingarten|_4#27-38]"
+                        + "[(39-44)s:franz|_5#39-44]"
+                        + "[(45-49)s:hans|_6#45-49]"
+                        + "[(50-54)s:haus|_7#50-54]"
+                        + "[(55-59)s:efeu|_8#55-59]"
+                        + "[(60-64)s:effe|_9#60-64]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("base");
-	SpanQuery sq = kq.re("s:af*e").toQuery();
-	assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sq.toString());
-			
-	Krill ks = new Krill(sq);
-	ks.getMeta().getContext().left.setToken(true).setLength(1);
-	ks.getMeta().getContext().right.setToken(true).setLength(1);
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.re("s:af*e").toQuery();
+        assertEquals("SpanMultiTermQueryWrapper(base:/s:af*e/)", sq.toString());
 
-	Result kr = ki.search(ks);
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(1);
+        ks.getMeta().getContext().right.setToken(true).setLength(1);
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1).getSnippetBrackets());
+        Result kr = ki.search(ks);
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("affe [afffe] baum ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.....?garten").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... franz [hans] haus ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... hans [haus] efeu ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
+                "s:.....?garten").toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*ff.*").toQuery()));
-	assertEquals((long) 3, kr.getTotalResults());
-	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
-	assertEquals("... efeu [effe]", kr.getMatch(2).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... franz [hans] haus ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... hans [haus] efeu ...", kr.getMatch(1)
+                .getSnippetBrackets());
+
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*ff.*")
+                .toQuery()));
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("affe [afffe] baum ...", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("... efeu [effe]", kr.getMatch(2).getSnippetBrackets());
     };
 
+
     @Test
     public void indexWildcard () throws Exception {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addTV("base",
-		 "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
-		 "[(0-4)s:affe|_0#0-4|-:t$<i>10]" +
-		 "[(5-10)s:afffe|_1#5-10]" +
-		 "[(11-15)s:baum|_2#11-15]" +
-		 "[(16-26)s:baumgarten|_3#16-26]" +
-		 "[(27-38)s:steingarten|_4#27-38]" +
-		 "[(39-44)s:franz|_5#39-44]" +
-		 "[(45-49)s:hans|_6#45-49]" +
-		 "[(50-54)s:haus|_7#50-54]" +
-		 "[(55-59)s:efeu|_8#55-59]" +
-		 "[(60-64)s:effe|_9#60-64]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addTV(
+                "base",
+                "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
+                "[(0-4)s:affe|_0#0-4|-:t$<i>10]" + "[(5-10)s:afffe|_1#5-10]"
+                        + "[(11-15)s:baum|_2#11-15]"
+                        + "[(16-26)s:baumgarten|_3#16-26]"
+                        + "[(27-38)s:steingarten|_4#27-38]"
+                        + "[(39-44)s:franz|_5#39-44]"
+                        + "[(45-49)s:hans|_6#45-49]"
+                        + "[(50-54)s:haus|_7#50-54]"
+                        + "[(55-59)s:efeu|_8#55-59]"
+                        + "[(60-64)s:effe|_9#60-64]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("base");
-	SpanQuery sq = kq.wc("s:af*e").toQuery();
-	assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toString());
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.wc("s:af*e").toQuery();
+        assertEquals("SpanMultiTermQueryWrapper(base:s:af*e)", sq.toString());
 
-	Krill ks = new Krill(sq);
-	ks.getMeta().getContext().left.setToken(true).setLength(1);
-	ks.getMeta().getContext().right.setToken(true).setLength(1);
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(1);
+        ks.getMeta().getContext().right.setToken(true).setLength(1);
 
-	Result kr = ki.search(ks);
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
+        Result kr = ki.search(ks);
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("affe [afffe] baum ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum.*").toQuery()));
-	assertEquals((long) 0, kr.getTotalResults());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum.*")
+                .toQuery()));
+        assertEquals((long) 0, kr.getTotalResults());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum*").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:baum*")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:*garten").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:*garten")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:ha?s").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... franz [hans] haus ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... hans [haus] efeu ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:ha?s")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... franz [hans] haus ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... hans [haus] efeu ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:?ff?").toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... efeu [effe]", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").wc("s:?ff?")
+                .toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("... efeu [effe]", kr.getMatch(1).getSnippetBrackets());
     };
 
+
     @Test
     public void indexRegexCaseInsensitive () throws Exception {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addTV("base",
-		 "AfFe aFfFE Baum Baumgarten SteinGarten franZ HaNs Haus Efeu effe",
-		 "[(0-4)s:AfFe|i:affe|_0#0-4|-:t$<i>10]" +
-		 "[(5-10)s:aFfFE|i:afffe|_1#5-10]" +
-		 "[(11-15)s:Baum|i:baum|_2#11-15]" +
-		 "[(16-26)s:Baumgarten|i:baumgarten|_3#16-26]" +
-		 "[(27-38)s:SteinGarten|i:steingarten|_4#27-38]" +
-		 "[(39-44)s:franZ|i:franz|_5#39-44]" +
-		 "[(45-49)s:HaNs|i:hans|_6#45-49]" +
-		 "[(50-54)s:Haus|i:haus|_7#50-54]" +
-		 "[(55-59)s:Efeu|i:efeu|_8#55-59]" +
-		 "[(60-64)s:effe|i:effe|_9#60-64]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addTV(
+                "base",
+                "AfFe aFfFE Baum Baumgarten SteinGarten franZ HaNs Haus Efeu effe",
+                "[(0-4)s:AfFe|i:affe|_0#0-4|-:t$<i>10]"
+                        + "[(5-10)s:aFfFE|i:afffe|_1#5-10]"
+                        + "[(11-15)s:Baum|i:baum|_2#11-15]"
+                        + "[(16-26)s:Baumgarten|i:baumgarten|_3#16-26]"
+                        + "[(27-38)s:SteinGarten|i:steingarten|_4#27-38]"
+                        + "[(39-44)s:franZ|i:franz|_5#39-44]"
+                        + "[(45-49)s:HaNs|i:hans|_6#45-49]"
+                        + "[(50-54)s:Haus|i:haus|_7#50-54]"
+                        + "[(55-59)s:Efeu|i:efeu|_8#55-59]"
+                        + "[(60-64)s:effe|i:effe|_9#60-64]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("base");
-	SpanQuery sq = kq.re("s:Af*e", true).toQuery();
-	assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sq.toString());
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.re("s:Af*e", true).toQuery();
+        assertEquals("SpanMultiTermQueryWrapper(base:/i:af*e/)", sq.toString());
 
-	Krill ks = new Krill(sq);
-	ks.getMeta().getContext().left.setToken(true).setLength(1);
-	ks.getMeta().getContext().right.setToken(true).setLength(1);
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(1);
+        ks.getMeta().getContext().right.setToken(true).setLength(1);
 
-	Result kr = ki.search(ks);
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1).getSnippetBrackets());
+        Result kr = ki.search(ks);
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:Af.*e").toQuery()));
-	assertEquals((long) 1, kr.getTotalResults());
-	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:Af.*e")
+                .toQuery()));
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*", true).toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... aFfFE [Baum] Baumgarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:baum.*",
+                true).toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... aFfFE [Baum] Baumgarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*garten", true).toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... Baumgarten [SteinGarten] franZ ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
+                "s:.*garten", true).toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... Baumgarten [SteinGarten] franZ ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*garten", false).toQuery()));
-	assertEquals((long) 1, kr.getTotalResults());
-	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re(
+                "s:.*garten", false).toQuery()));
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s", true).toQuery()));
-	assertEquals((long) 2, kr.getTotalResults());
-	assertEquals("... franZ [HaNs] Haus ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("... HaNs [Haus] Efeu ...", kr.getMatch(1).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:ha.s",
+                true).toQuery()));
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals("... franZ [HaNs] Haus ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("... HaNs [Haus] Efeu ...", kr.getMatch(1)
+                .getSnippetBrackets());
 
-	kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*f*e", true).toQuery()));
-	assertEquals((long) 3, kr.getTotalResults());
-	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
-	assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1).getSnippetBrackets());
-	assertEquals("... Efeu [effe]", kr.getMatch(2).getSnippetBrackets());
+        kr = ki.search(ks.setSpanQuery(new QueryBuilder("base").re("s:.*f*e",
+                true).toQuery()));
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
+        assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1)
+                .getSnippetBrackets());
+        assertEquals("... Efeu [effe]", kr.getMatch(2).getSnippetBrackets());
     };
 
+
     @Test
     public void indexRegexCombined () throws Exception {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addTV("base",
-		 "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
-		 "[(0-4)s:affe|_0#0-4|-:t$<i>10]" +
-		 "[(5-10)s:afffe|_1#5-10]" +
-		 "[(11-15)s:baum|_2#11-15]" +
-		 "[(16-26)s:baumgarten|_3#16-26]" +
-		 "[(27-38)s:steingarten|_4#27-38]" +
-		 "[(39-44)s:franz|_5#39-44]" +
-		 "[(45-49)s:hans|_6#45-49]" +
-		 "[(50-54)s:haus|_7#50-54]" +
-		 "[(55-59)s:efeu|_8#55-59]" +
-		 "[(60-64)s:effe|_9#60-64]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addTV(
+                "base",
+                "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
+                "[(0-4)s:affe|_0#0-4|-:t$<i>10]" + "[(5-10)s:afffe|_1#5-10]"
+                        + "[(11-15)s:baum|_2#11-15]"
+                        + "[(16-26)s:baumgarten|_3#16-26]"
+                        + "[(27-38)s:steingarten|_4#27-38]"
+                        + "[(39-44)s:franz|_5#39-44]"
+                        + "[(45-49)s:hans|_6#45-49]"
+                        + "[(50-54)s:haus|_7#50-54]"
+                        + "[(55-59)s:efeu|_8#55-59]"
+                        + "[(60-64)s:effe|_9#60-64]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("base");
-	SpanQuery sq = kq.seq(kq.seg("s:affe")).append(kq.re("s:af*e")).toQuery();
-	assertEquals("spanNext(base:s:affe, SpanMultiTermQueryWrapper(base:/s:af*e/))", sq.toString());
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.seq(kq.seg("s:affe")).append(kq.re("s:af*e"))
+                .toQuery();
+        assertEquals(
+                "spanNext(base:s:affe, SpanMultiTermQueryWrapper(base:/s:af*e/))",
+                sq.toString());
 
-	Krill ks = new Krill(sq);
-	ks.getMeta().getContext().left.setToken(true).setLength(1);
-	ks.getMeta().getContext().right.setToken(true).setLength(1);
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(1);
+        ks.getMeta().getContext().right.setToken(true).setLength(1);
 
-	Result kr = ki.search(ks);
-	assertEquals((long) 1, kr.getTotalResults());
-	assertEquals("[affe afffe] baum ...", kr.getMatch(0).getSnippetBrackets());
+        Result kr = ki.search(ks);
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals("[affe afffe] baum ...", kr.getMatch(0)
+                .getSnippetBrackets());
     };
 
 
     @Test
     public void indexRegexWithinRewrite () throws Exception {
-	KrillIndex ki = new KrillIndex();
+        KrillIndex ki = new KrillIndex();
 
-	// abcabcabac
-	FieldDocument fd = new FieldDocument();
-	fd.addTV("base",
-		 "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
-		 "[(0-4)s:affe|_0#0-4|-:t$<i>10]" +
-		 "[(5-10)s:afffe|_1#5-10]" +
-		 "[(11-15)s:baum|_2#11-15]" +
-		 "[(16-26)s:baumgarten|_3#16-26]" +
-		 "[(27-38)s:steingarten|_4#27-38]" +
-		 "[(39-44)s:franz|_5#39-44]" +
-		 "[(45-49)s:hans|_6#45-49]" +
-		 "[(50-54)s:haus|_7#50-54]" +
-		 "[(55-59)s:efeu|_8#55-59]" +
-		 "[(60-64)s:effe|_9#60-64]");
-	ki.addDoc(fd);
+        // abcabcabac
+        FieldDocument fd = new FieldDocument();
+        fd.addTV(
+                "base",
+                "affe afffe baum baumgarten steingarten franz hans haus efeu effe",
+                "[(0-4)s:affe|_0#0-4|-:t$<i>10]" + "[(5-10)s:afffe|_1#5-10]"
+                        + "[(11-15)s:baum|_2#11-15]"
+                        + "[(16-26)s:baumgarten|_3#16-26]"
+                        + "[(27-38)s:steingarten|_4#27-38]"
+                        + "[(39-44)s:franz|_5#39-44]"
+                        + "[(45-49)s:hans|_6#45-49]"
+                        + "[(50-54)s:haus|_7#50-54]"
+                        + "[(55-59)s:efeu|_8#55-59]"
+                        + "[(60-64)s:effe|_9#60-64]");
+        ki.addDoc(fd);
 
-	ki.commit();
+        ki.commit();
 
-	QueryBuilder kq = new QueryBuilder("base");
-	SpanQuery sq = kq.contains(
-				   kq.seq(
-					  kq.re("s:a.*e")
-					  ).append(
-						   kq.re("s:af*e")
-						   ),
-				   kq.seg("s:affe")).toQuery();
-	assertEquals("spanContain(spanNext(SpanMultiTermQueryWrapper(base:/s:a.*e/), SpanMultiTermQueryWrapper(base:/s:af*e/)), base:s:affe)", sq.toString());
-	Krill ks = new Krill(sq);
-	ks.getMeta().getContext().left.setToken(true).setLength(1);
-	ks.getMeta().getContext().right.setToken(true).setLength(1);
+        QueryBuilder kq = new QueryBuilder("base");
+        SpanQuery sq = kq.contains(
+                kq.seq(kq.re("s:a.*e")).append(kq.re("s:af*e")),
+                kq.seg("s:affe")).toQuery();
+        assertEquals(
+                "spanContain(spanNext(SpanMultiTermQueryWrapper(base:/s:a.*e/), SpanMultiTermQueryWrapper(base:/s:af*e/)), base:s:affe)",
+                sq.toString());
+        Krill ks = new Krill(sq);
+        ks.getMeta().getContext().left.setToken(true).setLength(1);
+        ks.getMeta().getContext().right.setToken(true).setLength(1);
 
-	Result kr = ki.search(ks);
-	assertEquals((long) 1, kr.getTotalResults());
-	assertEquals("[affe afffe] baum ...", kr.getMatch(0).getSnippetBrackets());
+        Result kr = ki.search(ks);
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals("[affe afffe] baum ...", kr.getMatch(0)
+                .getSnippetBrackets());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index c38135a..838a572 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -20,7 +20,7 @@
 import de.ids_mannheim.korap.response.Match;
 import de.ids_mannheim.korap.response.Result;
 
-    /*
+/*
 
 within(x,y)
 
@@ -57,481 +57,491 @@
 -> [p:VVFIN](>SUBJ[nr:sg] & >OBJ[c:dat])
 
 
-     */
+ */
 
 public class TestRelationIndex {
-	private KrillIndex ki;
-	private Result kr;
+    private KrillIndex ki;
+    private Result kr;
 
-	public TestRelationIndex() throws IOException {
-		ki = new KrillIndex();
-	}
-	
-	private FieldDocument createFieldDoc0(){
-    	FieldDocument fd = new FieldDocument();
+
+    public TestRelationIndex () throws IOException {
+        ki = new KrillIndex();
+    }
+
+
+    private FieldDocument createFieldDoc0 () {
+        FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
-        fd.addTV("base", "ceccecdeed",
-			"[(0-1)s:c$<s>1|_0#0-1|>:xip/syntax-dep_rel$<i>6<s>1<s>1<s>1]"+
-            "[(1-2)s:e$<s>1|_1#1-2|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1|>:xip/syntax-dep_rel$<i>4<s>1<s>1<s>1]" +             
-            "[(2-3)s:c|_2#2-3]" +
-            "[(3-4)s:c$<s>1|s:b$<s>2|_3#3-4|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1]" + 
-            "[(4-5)s:e$<s>1|s:d$<s>2|_4#4-5|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]" +
-            "[(5-6)s:c|_5#5-6]" +
-            "[(6-7)s:d$<s>1|_6#6-7|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]" +
-            "[(7-8)s:e|_7#7-8]" + 
-            "[(8-9)s:e|s:b|_8#8-9]" + 
-            "[(9-10)s:d$<s>1|_9#9-10|>:xip/syntax-dep_rel$<i>1<s>2<s>1<s>1|>:xip/syntax-dep_rel$<i>3<s>1<s>1<s>1]");
+        fd.addTV(
+                "base",
+                "ceccecdeed",
+                "[(0-1)s:c$<s>1|_0#0-1|>:xip/syntax-dep_rel$<i>6<s>1<s>1<s>1]"
+                        + "[(1-2)s:e$<s>1|_1#1-2|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1|>:xip/syntax-dep_rel$<i>4<s>1<s>1<s>1]"
+                        + "[(2-3)s:c|_2#2-3]"
+                        + "[(3-4)s:c$<s>1|s:b$<s>2|_3#3-4|<:xip/syntax-dep_rel$<i>9<s>1<s>1<s>1]"
+                        + "[(4-5)s:e$<s>1|s:d$<s>2|_4#4-5|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]"
+                        + "[(5-6)s:c|_5#5-6]"
+                        + "[(6-7)s:d$<s>1|_6#6-7|<:xip/syntax-dep_rel$<i>1<s>1<s>1<s>1]"
+                        + "[(7-8)s:e|_7#7-8]"
+                        + "[(8-9)s:e|s:b|_8#8-9]"
+                        + "[(9-10)s:d$<s>1|_9#9-10|>:xip/syntax-dep_rel$<i>1<s>2<s>1<s>1|>:xip/syntax-dep_rel$<i>3<s>1<s>1<s>1]");
         return fd;
     }
-	
-	private FieldDocument createFieldDoc1(){
-    	FieldDocument fd = new FieldDocument();
+
+
+    private FieldDocument createFieldDoc1 () {
+        FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
-        fd.addTV("base", "ceccecdeed",
-            "[(0-1)s:c$<s>2|<>:p$#0-3$<i>3<s>1|_0#0-1|" +
-            	">:xip/syntax-dep_rel$<i>3<i>6<i>9<s>2<s>1<s>1|" +
-            	">:xip/syntax-dep_rel$<i>6<i>9<s>1<s>2<s>1|" +
-            	"r@:func=subj$<s>2]"+
-            "[(1-2)s:e|_1#1-2|<>:p#1-3$<i>3<s>1]" +             
-            "[(2-3)s:c|_2#2-3]" +
-            "[(3-4)s:c|s:b|_3#3-4]" + 
-            "[(4-5)s:e|s:d|_4#4-5]" +
-            "[(5-6)s:c|_5#5-6]" +
-            "[(6-7)s:d$<s>2|<>:p$#6-9$<i>9<s>1|_6#6-7|" +
-            	"<:xip/syntax-dep_rel$<i>9<b>0<i>1<s>1<s>1<s>2|" +
-            	">:xip/syntax-dep_rel$<i>9<b>0<i>9<s>3<s>1<s>1|"+
-            	"<:xip/syntax-dep_rel$<i>9<i>1<i>3<s>2<s>1<s>1|" +
-            	"r@:func=obj$<s>2]" + 
-            "[(7-8)s:e|_7#7-8]" +
-            "[(8-9)s:e|s:b|_8#8-9]" + 
-            "[(9-10)s:d$<s>1|_9#9-10|<:xip/syntax-dep_rel$<i>6<i>9<s>2<s>1<s>1]");
+        fd.addTV(
+                "base",
+                "ceccecdeed",
+                "[(0-1)s:c$<s>2|<>:p$#0-3$<i>3<s>1|_0#0-1|"
+                        + ">:xip/syntax-dep_rel$<i>3<i>6<i>9<s>2<s>1<s>1|"
+                        + ">:xip/syntax-dep_rel$<i>6<i>9<s>1<s>2<s>1|"
+                        + "r@:func=subj$<s>2]"
+                        + "[(1-2)s:e|_1#1-2|<>:p#1-3$<i>3<s>1]"
+                        + "[(2-3)s:c|_2#2-3]"
+                        + "[(3-4)s:c|s:b|_3#3-4]"
+                        + "[(4-5)s:e|s:d|_4#4-5]"
+                        + "[(5-6)s:c|_5#5-6]"
+                        + "[(6-7)s:d$<s>2|<>:p$#6-9$<i>9<s>1|_6#6-7|"
+                        + "<:xip/syntax-dep_rel$<i>9<b>0<i>1<s>1<s>1<s>2|"
+                        + ">:xip/syntax-dep_rel$<i>9<b>0<i>9<s>3<s>1<s>1|"
+                        + "<:xip/syntax-dep_rel$<i>9<i>1<i>3<s>2<s>1<s>1|"
+                        + "r@:func=obj$<s>2]"
+                        + "[(7-8)s:e|_7#7-8]"
+                        + "[(8-9)s:e|s:b|_8#8-9]"
+                        + "[(9-10)s:d$<s>1|_9#9-10|<:xip/syntax-dep_rel$<i>6<i>9<s>2<s>1<s>1]");
         return fd;
     }
-	
-	private FieldDocument createFieldDoc2(){
-    	FieldDocument fd = new FieldDocument();
+
+
+    private FieldDocument createFieldDoc2 () {
+        FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
-        fd.addTV("base",
-            "Ich kaufe die Blümen für meine Mutter.",             
-            "[(0-3)s:Ich|_0#0-3|pos:NN$<s>1|<>:s#0-38$<i>7<s>2|<>:np#0-3$<i>1<s>3|" +
-            	">:child-of$<i>0<i>7<s>1<s>3<s>2|" +
-            	">:child-of$<i>0<i>1<s>6<s>1<s>3|" +
-            	"<:child-of$<i>1<b>0<i>1<s>3<s>3<s>1|" +
-            	"<:child-of$<i>7<i>0<i>1<s>4<s>2<s>3|" +
-            	"<:child-of$<i>7<i>1<i>7<s>5<s>2<s>2|" +
-            	"<:dep$<i>2<s>2<s>1<s>1|" +
-            	"r@:func=sbj$<i>0<i>7<s>1]"+            	
-            	
-            "[(1-2)s:kaufe|_1#4-9|pos:V$<s>1|<>:vp#4-38$<i>7<s>2|" +
-            	">:child-of$<i>7<i>0<i>7<s>1<s>2<s>2|"+
-            	">:child-of$<i>1<i>7<s>2<s>1<s>2|" +
-            	"<:child-of$<i>7<b>0<i>2<s>5<s>2<s>1|" +
-            	"<:child-of$<i>7<i>2<i>7<s>6<s>2<s>4|" +
-            	">:dep$<i>1<s>3<s>1<s>1|" +
-            	">:dep$<i>4<s>4<s>1<s>1]" +
-            	
-            "[(2-3)s:die|_2#10-13|pos:ART$<s>1|tt:DET$<s>2|<>:np#10-20$<i>4<s>3|<>:np#10-38$<i>7<s>4|" +
-            	">:child-of$<i>4<i>2<i>7<s>1<s>3<s>4|" +
-            	">:child-of$<i>2<i>4<s>2<s>1<s>3|" +
-            	">:child-of$<i>7<i>1<i>7<s>2<s>4<s>2|" +
-            	"<:child-of$<i>4<b>0<i>3<s>3<s>3<s>1|" +
-            	"<:child-of$<i>4<b>0<i>4<s>4<s>3<s>1|" +
-            	"<:child-of$<i>7<i>2<i>4<s>5<s>4<s>3|" +
-            	"<:child-of$<i>7<i>4<i>7<s>6<s>4<s>2|" +
-            	"<:dep$<i>4<s>3<s>1<s>1|" +
-            	"r@:func=obj$<i>2<i>7<s>1]" +
-            
-            "[(3-4)s:Blümen|_3#14-20|pos:NN$<s>1|" +
-            	">:child-of$<i>2<i>4<s>1<s>1<s>3|" +            	
-            	"<:dep$<i>2<s>2<s>1<s>2|" +
-            	">:dep$<i>3<s>3<s>1<s>1|" +
-            	">:dep$<i>5<s>4<s>1<s>1|" +
-            	"r@:func=head$<i>2<i>4<s>2]" +
-            	
-            "[(4-5)s:für|_4#21-24|pos:PREP$<s>1|<>:pp#21-38$<i>7<s>2|" +
-            	">:child-of$<i>4<i>7<s>1<s>1<s>2|" +
-            	">:child-of$<i>7<i>2<i>7<s>2<s>2<s>4|" +
-            	"<:child-of$<i>7<b>0<i>5<s>4<s>2<s>1|" +
-            	"<:child-of$<i>7<i>5<i>7<s>5<s>2<s>2|" +
-            	"<:dep$<i>4<s>1<s>1<s>1|" +
-            	">:dep$<i>7<s>3<s>1<s>1]" +
-            
-            "[(5-6)s:meine|_5#25-30|pos:ART$<s>1|<>:np#25-38$<i>7<s>2|" +
-            	">:child-of$<i>5<i>7<s>1<s>1<s>2|" +
-            	">:child-of$<i>7<i>4<i>7<s>2<s>2<s>2|" +
-            	"<:child-of$<i>7<b>0<i>6<s>4<s>2<s>1|" +
-            	"<:child-of$<i>7<b>0<i>7<s>5<s>2<s>1|" +
-            	"<:dep$<i>7<s>3<s>1<s>1]" +
-            	
-            "[(6-7)s:Mutter.|_6#31-38|pos:NN$<s>1|" +
-            	">:child-of$<i>5<i>7<s>1<s>1<s>2|" +
-            	">:dep$<i>6<s>2<s>1<s>1|" +
-            	"<:dep$<i>5<s>3<s>1<s>1|" +
-        		"r@:func=head$<i>6<i>7<s>3]");
-        
+        fd.addTV(
+                "base",
+                "Ich kaufe die Blümen für meine Mutter.",
+                "[(0-3)s:Ich|_0#0-3|pos:NN$<s>1|<>:s#0-38$<i>7<s>2|<>:np#0-3$<i>1<s>3|"
+                        + ">:child-of$<i>0<i>7<s>1<s>3<s>2|"
+                        + ">:child-of$<i>0<i>1<s>6<s>1<s>3|"
+                        + "<:child-of$<i>1<b>0<i>1<s>3<s>3<s>1|"
+                        + "<:child-of$<i>7<i>0<i>1<s>4<s>2<s>3|"
+                        + "<:child-of$<i>7<i>1<i>7<s>5<s>2<s>2|"
+                        + "<:dep$<i>2<s>2<s>1<s>1|"
+                        + "r@:func=sbj$<i>0<i>7<s>1]"
+                        +
+
+                        "[(1-2)s:kaufe|_1#4-9|pos:V$<s>1|<>:vp#4-38$<i>7<s>2|"
+                        + ">:child-of$<i>7<i>0<i>7<s>1<s>2<s>2|"
+                        + ">:child-of$<i>1<i>7<s>2<s>1<s>2|"
+                        + "<:child-of$<i>7<b>0<i>2<s>5<s>2<s>1|"
+                        + "<:child-of$<i>7<i>2<i>7<s>6<s>2<s>4|"
+                        + ">:dep$<i>1<s>3<s>1<s>1|"
+                        + ">:dep$<i>4<s>4<s>1<s>1]"
+                        +
+
+                        "[(2-3)s:die|_2#10-13|pos:ART$<s>1|tt:DET$<s>2|<>:np#10-20$<i>4<s>3|<>:np#10-38$<i>7<s>4|"
+                        + ">:child-of$<i>4<i>2<i>7<s>1<s>3<s>4|"
+                        + ">:child-of$<i>2<i>4<s>2<s>1<s>3|"
+                        + ">:child-of$<i>7<i>1<i>7<s>2<s>4<s>2|"
+                        + "<:child-of$<i>4<b>0<i>3<s>3<s>3<s>1|"
+                        + "<:child-of$<i>4<b>0<i>4<s>4<s>3<s>1|"
+                        + "<:child-of$<i>7<i>2<i>4<s>5<s>4<s>3|"
+                        + "<:child-of$<i>7<i>4<i>7<s>6<s>4<s>2|"
+                        + "<:dep$<i>4<s>3<s>1<s>1|"
+                        + "r@:func=obj$<i>2<i>7<s>1]" +
+
+                        "[(3-4)s:Blümen|_3#14-20|pos:NN$<s>1|"
+                        + ">:child-of$<i>2<i>4<s>1<s>1<s>3|"
+                        + "<:dep$<i>2<s>2<s>1<s>2|" + ">:dep$<i>3<s>3<s>1<s>1|"
+                        + ">:dep$<i>5<s>4<s>1<s>1|"
+                        + "r@:func=head$<i>2<i>4<s>2]" +
+
+                        "[(4-5)s:für|_4#21-24|pos:PREP$<s>1|<>:pp#21-38$<i>7<s>2|"
+                        + ">:child-of$<i>4<i>7<s>1<s>1<s>2|"
+                        + ">:child-of$<i>7<i>2<i>7<s>2<s>2<s>4|"
+                        + "<:child-of$<i>7<b>0<i>5<s>4<s>2<s>1|"
+                        + "<:child-of$<i>7<i>5<i>7<s>5<s>2<s>2|"
+                        + "<:dep$<i>4<s>1<s>1<s>1|" + ">:dep$<i>7<s>3<s>1<s>1]"
+                        +
+
+                        "[(5-6)s:meine|_5#25-30|pos:ART$<s>1|<>:np#25-38$<i>7<s>2|"
+                        + ">:child-of$<i>5<i>7<s>1<s>1<s>2|"
+                        + ">:child-of$<i>7<i>4<i>7<s>2<s>2<s>2|"
+                        + "<:child-of$<i>7<b>0<i>6<s>4<s>2<s>1|"
+                        + "<:child-of$<i>7<b>0<i>7<s>5<s>2<s>1|"
+                        + "<:dep$<i>7<s>3<s>1<s>1]" +
+
+                        "[(6-7)s:Mutter.|_6#31-38|pos:NN$<s>1|"
+                        + ">:child-of$<i>5<i>7<s>1<s>1<s>2|"
+                        + ">:dep$<i>6<s>2<s>1<s>1|" + "<:dep$<i>5<s>3<s>1<s>1|"
+                        + "r@:func=head$<i>6<i>7<s>3]");
+
         return fd;
     }
-	
-	/** Relations: token to token, token to span, span to span
-	 * */
-	@Test
-	public void testCase1() throws IOException {
-		ki.addDoc(createFieldDoc0());
-		ki.addDoc(createFieldDoc1());
-		ki.commit();
-		
-		SpanRelationQuery sq = new SpanRelationQuery(new SpanTermQuery(
-				new Term("base", ">:xip/syntax-dep_rel")), true);
-		kr = ki.search(sq, (short) 10);
-		
-		assertEquals((long) 7, kr.getTotalResults());
-		// token to token
-		assertEquals(0, kr.getMatch(0).getLocalDocID());
-		assertEquals(0, kr.getMatch(0).getStartPos());
-		assertEquals(1, kr.getMatch(0).getEndPos());
-		assertEquals(1, kr.getMatch(1).getStartPos());
-		assertEquals(2, kr.getMatch(1).getEndPos());
-		assertEquals(9, kr.getMatch(2).getStartPos());
-		assertEquals(10, kr.getMatch(2).getEndPos());
-		assertEquals(9, kr.getMatch(3).getStartPos());
-		assertEquals(10, kr.getMatch(3).getEndPos());
 
-		// token to span
-		assertEquals(1,kr.getMatch(4).getLocalDocID());
-		assertEquals(0,kr.getMatch(4).getStartPos());
-		assertEquals(1, kr.getMatch(4).getEndPos());
-		assertEquals(0,kr.getMatch(5).getStartPos());
-		assertEquals(3, kr.getMatch(5).getEndPos());
-		
-		// span to span
-		assertEquals(6,kr.getMatch(6).getStartPos());
-		assertEquals(9, kr.getMatch(6).getEndPos());
 
-		// check target
+    /**
+     * Relations: token to token, token to span, span to span
+     * */
+    @Test
+    public void testCase1 () throws IOException {
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
 
-	}
-	
-	/** Relation span to token
-	 * */
-	@Test
-	public void testCase2() throws IOException {
-		ki.addDoc(createFieldDoc0());
-		ki.addDoc(createFieldDoc1());
-		ki.commit();
-		
-		SpanRelationQuery sq = new SpanRelationQuery(new SpanTermQuery(
-				new Term("base", "<:xip/syntax-dep_rel")), true);
-		kr = ki.search(sq,(short) 10);
-		
-		assertEquals((long) 7, kr.getTotalResults());
-		// token to token
-		assertEquals(0,kr.getMatch(0).getLocalDocID());
-		assertEquals(1,kr.getMatch(0).getStartPos());
-		assertEquals(2, kr.getMatch(0).getEndPos());
-		assertEquals(3, kr.getMatch(1).getStartPos());
-		assertEquals(4, kr.getMatch(1).getEndPos());
-		assertEquals(4, kr.getMatch(2).getStartPos());
-		assertEquals(5, kr.getMatch(2).getEndPos());
-		assertEquals(6, kr.getMatch(3).getStartPos());
-		assertEquals(7, kr.getMatch(3).getEndPos());
-		
-		assertEquals(1,kr.getMatch(4).getLocalDocID());
-		// span to token
-		assertEquals(6, kr.getMatch(4).getStartPos());
-		assertEquals(9,kr.getMatch(4).getEndPos());
-		assertEquals(6, kr.getMatch(5).getStartPos());
-		assertEquals(9,kr.getMatch(5).getEndPos());
-		// span to span
-		assertEquals(9, kr.getMatch(6).getStartPos());
-		assertEquals(10,kr.getMatch(6).getEndPos());
-	}
-	
-	/** Relations with attributes
-	 * 	NEED focusMulti on span relation query before SpanWithAttributeQuery 
-	 * */
-	/* @Test
-	public void testCase3() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		// child-of relations
-		SpanRelationQuery srq= new SpanRelationQuery(new SpanTermQuery(
-				new Term("base", ">:child-of")), true);
-		kr = ki.search(srq,(short) 20);
-		
-		assertEquals((long) 13, kr.getTotalResults());
+        SpanRelationQuery sq = new SpanRelationQuery(new SpanTermQuery(
+                new Term("base", ">:xip/syntax-dep_rel")), true);
+        kr = ki.search(sq, (short) 10);
 
-		// child-of with attr func=sbj
-		SpanWithAttributeQuery wq = 
-			new SpanWithAttributeQuery(srq, 
-				new SpanAttributeQuery( 
-					new SpanTermQuery(new Term("base", "r@:func=sbj")),
-					true), 
-				true
-		);
-		
-		kr = ki.search(wq,(short) 10);		
-		assertEquals((long) 1, kr.getTotalResults());
-		assertEquals(0,kr.getMatch(0).getStartPos()); // token
-		assertEquals(1, kr.getMatch(0).getEndPos());
-		
-		// child-of without attr func=sbj
-		wq = 
-			new SpanWithAttributeQuery(srq, 
-				new SpanAttributeQuery( 
-					new SpanTermQuery(new Term("base", "r@:func=sbj")),
-					true, true), 
-				true
-		);
-		kr = ki.search(wq,(short) 20);
-		assertEquals((long) 12, kr.getTotalResults());
+        assertEquals((long) 7, kr.getTotalResults());
+        // token to token
+        assertEquals(0, kr.getMatch(0).getLocalDocID());
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(1, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(2, kr.getMatch(1).getEndPos());
+        assertEquals(9, kr.getMatch(2).getStartPos());
+        assertEquals(10, kr.getMatch(2).getEndPos());
+        assertEquals(9, kr.getMatch(3).getStartPos());
+        assertEquals(10, kr.getMatch(3).getEndPos());
 
-		// child-of with attr func-obj
-		wq = new SpanWithAttributeQuery(srq,
-				new SpanAttributeQuery( 
-					new SpanTermQuery( new Term("base", "r@:func=obj")),
-					true), 
-				true
-		);
-		
-		kr = ki.search(wq,(short) 10);
-		assertEquals((long) 1, kr.getTotalResults());
-		assertEquals(2,kr.getMatch(0).getStartPos()); // element
-		assertEquals(4,kr.getMatch(0).getEndPos());
+        // token to span
+        assertEquals(1, kr.getMatch(4).getLocalDocID());
+        assertEquals(0, kr.getMatch(4).getStartPos());
+        assertEquals(1, kr.getMatch(4).getEndPos());
+        assertEquals(0, kr.getMatch(5).getStartPos());
+        assertEquals(3, kr.getMatch(5).getEndPos());
 
-		// target of a dependency relation		
-		srq = new SpanRelationQuery(
-				new SpanTermQuery(new Term("base", "<:dep")), true);
-		kr = ki.search(srq,(short) 10);
-		
-		assertEquals((long) 6, kr.getTotalResults());
+        // span to span
+        assertEquals(6, kr.getMatch(6).getStartPos());
+        assertEquals(9, kr.getMatch(6).getEndPos());
 
-		// target of a dependency relation, which is also a head
-		wq = new SpanWithAttributeQuery(srq, 
-					new SpanAttributeQuery( 
-						new SpanTermQuery( new Term("base", "r@:func=head")),
-						true), 
-					true
-			);
-		
-		kr = ki.search(wq,(short) 20);
-		// for (Match km : kr.getMatches()) {
-		// System.out.println(km.getStartPos() + "," + km.getEndPos() + " "
-		// + km.getSnippetBrackets());
-		// }
-		assertEquals((long) 2, kr.getTotalResults());
-		assertEquals(3, kr.getMatch(0).getStartPos());
-		assertEquals(4,kr.getMatch(0).getEndPos());
-		assertEquals(6, kr.getMatch(1).getStartPos());
-		assertEquals(7, kr.getMatch(1).getEndPos());
-		
-	}
-	
-	// FOCUS has not sorted
-	/** Relation with variable
-	 * 	match right, return left
-	 * 	sort by right, then sort by left
-	 * @throws IOException 
-	 * */
-	/*@Test
-	public void testCase4() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		//return all children of np
-		SpanQuery rv = new SpanFocusQuery(
-		    new SpanSegmentQuery(
-			    new SpanRelationQuery(
-			       new SpanTermQuery(new Term("base","<:child-of")), true), 
-			       new SpanElementQuery("base","np"),
-			true),
-		(byte) 2);
-				
-		kr = ki.search(rv,(short) 10);
-		for (Match km : kr.getMatches()) {
-			System.out.println(km.getStartPos() + "," + km.getEndPos() 
-			// + " "+ km.getSnippetBrackets()
-					);
-		}
+        // check target
 
-		assertEquals((long) 7, kr.getTotalResults());
-		assertEquals(0,kr.getMatch(0).getStartPos());
-		assertEquals(1,kr.getMatch(0).getEndPos());
-		assertEquals(2,kr.getMatch(1).getStartPos());
-		assertEquals(3,kr.getMatch(1).getEndPos());
-		assertEquals(2,kr.getMatch(2).getStartPos());
-		assertEquals(4,kr.getMatch(2).getEndPos());
-		assertEquals(3,kr.getMatch(3).getStartPos());
-		assertEquals(4,kr.getMatch(3).getEndPos());
-		assertEquals(4,kr.getMatch(4).getStartPos());
-		assertEquals(7,kr.getMatch(4).getEndPos());
-		assertEquals(5,kr.getMatch(5).getStartPos());
-		assertEquals(6,kr.getMatch(5).getEndPos());
-		assertEquals(6,kr.getMatch(6).getStartPos());
-		assertEquals(7,kr.getMatch(6).getEndPos());		
-		// sorting left problem (solved)
-		
-		//return all children of np that are articles
-		SpanSegmentQuery rv2 = new SpanSegmentQuery(rv, new SpanTermQuery(new Term("base","pos:ART")));		
-		kr = ki.search(rv2,(short) 10);
-				
-		assertEquals((long) 2, kr.getTotalResults());
-		assertEquals(2,kr.getMatch(0).getStartPos());
-		assertEquals(3,kr.getMatch(0).getEndPos());
-		assertEquals(5,kr.getMatch(1).getStartPos());
-		assertEquals(6,kr.getMatch(1).getEndPos());
-		
-		// return all nps whose children are articles
-		/*SpanRelationPartQuery rv3 = 
-			new SpanRelationPartQuery(rv, 
-				new SpanTermWithIdQuery(new Term("base","pos:ART"), true), 
-				false, true, true); 
-		kr = ki.search(rv3,(short) 10);
-		 
-		assertEquals((long) 2, kr.getTotalResults());
-		assertEquals(2,kr.getMatch(0).getStartPos());
-		assertEquals(4,kr.getMatch(0).getEndPos());
-		assertEquals(5,kr.getMatch(1).getStartPos());
-		assertEquals(7,kr.getMatch(1).getEndPos());
-		
-		*/
-	//}
-	
-	/** Match left return left
-	 *  Match right return right
-	 * */
-	@Test
-    public void testCase5() throws IOException {
+    }
+
+
+    /**
+     * Relation span to token
+     * */
+    @Test
+    public void testCase2 () throws IOException {
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanRelationQuery sq = new SpanRelationQuery(new SpanTermQuery(
+                new Term("base", "<:xip/syntax-dep_rel")), true);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals((long) 7, kr.getTotalResults());
+        // token to token
+        assertEquals(0, kr.getMatch(0).getLocalDocID());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getStartPos());
+        assertEquals(4, kr.getMatch(1).getEndPos());
+        assertEquals(4, kr.getMatch(2).getStartPos());
+        assertEquals(5, kr.getMatch(2).getEndPos());
+        assertEquals(6, kr.getMatch(3).getStartPos());
+        assertEquals(7, kr.getMatch(3).getEndPos());
+
+        assertEquals(1, kr.getMatch(4).getLocalDocID());
+        // span to token
+        assertEquals(6, kr.getMatch(4).getStartPos());
+        assertEquals(9, kr.getMatch(4).getEndPos());
+        assertEquals(6, kr.getMatch(5).getStartPos());
+        assertEquals(9, kr.getMatch(5).getEndPos());
+        // span to span
+        assertEquals(9, kr.getMatch(6).getStartPos());
+        assertEquals(10, kr.getMatch(6).getEndPos());
+    }
+
+
+    /**
+     * Relations with attributes
+     * NEED focusMulti on span relation query before
+     * SpanWithAttributeQuery
+     * */
+    /* @Test
+    public void testCase3() throws IOException {
+    	ki.addDoc(createFieldDoc2());
+    	ki.commit();
+    	
+    	// child-of relations
+    	SpanRelationQuery srq= new SpanRelationQuery(new SpanTermQuery(
+    			new Term("base", ">:child-of")), true);
+    	kr = ki.search(srq,(short) 20);
+    	
+    	assertEquals((long) 13, kr.getTotalResults());
+
+    	// child-of with attr func=sbj
+    	SpanWithAttributeQuery wq = 
+    		new SpanWithAttributeQuery(srq, 
+    			new SpanAttributeQuery( 
+    				new SpanTermQuery(new Term("base", "r@:func=sbj")),
+    				true), 
+    			true
+    	);
+    	
+    	kr = ki.search(wq,(short) 10);		
+    	assertEquals((long) 1, kr.getTotalResults());
+    	assertEquals(0,kr.getMatch(0).getStartPos()); // token
+    	assertEquals(1, kr.getMatch(0).getEndPos());
+    	
+    	// child-of without attr func=sbj
+    	wq = 
+    		new SpanWithAttributeQuery(srq, 
+    			new SpanAttributeQuery( 
+    				new SpanTermQuery(new Term("base", "r@:func=sbj")),
+    				true, true), 
+    			true
+    	);
+    	kr = ki.search(wq,(short) 20);
+    	assertEquals((long) 12, kr.getTotalResults());
+
+    	// child-of with attr func-obj
+    	wq = new SpanWithAttributeQuery(srq,
+    			new SpanAttributeQuery( 
+    				new SpanTermQuery( new Term("base", "r@:func=obj")),
+    				true), 
+    			true
+    	);
+    	
+    	kr = ki.search(wq,(short) 10);
+    	assertEquals((long) 1, kr.getTotalResults());
+    	assertEquals(2,kr.getMatch(0).getStartPos()); // element
+    	assertEquals(4,kr.getMatch(0).getEndPos());
+
+    	// target of a dependency relation		
+    	srq = new SpanRelationQuery(
+    			new SpanTermQuery(new Term("base", "<:dep")), true);
+    	kr = ki.search(srq,(short) 10);
+    	
+    	assertEquals((long) 6, kr.getTotalResults());
+
+    	// target of a dependency relation, which is also a head
+    	wq = new SpanWithAttributeQuery(srq, 
+    				new SpanAttributeQuery( 
+    					new SpanTermQuery( new Term("base", "r@:func=head")),
+    					true), 
+    				true
+    		);
+    	
+    	kr = ki.search(wq,(short) 20);
+    	// for (Match km : kr.getMatches()) {
+    	// System.out.println(km.getStartPos() + "," + km.getEndPos() + " "
+    	// + km.getSnippetBrackets());
+    	// }
+    	assertEquals((long) 2, kr.getTotalResults());
+    	assertEquals(3, kr.getMatch(0).getStartPos());
+    	assertEquals(4,kr.getMatch(0).getEndPos());
+    	assertEquals(6, kr.getMatch(1).getStartPos());
+    	assertEquals(7, kr.getMatch(1).getEndPos());
+    	
+    }
+    
+    // FOCUS has not sorted
+    /** Relation with variable
+     * 	match right, return left
+     * 	sort by right, then sort by left
+     * @throws IOException 
+     * */
+    /*@Test
+    public void testCase4() throws IOException {
+    	ki.addDoc(createFieldDoc2());
+    	ki.commit();
+    	
+    	//return all children of np
+    	SpanQuery rv = new SpanFocusQuery(
+    	    new SpanSegmentQuery(
+    		    new SpanRelationQuery(
+    		       new SpanTermQuery(new Term("base","<:child-of")), true), 
+    		       new SpanElementQuery("base","np"),
+    		true),
+    	(byte) 2);
+    			
+    	kr = ki.search(rv,(short) 10);
+    	for (Match km : kr.getMatches()) {
+    		System.out.println(km.getStartPos() + "," + km.getEndPos() 
+    		// + " "+ km.getSnippetBrackets()
+    				);
+    	}
+
+    	assertEquals((long) 7, kr.getTotalResults());
+    	assertEquals(0,kr.getMatch(0).getStartPos());
+    	assertEquals(1,kr.getMatch(0).getEndPos());
+    	assertEquals(2,kr.getMatch(1).getStartPos());
+    	assertEquals(3,kr.getMatch(1).getEndPos());
+    	assertEquals(2,kr.getMatch(2).getStartPos());
+    	assertEquals(4,kr.getMatch(2).getEndPos());
+    	assertEquals(3,kr.getMatch(3).getStartPos());
+    	assertEquals(4,kr.getMatch(3).getEndPos());
+    	assertEquals(4,kr.getMatch(4).getStartPos());
+    	assertEquals(7,kr.getMatch(4).getEndPos());
+    	assertEquals(5,kr.getMatch(5).getStartPos());
+    	assertEquals(6,kr.getMatch(5).getEndPos());
+    	assertEquals(6,kr.getMatch(6).getStartPos());
+    	assertEquals(7,kr.getMatch(6).getEndPos());		
+    	// sorting left problem (solved)
+    	
+    	//return all children of np that are articles
+    	SpanSegmentQuery rv2 = new SpanSegmentQuery(rv, new SpanTermQuery(new Term("base","pos:ART")));		
+    	kr = ki.search(rv2,(short) 10);
+    			
+    	assertEquals((long) 2, kr.getTotalResults());
+    	assertEquals(2,kr.getMatch(0).getStartPos());
+    	assertEquals(3,kr.getMatch(0).getEndPos());
+    	assertEquals(5,kr.getMatch(1).getStartPos());
+    	assertEquals(6,kr.getMatch(1).getEndPos());
+    	
+    	// return all nps whose children are articles
+    	/*SpanRelationPartQuery rv3 = 
+    		new SpanRelationPartQuery(rv, 
+    			new SpanTermWithIdQuery(new Term("base","pos:ART"), true), 
+    			false, true, true); 
+    	kr = ki.search(rv3,(short) 10);
+    	 
+    	assertEquals((long) 2, kr.getTotalResults());
+    	assertEquals(2,kr.getMatch(0).getStartPos());
+    	assertEquals(4,kr.getMatch(0).getEndPos());
+    	assertEquals(5,kr.getMatch(1).getStartPos());
+    	assertEquals(7,kr.getMatch(1).getEndPos());
+    	
+    	*/
+    //}
+
+    /**
+     * Match left return left
+     * Match right return right
+     * */
+    @Test
+    public void testCase5 () throws IOException {
         ki.addDoc(createFieldDoc2());
         ki.commit();
-        
+
         // return all children that are NP
-		SpanQuery rv = new SpanSegmentQuery(
-		    new SpanRelationQuery(
-		       new SpanTermQuery(new Term("base",">:child-of")), true), 
-		       new SpanElementQuery("base","np"),
-		    true);
-                
-        kr = ki.search(rv,(short) 10);
+        SpanQuery rv = new SpanSegmentQuery(new SpanRelationQuery(
+                new SpanTermQuery(new Term("base", ">:child-of")), true),
+                new SpanElementQuery("base", "np"), true);
+
+        kr = ki.search(rv, (short) 10);
 
         assertEquals(4, kr.getTotalResults());
-        assertEquals(0,kr.getMatch(0).getStartPos());
-        assertEquals(1,kr.getMatch(0).getEndPos());
-        assertEquals(2,kr.getMatch(1).getStartPos());
-        assertEquals(4,kr.getMatch(1).getEndPos());
-        assertEquals(2,kr.getMatch(2).getStartPos());
-        assertEquals(7,kr.getMatch(2).getEndPos());
-        assertEquals(5,kr.getMatch(3).getStartPos());
-        assertEquals(7,kr.getMatch(3).getEndPos());
-        
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(1, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(1).getStartPos());
+        assertEquals(4, kr.getMatch(1).getEndPos());
+        assertEquals(2, kr.getMatch(2).getStartPos());
+        assertEquals(7, kr.getMatch(2).getEndPos());
+        assertEquals(5, kr.getMatch(3).getStartPos());
+        assertEquals(7, kr.getMatch(3).getEndPos());
+
         // return all parents that are NP
-		rv = new SpanSegmentQuery(
-            new SpanRelationQuery(
-                new SpanTermQuery(new Term("base", "<:child-of")), true), 
-            new SpanElementQuery("base", "np"), 
-            true);
-                
-        kr = ki.search(rv,(short) 10);
+        rv = new SpanSegmentQuery(new SpanRelationQuery(new SpanTermQuery(
+                new Term("base", "<:child-of")), true), new SpanElementQuery(
+                "base", "np"), true);
+
+        kr = ki.search(rv, (short) 10);
 
         assertEquals(7, kr.getTotalResults());
-        assertEquals(0,kr.getMatch(0).getStartPos());
-        assertEquals(1,kr.getMatch(0).getEndPos());
-        assertEquals(2,kr.getMatch(1).getStartPos());
-        assertEquals(4,kr.getMatch(1).getEndPos());
-        assertEquals(2,kr.getMatch(2).getStartPos());
-        assertEquals(4,kr.getMatch(2).getEndPos());
-        assertEquals(2,kr.getMatch(3).getStartPos());
-        assertEquals(7,kr.getMatch(3).getEndPos());
-        assertEquals(2,kr.getMatch(4).getStartPos());
-        assertEquals(7,kr.getMatch(4).getEndPos());
-        assertEquals(5,kr.getMatch(5).getStartPos());
-        assertEquals(7,kr.getMatch(5).getEndPos());
-        assertEquals(5,kr.getMatch(6).getStartPos());
-        assertEquals(7,kr.getMatch(6).getEndPos());     
-   }
-	
-	// FOCUS has not sorted
-	/** Match left, return right
-	 * 	sort by left, then sort by right
-	 * */
-	/*@Test
-	public void testCase7() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		// return all children that are NP
-		SpanQuery rv = new SpanSegmentQuery(
-		    new SpanRelationQuery(
-		       new SpanTermQuery(new Term("base",">:child-of")), true), 
-		       new SpanElementQuery("base","np"),
-		    true);
-		
-		//return all parents of np
-		SpanQuery rv2 = new SpanFocusQuery(rv, (byte) 2);
-		kr = ki.search(rv2, (short) 10);
-		for (Match km : kr.getMatches()) {
-			System.out.println(km.getStartPos() + "," + km.getEndPos()
-			// + " "+ km.getSnippetBrackets()
-					);
-		}
-		assertEquals((long) 4, kr.getTotalResults());
-		assertEquals(0,kr.getMatch(0).getStartPos());
-		assertEquals(7,kr.getMatch(0).getEndPos());
-		assertEquals(1,kr.getMatch(1).getStartPos());
-		assertEquals(7,kr.getMatch(1).getEndPos());
-		assertEquals(2,kr.getMatch(2).getStartPos());
-		assertEquals(7,kr.getMatch(2).getEndPos());
-		assertEquals(4,kr.getMatch(3).getStartPos());
-		assertEquals(7,kr.getMatch(3).getEndPos());
-		// id problem (solved)
+        assertEquals(0, kr.getMatch(0).getStartPos());
+        assertEquals(1, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(1).getStartPos());
+        assertEquals(4, kr.getMatch(1).getEndPos());
+        assertEquals(2, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
+        assertEquals(2, kr.getMatch(3).getStartPos());
+        assertEquals(7, kr.getMatch(3).getEndPos());
+        assertEquals(2, kr.getMatch(4).getStartPos());
+        assertEquals(7, kr.getMatch(4).getEndPos());
+        assertEquals(5, kr.getMatch(5).getStartPos());
+        assertEquals(7, kr.getMatch(5).getEndPos());
+        assertEquals(5, kr.getMatch(6).getStartPos());
+        assertEquals(7, kr.getMatch(6).getEndPos());
+    }
 
-		// return all parents of np that are PP
-		
-	}
-	
-	/** Relations whose source/target do not embed 
-	 * 	its counterparts.
-	 * */	
-	@Test
-	public void testCase8() throws IOException {
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		//return source of dep relations to pos:NN
-		SpanQuery rv = new SpanFocusQuery( 
-		        new SpanSegmentQuery(
-				    new SpanRelationQuery(
-                        new SpanTermQuery(new Term("base", "<:dep")), true), 
-				    new SpanTermWithIdQuery(new Term("base","pos:NN"), true), 
-		        true),
-        (byte) 2);
 
-		kr = ki.search(rv,(short) 10);
-		assertEquals((long) 3, kr.getTotalResults());
-		assertEquals(1,kr.getMatch(0).getStartPos());
-		assertEquals(2,kr.getMatch(0).getEndPos());
-		assertEquals(1,kr.getMatch(1).getStartPos());
-		assertEquals(2,kr.getMatch(1).getEndPos());
-		assertEquals(4,kr.getMatch(2).getStartPos());
-		assertEquals(5,kr.getMatch(2).getEndPos());
-		
-		//return target of dep relations from pos:NN
-		rv = new SpanFocusQuery( 
-		        new SpanSegmentQuery(
-				    new SpanRelationQuery(
-                        new SpanTermQuery(new Term("base", ">:dep")), true), 
-				    new SpanTermWithIdQuery(new Term("base","pos:NN"), true), 
-		        true),
-        (byte) 2);
-		kr = ki.search(rv,(short) 10);
-		assertEquals((long) 3, kr.getTotalResults());
-		assertEquals(2,kr.getMatch(0).getStartPos());
-		assertEquals(3,kr.getMatch(0).getEndPos());
-		assertEquals(4,kr.getMatch(1).getStartPos());
-		assertEquals(5,kr.getMatch(1).getEndPos());
-		assertEquals(5,kr.getMatch(2).getStartPos());
-		assertEquals(6,kr.getMatch(2).getEndPos());
+    // FOCUS has not sorted
+    /**
+     * Match left, return right
+     * sort by left, then sort by right
+     * */
+    /*@Test
+    public void testCase7() throws IOException {
+    	ki.addDoc(createFieldDoc2());
+    	ki.commit();
+    	
+    	// return all children that are NP
+    	SpanQuery rv = new SpanSegmentQuery(
+    	    new SpanRelationQuery(
+    	       new SpanTermQuery(new Term("base",">:child-of")), true), 
+    	       new SpanElementQuery("base","np"),
+    	    true);
+    	
+    	//return all parents of np
+    	SpanQuery rv2 = new SpanFocusQuery(rv, (byte) 2);
+    	kr = ki.search(rv2, (short) 10);
+    	for (Match km : kr.getMatches()) {
+    		System.out.println(km.getStartPos() + "," + km.getEndPos()
+    		// + " "+ km.getSnippetBrackets()
+    				);
+    	}
+    	assertEquals((long) 4, kr.getTotalResults());
+    	assertEquals(0,kr.getMatch(0).getStartPos());
+    	assertEquals(7,kr.getMatch(0).getEndPos());
+    	assertEquals(1,kr.getMatch(1).getStartPos());
+    	assertEquals(7,kr.getMatch(1).getEndPos());
+    	assertEquals(2,kr.getMatch(2).getStartPos());
+    	assertEquals(7,kr.getMatch(2).getEndPos());
+    	assertEquals(4,kr.getMatch(3).getStartPos());
+    	assertEquals(7,kr.getMatch(3).getEndPos());
+    	// id problem (solved)
 
-	}
-	
+    	// return all parents of np that are PP
+    	
+    }
+    
+    /** Relations whose source/target do not embed 
+     * 	its counterparts.
+     * */
+    @Test
+    public void testCase8 () throws IOException {
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        //return source of dep relations to pos:NN
+        SpanQuery rv = new SpanFocusQuery(new SpanSegmentQuery(
+                new SpanRelationQuery(new SpanTermQuery(new Term("base",
+                        "<:dep")), true), new SpanTermWithIdQuery(new Term(
+                        "base", "pos:NN"), true), true), (byte) 2);
+
+        kr = ki.search(rv, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+        assertEquals(2, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getStartPos());
+        assertEquals(2, kr.getMatch(1).getEndPos());
+        assertEquals(4, kr.getMatch(2).getStartPos());
+        assertEquals(5, kr.getMatch(2).getEndPos());
+
+        //return target of dep relations from pos:NN
+        rv = new SpanFocusQuery(
+                new SpanSegmentQuery(new SpanRelationQuery(new SpanTermQuery(
+                        new Term("base", ">:dep")), true),
+                        new SpanTermWithIdQuery(new Term("base", "pos:NN"),
+                                true), true), (byte) 2);
+        kr = ki.search(rv, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(2, kr.getMatch(0).getStartPos());
+        assertEquals(3, kr.getMatch(0).getEndPos());
+        assertEquals(4, kr.getMatch(1).getStartPos());
+        assertEquals(5, kr.getMatch(1).getEndPos());
+        assertEquals(5, kr.getMatch(2).getStartPos());
+        assertEquals(6, kr.getMatch(2).getEndPos());
+
+    }
+
 }
\ No newline at end of file
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
index 087bd9f..63093fc 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
@@ -17,160 +17,147 @@
 import de.ids_mannheim.korap.query.SpanRepetitionQuery;
 
 public class TestRepetitionIndex {
-	
-    private KrillIndex ki;
-	private Result kr;
 
-	private FieldDocument createFieldDoc0(){
-    	FieldDocument fd = new FieldDocument();
+    private KrillIndex ki;
+    private Result kr;
+
+
+    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|s:b|_4#3-4|<>:x#3-7$<i>7]" + 
-            "[(4-5)s:e|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|s:b|_9#8-9|<>:x#8-10$<i>10]" + 
-            "[(9-10)s:d|_10#9-10]");
+        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|s:b|_4#3-4|<>:x#3-7$<i>7]"
+                + "[(4-5)s:e|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|s:b|_9#8-9|<>:x#8-10$<i>10]"
+                + "[(9-10)s:d|_10#9-10]");
         return fd;
     }
-	
-	private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
-        fd.addString("ID", "doc-1");
-        fd.addTV("base",
-            "text",             
-            "[(0-1)s:b|_1#0-1]" +
-            "[(1-2)s:e|_2#1-2]" +             
-            "[(2-3)s:c|_3#2-3]" +
-            "[(3-4)s:c|s:d]" + 
-            "[(4-5)s:d|s:c|_5#4-5]" +             
-            "[(5-6)s:e|s:c|_6#5-6]" +
-    		"[(6-7)s:e|_7#6-7]" +	
-	        "[(7-8)s:c|_8#7-8]" + 
-	        "[(8-9)s:d|_9#8-9]" + 
-	        "[(9-10)s:d|_10#9-10]");
-        return fd;
-	}
-	
-	private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
-        fd.addString("ID", "doc-2");
-        fd.addTV("base",
-            "text",             
-            "[(0-1)s:b|s:c|_1#0-1|<>:s#0-2$<i>1]" +
-            "[(1-2)s:c|_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:c|_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]");
-        return fd;
-	}
-	
-	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]");	
-        return fd;
-	}
 
-	@Test
-	public void testCase1() throws IOException{
-		ki = new KrillIndex();
+
+    private FieldDocument createFieldDoc1 () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("ID", "doc-1");
+        fd.addTV("base", "text", "[(0-1)s:b|_1#0-1]" + "[(1-2)s:e|_2#1-2]"
+                + "[(2-3)s:c|_3#2-3]" + "[(3-4)s:c|s:d]"
+                + "[(4-5)s:d|s:c|_5#4-5]" + "[(5-6)s:e|s:c|_6#5-6]"
+                + "[(6-7)s:e|_7#6-7]" + "[(7-8)s:c|_8#7-8]"
+                + "[(8-9)s:d|_9#8-9]" + "[(9-10)s:d|_10#9-10]");
+        return fd;
+    }
+
+
+    private FieldDocument createFieldDoc2 () {
+        FieldDocument fd = new FieldDocument();
+        fd.addString("ID", "doc-2");
+        fd.addTV("base", "text", "[(0-1)s:b|s:c|_1#0-1|<>:s#0-2$<i>1]"
+                + "[(1-2)s:c|_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:c|_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]");
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    @Test
+    public void testCase1 () throws IOException {
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.commit();
-        
+
         SpanQuery sq, sq2;
         // Quantifier only
         // c{1,2}
-        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,2, true);
+        sq = new SpanRepetitionQuery(
+                new SpanTermQuery(new Term("base", "s:c")), 1, 2, true);
         kr = ki.search(sq, (short) 10);
         // 0-1, 2-3, 2-4, 3-4, 5-6
-        assertEquals((long) 5,kr.getTotalResults());        
-        
+        assertEquals((long) 5, kr.getTotalResults());
+
         // ec{1,2}
-        sq = new SpanNextQuery(
-        		new SpanTermQuery(new Term("base", "s:e")),
-        		new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,2, true)
-    		);
-        
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")),
+                new SpanRepetitionQuery(new SpanTermQuery(new Term("base",
+                        "s:c")), 1, 2, true));
+
         kr = ki.search(sq, (short) 10);
         // 1-3, 1-4, 4-6
-        assertEquals((long) 3, kr.getTotalResults());   
-        
+        assertEquals((long) 3, kr.getTotalResults());
+
         // ec{1,2}d
-        sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("base", "s:d")));        
-        kr = ki.search(sq2, (short) 10);        
-        assertEquals((long) 2,kr.getTotalResults());
+        sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("base", "s:d")));
+        kr = ki.search(sq2, (short) 10);
+        assertEquals((long) 2, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
         assertEquals(4, kr.getMatch(1).startPos);
         assertEquals(7, kr.getMatch(1).endPos);
-        
+
         // Multiple documents        
         ki.addDoc(createFieldDoc1());
         ki.commit();
         kr = ki.search(sq2, (short) 10);
         assertEquals((long) 5, kr.getTotalResults());
-	}
-	
-	/** Skip to */
-	@Test
-	public void testCase2() throws IOException{
-		ki = new KrillIndex();
+    }
+
+
+    /** Skip to */
+    @Test
+    public void testCase2 () throws IOException {
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc3());
         ki.addDoc(createFieldDoc2());
         ki.addDoc(createFieldDoc1());
         ki.commit();
-        
+
         SpanQuery sq;
         // c{2,2}
-        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),2,2, true);
+        sq = new SpanRepetitionQuery(
+                new SpanTermQuery(new Term("base", "s:c")), 2, 2, true);
         kr = ki.search(sq, (short) 10);
         // doc1 2-4, 3-5, 4-6
-        assertEquals((long)6,kr.getTotalResults());
-        
+        assertEquals((long) 6, kr.getTotalResults());
+
         // ec{2,2}
-        kr = ki.search(sq, (short) 10); 
-        sq = new SpanNextQuery(
-        		new SpanTermQuery(new Term("base", "s:e")),
-        		new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),2,2, true)
-    		);
-        
-        kr = ki.search(sq, (short) 10); 
-        assertEquals((long)2,kr.getTotalResults());
-        assertEquals(3,kr.getMatch(1).getLocalDocID());        
-       
-	}
-	
-	/** OR */
-	@Test
-	public void testCase3() throws IOException{
-		ki = new KrillIndex();
+        kr = ki.search(sq, (short) 10);
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")),
+                new SpanRepetitionQuery(new SpanTermQuery(new Term("base",
+                        "s:c")), 2, 2, true));
+
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(1).getLocalDocID());
+
+    }
+
+
+    /** OR */
+    @Test
+    public void testCase3 () throws IOException {
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.commit();
-        
-        SpanQuery sq,sq2;
-     // ec{1,2}
-        sq = new SpanNextQuery(
-        		new SpanTermQuery(new Term("base", "s:e")),
-        		new SpanOrQuery(
-    				new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,1, true),
-    				new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:b")),1,1, true)
-				)
-    		);        
-        kr = ki.search(sq, (short) 10); 
-        assertEquals((long)3,kr.getTotalResults());
+
+        SpanQuery sq, sq2;
+        // ec{1,2}
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:e")),
+                new SpanOrQuery(new SpanRepetitionQuery(new SpanTermQuery(
+                        new Term("base", "s:c")), 1, 1, true),
+                        new SpanRepetitionQuery(new SpanTermQuery(new Term(
+                                "base", "s:b")), 1, 1, true)));
+        kr = ki.search(sq, (short) 10);
+        assertEquals((long) 3, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(3, kr.getMatch(0).endPos);
         assertEquals(4, kr.getMatch(1).startPos);
@@ -178,66 +165,68 @@
         assertEquals(7, kr.getMatch(2).startPos);
         assertEquals(9, kr.getMatch(2).endPos);
 
-	}
-	
-	@Test
-	public void testCase4() throws IOException {
-		ki = new KrillIndex();
+    }
+
+
+    @Test
+    public void testCase4 () throws IOException {
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc1());
         ki.commit();
-        
-		SpanQuery sq;
+
+        SpanQuery sq;
         // c{2,2}
-        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,3, true);
+        sq = new SpanRepetitionQuery(
+                new SpanTermQuery(new Term("base", "s:c")), 1, 3, true);
         kr = ki.search(sq, (short) 10);
         // 2-3, 2-4, 2-5, 3-4, 3-5, 3-6, 4-5, 4-6, 5-6, 7-8  
-        assertEquals((long)10,kr.getTotalResults());
-        
-        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),2,3, true);
+        assertEquals((long) 10, kr.getTotalResults());
+
+        sq = new SpanRepetitionQuery(
+                new SpanTermQuery(new Term("base", "s:c")), 2, 3, true);
         kr = ki.search(sq, (short) 10);
         // 2-4, 2-5, 3-5, 3-6, 4-6 
-        assertEquals((long)5,kr.getTotalResults());
-        
-//        System.out.print(kr.getTotalResults()+"\n");
-//		for (int i=0; i< kr.getTotalResults(); i++){
-//			System.out.println(
-//				kr.match(i).getLocalDocID()+" "+
-//				kr.match(i).startPos + " " +
-//				kr.match(i).endPos
-//			);
-//		}
-	}
-	
-	@Test
-	public void testCase5() throws IOException {
-		ki = new KrillIndex();
-	    ki.addDoc(
-	        getClass().getResourceAsStream("/wiki/00001.json.gz"), true
-        );
-		ki.commit();
-		
-		SpanQuery sq0, sq1, sq2;
-		sq0 = new SpanTermQuery(new Term("tokens", "tt/p:NN"));
-		sq1 = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","tt/p:ADJA")),2,3, true);
-        sq2 = new SpanNextQuery(sq1,sq0);        
+        assertEquals((long) 5, kr.getTotalResults());
+
+        //        System.out.print(kr.getTotalResults()+"\n");
+        //		for (int i=0; i< kr.getTotalResults(); i++){
+        //			System.out.println(
+        //				kr.match(i).getLocalDocID()+" "+
+        //				kr.match(i).startPos + " " +
+        //				kr.match(i).endPos
+        //			);
+        //		}
+    }
+
+
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
+        ki.commit();
+
+        SpanQuery sq0, sq1, sq2;
+        sq0 = new SpanTermQuery(new Term("tokens", "tt/p:NN"));
+        sq1 = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens",
+                "tt/p:ADJA")), 2, 3, true);
+        sq2 = new SpanNextQuery(sq1, sq0);
         kr = ki.search(sq2, (short) 10);
-        
-        assertEquals((long)2,kr.getTotalResults());
+
+        assertEquals((long) 2, kr.getTotalResults());
         assertEquals(73, kr.getMatch(0).getStartPos());
         assertEquals(77, kr.getMatch(0).getEndPos());
         assertEquals(74, kr.getMatch(1).getStartPos());
         assertEquals(77, kr.getMatch(1).getEndPos());
-       /* for (Match km : kr.getMatches()){
-        	System.out.println(km.getSnippetBrackets());
-        	System.out.println(km.getStartPos() +","+km.getEndPos());
-        }*/
-        
-        sq2 = new SpanNextQuery(
-        		new SpanTermQuery(new Term("tokens", "s:offenen")),
-        		sq2);
+        /* for (Match km : kr.getMatches()){
+         	System.out.println(km.getSnippetBrackets());
+         	System.out.println(km.getStartPos() +","+km.getEndPos());
+         }*/
+
+        sq2 = new SpanNextQuery(new SpanTermQuery(new Term("tokens",
+                "s:offenen")), sq2);
         kr = ki.search(sq2, (short) 10);
-        
-        assertEquals((long)1,kr.getTotalResults());
+
+        assertEquals((long) 1, kr.getTotalResults());
         assertEquals(73, kr.getMatch(0).getStartPos());
         assertEquals(77, kr.getMatch(0).getEndPos());
         /*
@@ -245,5 +234,5 @@
         	System.out.println(km.getSnippetBrackets());
         	System.out.println(km.getStartPos() +","+km.getEndPos());
         }*/
-	}
+    }
 }
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 01e9aa3..da6851e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
@@ -24,213 +24,198 @@
 
 @RunWith(JUnit4.class)
 public class TestSegmentIndex {
-	private SpanQuery sq;
-	private KrillIndex ki;
-	private Result kr;
-	private FieldDocument fd;
-	private Logger log;	
-	
-	public TestSegmentIndex() throws IOException {
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-		ki.addDoc(createFieldDoc1());
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		log = LoggerFactory.getLogger(getClass());
-	}
+    private SpanQuery sq;
+    private KrillIndex ki;
+    private Result kr;
+    private FieldDocument fd;
+    private Logger log;
 
-	/** Multiple matches in one document. */
-	@Test
-	public void testCase1() throws IOException {
-		sq = new SpanSegmentQuery(
-				new SpanTermQuery(new Term("base","s:b")),
-				new SpanTermQuery(new Term("base","s:c"))
-		);
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();
-		
-		assertEquals("totalResults", kr.getTotalResults(), 3);
-		assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-		assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
-		assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
-		assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);		
-	}
-	
-	/** Matches in multiple documents.
-	 * 	Ensure the same document. The current secondspan is skipped to 
-	 * 	the doc number of the firstspan.  */
-	@Test
-	public void testCase2() throws IOException {		
-//		log.trace("Testcase2");
-		sq = new SpanSegmentQuery(
-				new SpanTermQuery(new Term("base","s:a")),				
-				new SpanTermQuery(new Term("base","s:b"))
-		);
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();
-				
-		assertEquals("totalResults", kr.getTotalResults(), 3);
-		// Match #0
-		assertEquals("doc-number", 1, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 1, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 2, kr.getMatch(0).endPos);
-		// Match #2
-		assertEquals("doc-number", 2, kr.getMatch(2).getLocalDocID());
-		assertEquals("StartPos", 2, kr.getMatch(2).startPos);
-		assertEquals("EndPos", 3, kr.getMatch(2).endPos);		
-	}
-	
-	
-	/** Ensure the same document, skip to a greater doc number */
-	@Test
-	public void testCase3() throws IOException{
-//		log.trace("Testcase3");
-		sq = new SpanSegmentQuery(
-				new SpanTermQuery(new Term("base","s:d")),
-				new SpanTermQuery(new Term("base","s:b"))
-		);
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();
-		
-		assertEquals("totalResults", kr.getTotalResults(), 1);
-		assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
-		assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);		
-	}
-	
-	/** Matching a SpanElementQuery and a SpanNextQuery 
-	 * 	Multiple atomic indices
-	 * */
-	@Test
-	public void testCase4() throws IOException{
-//		log.trace("Testcase4");
-		
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-		ki.commit();
-		ki.addDoc(createFieldDoc1());		
-		ki.addDoc(createFieldDoc2());
-		ki.commit();
-		
-		sq = new SpanSegmentQuery(
-				new SpanElementQuery("base","e"),
-				new SpanNextQuery(
-					new SpanTermQuery(new Term("base","s:a")),
-					new SpanTermQuery(new Term("base","s:b"))
-				)
-		);
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();
-		
-		assertEquals("totalResults", kr.getTotalResults(), 2);
-		// Match #0
-		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 3, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 5, kr.getMatch(0).endPos);
-		// Match #1
-		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
-		assertEquals("StartPos", 1, kr.getMatch(1).startPos);
-		assertEquals("EndPos", 3, kr.getMatch(1).endPos);				
-	}
-	
-	/** Matching SpanElementQueries */
-	@Test
-	public void testCase5() throws IOException{
-//		log.trace("Testcase5");
-		sq = new SpanSegmentQuery(
-				new SpanElementQuery("base","e"),
-				new SpanElementQuery("base","e2")
-		);
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();			
-		
-		assertEquals("totalResults", kr.getTotalResults(), 1);
-		// Match #0
-		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos", 3, kr.getMatch(0).startPos);
-		assertEquals("EndPos", 5, kr.getMatch(0).endPos);				
-	}
-		
-	/** Skip to SegmentSpan */
-	@Test
-	public void testcase6() throws IOException{
-		ki.addDoc(createFieldDoc4());
-		ki.commit();
-		sq = new SpanNextQuery(
-				new SpanSegmentQuery(
-					new SpanTermQuery(new Term("base","s:b")),
-					new SpanTermQuery(new Term("base","s:c"))
-				),
-				new SpanTermQuery(new Term("base","s:d"))
-			);		
-		
-		kr = ki.search(sq, (short) 10);
-		ki.close();
-		
-		assertEquals("totalResults", kr.getTotalResults(), 2);				
-		// Match #0
-		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-		assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
-		assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
-		// Match #1 in the other atomic index
-		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
-		assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
-		assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
-	}
 
-    
-	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]");
-		return fd;
-	}
-	
-	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]");
-		return fd;
-	} 
-	
-	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]");			 	
-		return fd;
-	}
-	
-	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]");			 	
-		return fd;
-	}
+    public TestSegmentIndex () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        log = LoggerFactory.getLogger(getClass());
+    }
+
+
+    /** Multiple matches in one document. */
+    @Test
+    public void testCase1 () throws IOException {
+        sq = new SpanSegmentQuery(new SpanTermQuery(new Term("base", "s:b")),
+                new SpanTermQuery(new Term("base", "s:c")));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+        assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+    }
+
+
+    /**
+     * Matches in multiple documents.
+     * Ensure the same document. The current secondspan is skipped to
+     * the doc number of the firstspan.
+     */
+    @Test
+    public void testCase2 () throws IOException {
+        //		log.trace("Testcase2");
+        sq = new SpanSegmentQuery(new SpanTermQuery(new Term("base", "s:a")),
+                new SpanTermQuery(new Term("base", "s:b")));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 3);
+        // Match #0
+        assertEquals("doc-number", 1, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 2, kr.getMatch(0).endPos);
+        // Match #2
+        assertEquals("doc-number", 2, kr.getMatch(2).getLocalDocID());
+        assertEquals("StartPos", 2, kr.getMatch(2).startPos);
+        assertEquals("EndPos", 3, kr.getMatch(2).endPos);
+    }
+
+
+    /** Ensure the same document, skip to a greater doc number */
+    @Test
+    public void testCase3 () throws IOException {
+        //		log.trace("Testcase3");
+        sq = new SpanSegmentQuery(new SpanTermQuery(new Term("base", "s:d")),
+                new SpanTermQuery(new Term("base", "s:b")));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+    }
+
+
+    /**
+     * Matching a SpanElementQuery and a SpanNextQuery
+     * Multiple atomic indices
+     * */
+    @Test
+    public void testCase4 () throws IOException {
+        //		log.trace("Testcase4");
+
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.commit();
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        sq = new SpanSegmentQuery(new SpanElementQuery("base", "e"),
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:a")),
+                        new SpanTermQuery(new Term("base", "s:b"))));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        // Match #0
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 3, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 5, kr.getMatch(0).endPos);
+        // Match #1
+        assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+        assertEquals("StartPos", 1, kr.getMatch(1).startPos);
+        assertEquals("EndPos", 3, kr.getMatch(1).endPos);
+    }
+
+
+    /** Matching SpanElementQueries */
+    @Test
+    public void testCase5 () throws IOException {
+        //		log.trace("Testcase5");
+        sq = new SpanSegmentQuery(new SpanElementQuery("base", "e"),
+                new SpanElementQuery("base", "e2"));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 1);
+        // Match #0
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos", 3, kr.getMatch(0).startPos);
+        assertEquals("EndPos", 5, kr.getMatch(0).endPos);
+    }
+
+
+    /** Skip to SegmentSpan */
+    @Test
+    public void testcase6 () throws IOException {
+        ki.addDoc(createFieldDoc4());
+        ki.commit();
+        sq = new SpanNextQuery(new SpanSegmentQuery(new SpanTermQuery(new Term(
+                "base", "s:b")), new SpanTermQuery(new Term("base", "s:c"))),
+                new SpanTermQuery(new Term("base", "s:d")));
+
+        kr = ki.search(sq, (short) 10);
+        ki.close();
+
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        // Match #0
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
+        // Match #1 in the other atomic index
+        assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+        assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
+
+
+    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]");
+        return fd;
+    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
index 9f1571a..7554b20 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
@@ -27,102 +27,98 @@
     private KrillIndex ki;
     private Result kr;
     private FieldDocument fd;
-    private Logger log;	
-	
+    private Logger log;
+
+
     @Test
-    public void testcaseNegation() throws Exception {
-	ki = new KrillIndex();
-	ki.addDoc(createFieldDoc0());
-	ki.addDoc(createFieldDoc1());
-	ki.addDoc(createFieldDoc2());
-	ki.addDoc(createFieldDoc3());
-	ki.commit();
-	SpanSegmentQueryWrapper ssqw = new SpanSegmentQueryWrapper("base","s:b");
-	ssqw.with("s:c");
-	SpanSequenceQueryWrapper sqw = new SpanSequenceQueryWrapper("base", ssqw).append("s:d");
+    public void testcaseNegation () throws Exception {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.addDoc(createFieldDoc3());
+        ki.commit();
+        SpanSegmentQueryWrapper ssqw = new SpanSegmentQueryWrapper("base",
+                "s:b");
+        ssqw.with("s:c");
+        SpanSequenceQueryWrapper sqw = new SpanSequenceQueryWrapper("base",
+                ssqw).append("s:d");
 
-	kr = ki.search(sqw.toQuery(), (short) 10);
-		
-	assertEquals("totalResults", kr.getTotalResults(), 2);				
-	// Match #0
-	assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-	assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
+        kr = ki.search(sqw.toQuery(), (short) 10);
 
-	// Match #1 in the other atomic index
-	assertEquals("doc-number", 3, kr.getMatch(1).getLocalDocID());
-	assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
-	assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
-		
-	ssqw = new SpanSegmentQueryWrapper("base","s:b");
-	ssqw.without("s:c");
-	sqw = new SpanSequenceQueryWrapper("base", ssqw).append("s:a");
+        assertEquals("totalResults", kr.getTotalResults(), 2);
+        // Match #0
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
 
-	kr = ki.search(sqw.toQuery(), (short) 10);
+        // Match #1 in the other atomic index
+        assertEquals("doc-number", 3, kr.getMatch(1).getLocalDocID());
+        assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
+        assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
 
-	assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
-	assertEquals("StartPos (0)", 2, kr.getMatch(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+        ssqw = new SpanSegmentQueryWrapper("base", "s:b");
+        ssqw.without("s:c");
+        sqw = new SpanSequenceQueryWrapper("base", ssqw).append("s:a");
 
-	assertEquals("doc-number", 1, kr.getMatch(1).getLocalDocID());
-	assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
-	assertEquals("EndPos (1)", 3, kr.getMatch(1).endPos);
+        kr = ki.search(sqw.toQuery(), (short) 10);
 
-	assertEquals("doc-number", 1, kr.getMatch(2).getLocalDocID());
-	assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
-	assertEquals("EndPos (2)", 4, kr.getMatch(2).endPos);
+        assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+        assertEquals("StartPos (0)", 2, kr.getMatch(0).startPos);
+        assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
 
-	assertEquals("doc-number", 2, kr.getMatch(3).getLocalDocID());
-	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
-	assertEquals("EndPos (3)", 3, kr.getMatch(3).endPos);
+        assertEquals("doc-number", 1, kr.getMatch(1).getLocalDocID());
+        assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
+        assertEquals("EndPos (1)", 3, kr.getMatch(1).endPos);
+
+        assertEquals("doc-number", 1, kr.getMatch(2).getLocalDocID());
+        assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
+        assertEquals("EndPos (2)", 4, kr.getMatch(2).endPos);
+
+        assertEquals("doc-number", 2, kr.getMatch(3).getLocalDocID());
+        assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+        assertEquals("EndPos (3)", 3, kr.getMatch(3).endPos);
     }
-    
-    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]");
-	return fd;
+
+
+    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]");
+        return fd;
     }
-	
-    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]");
-	return fd;
-    } 
-    
-    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]");			 	
-	return fd;
+
+
+    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]");
+        return fd;
     }
-	
-    private FieldDocument createFieldDoc3(){
-	fd = new FieldDocument();
-	fd.addString("ID", "doc-3");
-	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]");			 	
-	return fd;
+
+
+    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]");
+        return fd;
+    }
+
+
+    private FieldDocument createFieldDoc3 () {
+        fd = new FieldDocument();
+        fd.addString("ID", "doc-3");
+        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]");
+        return fd;
     }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index 2731cf4..3ed9dc6 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -29,18 +29,19 @@
     Result kr;
     KrillIndex ki;
 
-    public TestSpanExpansionIndex() throws IOException {
+
+    public TestSpanExpansionIndex () throws IOException {
         ki = new KrillIndex();
-        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"),
-                true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
         ki.commit();
     }
 
+
     /**
      * Left and right expansions
      * */
     @Test
-    public void testCase1() throws IOException {
+    public void testCase1 () throws IOException {
 
         SpanTermQuery stq = new SpanTermQuery(new Term("tokens", "s:des"));
         // left
@@ -75,12 +76,13 @@
         assertEquals(161, kr.getMatch(3).getEndPos());
     }
 
+
     /**
-     * Classnumber 
+     * Classnumber
      * Check the expansion offsets
      * */
     @Test
-    public void testCase2() {
+    public void testCase2 () {
         byte classNumber = 1;
         SpanExpansionQuery sq;
         // create new payload for the expansion offsets
@@ -133,11 +135,12 @@
          */
     }
 
+
     /**
      * Right expansion with exclusion
      * */
     @Test
-    public void testCase3() throws IOException {
+    public void testCase3 () throws IOException {
         byte classNumber = 1;
         SpanTermQuery stq = new SpanTermQuery(new Term("tokens", "tt/p:NN"));
         SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens",
@@ -167,12 +170,13 @@
          */
     }
 
+
     /**
-     * Left expansion with exclusion 
+     * Left expansion with exclusion
      * No expansion
      * */
     @Test
-    public void testCase4() throws IOException {
+    public void testCase4 () throws IOException {
         byte classNumber = 1;
         SpanTermQuery stq = new SpanTermQuery(new Term("tokens", "tt/p:NN"));
         SpanTermQuery notQuery = new SpanTermQuery(new Term("tokens",
@@ -208,14 +212,15 @@
 
     }
 
+
     /**
-     * Expansion over start and end documents start => cut to 0 
+     * Expansion over start and end documents start => cut to 0
      * TODO: end => to be handled in rendering process
      * 
      * @throws IOException
      * */
     @Test
-    public void testCase5() throws IOException {
+    public void testCase5 () throws IOException {
         KrillIndex ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.commit();
@@ -246,13 +251,14 @@
          */
     }
 
+
     /**
      * Expansion exclusion : multiple documents
      * 
      * @throws IOException
      * */
     @Test
-    public void testCase6() throws IOException {
+    public void testCase6 () throws IOException {
         KrillIndex ki = new KrillIndex();
         ki.addDoc(createFieldDoc0()); // same doc
         ki.addDoc(createFieldDoc1()); // only not clause
@@ -277,16 +283,15 @@
         assertEquals(4, kr.getMatch(4).getEndPos());
     }
 
+
     /**
      * Skip to
      * */
     @Test
-    public void testCase7() throws IOException, QueryException {
+    public void testCase7 () throws IOException, QueryException {
         KrillIndex ki = new KrillIndex();
-        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"),
-                true);
-        ki.addDoc(getClass().getResourceAsStream("/wiki/00002.json.gz"),
-                true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00002.json.gz"), true);
         ki.commit();
 
         String jsonPath = getClass().getResource("/queries/poly3.json")
@@ -308,13 +313,14 @@
          */
     }
 
+
     /**
      * Query rewrite bug
      * 
      * @throws IOException
      * */
     @Test
-    public void testQueryRewriteBug() throws IOException {
+    public void testQueryRewriteBug () throws IOException {
         KrillIndex ki = new KrillIndex();
         ki.addDoc(createFieldDoc0()); // same doc
         ki.addDoc(createFieldDoc1()); // only not clause
@@ -342,7 +348,8 @@
          */
     }
 
-    private FieldDocument createFieldDoc0() {
+
+    private FieldDocument createFieldDoc0 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-0");
         fd.addTV("base", "ceccecdeec", "[(0-1)s:c|_0#0-1]"
@@ -354,7 +361,8 @@
         return fd;
     }
 
-    private FieldDocument createFieldDoc1() {
+
+    private FieldDocument createFieldDoc1 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addTV("base", "bbccdd", "[(0-1)s:b|s:c|_0#0-1]"
@@ -364,7 +372,8 @@
         return fd;
     }
 
-    private FieldDocument createFieldDoc2() {
+
+    private FieldDocument createFieldDoc2 () {
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addTV("base", "beccea", "[(0-1)s:b|s:c|_0#0-1]"
@@ -374,7 +383,8 @@
         return fd;
     }
 
-    private String readFile(String path) {
+
+    private String readFile (String path) {
         StringBuilder sb = new StringBuilder();
         try {
             BufferedReader in = new BufferedReader(new FileReader(path));
@@ -383,7 +393,8 @@
                 sb.append(str);
             }
             in.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             fail(e.getMessage());
         }
         return sb.toString();
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
index b9b41cf..fe59ad3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
@@ -19,15 +19,16 @@
     Result kr;
     KrillIndex ki;
 
+
     public TestSubSpanIndex () throws IOException {
         ki = new KrillIndex();
-        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"),
-                true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00001.json.gz"), true);
         ki.commit();
     }
 
+
     @Test
-    public void testCase1() throws IOException {
+    public void testCase1 () throws IOException {
         SpanDistanceQuery sdq = new SpanDistanceQuery(new SpanTermQuery(
                 new Term("tokens", "tt/p:NN")), new SpanTermQuery(new Term(
                 "tokens", "tt/p:VAFIN")), new DistanceConstraint(5, 5, true,
@@ -57,8 +58,9 @@
          */
     }
 
+
     @Test
-    public void testCase2() {
+    public void testCase2 () {
         SpanDistanceQuery sdq = new SpanDistanceQuery(new SpanTermQuery(
                 new Term("tokens", "tt/p:NN")), new SpanTermQuery(new Term(
                 "tokens", "tt/p:VAFIN")), new DistanceConstraint(5, 5, true,
@@ -85,9 +87,10 @@
 
     }
 
+
     // Length 0
     @Test
-    public void testCase3() {
+    public void testCase3 () {
         SpanDistanceQuery sdq = new SpanDistanceQuery(new SpanTermQuery(
                 new Term("tokens", "tt/p:NN")), new SpanTermQuery(new Term(
                 "tokens", "tt/p:VAFIN")), new DistanceConstraint(5, 5, true,
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestTermInfo.java b/src/test/java/de/ids_mannheim/korap/index/TestTermInfo.java
index 28f5b2b..0f281ea 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestTermInfo.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestTermInfo.java
@@ -19,103 +19,103 @@
     @Test
     public void termExample1 () throws IOException {
 
-	byte[] b = new byte[16];
-	ByteBuffer bb = ByteBuffer.allocate(16);
-	bb.putInt(20); // startOffset
-	bb.putInt(25); // endOffset
-	bb.putInt(7);  // endPos
-	bb.put((byte) 4);
+        byte[] b = new byte[16];
+        ByteBuffer bb = ByteBuffer.allocate(16);
+        bb.putInt(20); // startOffset
+        bb.putInt(25); // endOffset
+        bb.putInt(7);  // endPos
+        bb.put((byte) 4);
 
-	TermInfo term = new TermInfo("<>:mate/p:NN", 4, bb).analyze();
-	assertEquals("type", term.getType(), "span");
-	assertEquals("value", term.getValue(), "NN");
-	assertEquals("foundry", term.getFoundry(), "mate");
-	assertEquals("layer", term.getLayer(), "p");
-	assertEquals("startPos", term.getStartPos(), 4);
-	assertEquals("endPos", term.getEndPos(), 6);
-	assertEquals("startChar", term.getStartChar(), 20);
-	assertEquals("endChar", term.getEndChar(), 25);
-	assertEquals("depth", term.getDepth(), (byte) 4);
+        TermInfo term = new TermInfo("<>:mate/p:NN", 4, bb).analyze();
+        assertEquals("type", term.getType(), "span");
+        assertEquals("value", term.getValue(), "NN");
+        assertEquals("foundry", term.getFoundry(), "mate");
+        assertEquals("layer", term.getLayer(), "p");
+        assertEquals("startPos", term.getStartPos(), 4);
+        assertEquals("endPos", term.getEndPos(), 6);
+        assertEquals("startChar", term.getStartChar(), 20);
+        assertEquals("endChar", term.getEndChar(), 25);
+        assertEquals("depth", term.getDepth(), (byte) 4);
 
-	bb.clear();
-	term = new TermInfo("mate/p:NN", 9, bb).analyze();
-	assertEquals("type", term.getType(), "term");
-	assertEquals("value", term.getValue(), "NN");
-	assertEquals("foundry", term.getFoundry(), "mate");
-	assertEquals("layer", term.getLayer(), "p");
-	assertEquals("startPos", term.getStartPos(), 9);
-	assertEquals("endPos", term.getEndPos(), 9);
-	assertEquals("startChar", term.getStartChar(), -1);
-	assertEquals("endChar", term.getEndChar(), -1);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        term = new TermInfo("mate/p:NN", 9, bb).analyze();
+        assertEquals("type", term.getType(), "term");
+        assertEquals("value", term.getValue(), "NN");
+        assertEquals("foundry", term.getFoundry(), "mate");
+        assertEquals("layer", term.getLayer(), "p");
+        assertEquals("startPos", term.getStartPos(), 9);
+        assertEquals("endPos", term.getEndPos(), 9);
+        assertEquals("startChar", term.getStartChar(), -1);
+        assertEquals("endChar", term.getEndChar(), -1);
+        assertEquals("depth", term.getDepth(), 0);
 
-	bb.clear();
-	bb.putInt(17).put((byte) 2);
-	term = new TermInfo(">:xip/p:ADJ", 11, bb).analyze();
-	assertEquals("type", term.getType(), "relSrc");
-	assertEquals("value", term.getValue(), "ADJ");
-	assertEquals("foundry", term.getFoundry(), "xip");
-	assertEquals("layer", term.getLayer(), "p");
-	assertEquals("startPos", term.getStartPos(), 11);
-	assertEquals("endPos", term.getEndPos(), 16);
-	assertEquals("startChar", term.getStartChar(), -1);
-	assertEquals("endChar", term.getEndChar(), -1);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        bb.putInt(17).put((byte) 2);
+        term = new TermInfo(">:xip/p:ADJ", 11, bb).analyze();
+        assertEquals("type", term.getType(), "relSrc");
+        assertEquals("value", term.getValue(), "ADJ");
+        assertEquals("foundry", term.getFoundry(), "xip");
+        assertEquals("layer", term.getLayer(), "p");
+        assertEquals("startPos", term.getStartPos(), 11);
+        assertEquals("endPos", term.getEndPos(), 16);
+        assertEquals("startChar", term.getStartChar(), -1);
+        assertEquals("endChar", term.getEndChar(), -1);
+        assertEquals("depth", term.getDepth(), 0);
 
-	bb.clear();
-	bb.putInt(24);
-	term = new TermInfo("<:xip/m:number:pl", 20, bb).analyze();
-	assertEquals("type", term.getType(), "relTarget");
-	assertEquals("value", term.getValue(), "number:pl");
-	assertEquals("foundry", term.getFoundry(), "xip");
-	assertEquals("layer", term.getLayer(), "m");
-	assertEquals("startPos", term.getStartPos(), 20);
-	assertEquals("endPos", term.getEndPos(), 23);
-	assertEquals("startChar", term.getStartChar(), -1);
-	assertEquals("endChar", term.getEndChar(), -1);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        bb.putInt(24);
+        term = new TermInfo("<:xip/m:number:pl", 20, bb).analyze();
+        assertEquals("type", term.getType(), "relTarget");
+        assertEquals("value", term.getValue(), "number:pl");
+        assertEquals("foundry", term.getFoundry(), "xip");
+        assertEquals("layer", term.getLayer(), "m");
+        assertEquals("startPos", term.getStartPos(), 20);
+        assertEquals("endPos", term.getEndPos(), 23);
+        assertEquals("startChar", term.getStartChar(), -1);
+        assertEquals("endChar", term.getEndChar(), -1);
+        assertEquals("depth", term.getDepth(), 0);
 
-	bb.clear();
-	bb.putInt(240).putInt(400);
-	term = new TermInfo("_30", 30, bb).analyze();
-	assertEquals("type", term.getType(), "pos");
-	assertEquals("value", term.getValue(), "30");
-	assertNull("foundry", term.getFoundry());
-	assertNull("layer", term.getLayer());
-	assertEquals("startPos", term.getStartPos(), 30);
-	assertEquals("endPos", term.getEndPos(), 30);
-	assertEquals("startChar", term.getStartChar(), 240);
-	assertEquals("endChar", term.getEndChar(), 400);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        bb.putInt(240).putInt(400);
+        term = new TermInfo("_30", 30, bb).analyze();
+        assertEquals("type", term.getType(), "pos");
+        assertEquals("value", term.getValue(), "30");
+        assertNull("foundry", term.getFoundry());
+        assertNull("layer", term.getLayer());
+        assertEquals("startPos", term.getStartPos(), 30);
+        assertEquals("endPos", term.getEndPos(), 30);
+        assertEquals("startChar", term.getStartChar(), 240);
+        assertEquals("endChar", term.getEndChar(), 400);
+        assertEquals("depth", term.getDepth(), 0);
 
-	bb.clear();
-	bb.putInt(20); // startOffset
-	bb.putInt(25); // endOffset
-	bb.putInt(24); // endPos
-	term = new TermInfo("<>:s", 20, bb).analyze();
-	assertEquals("type", term.getType(), "span");
-	assertNull("value", term.getValue());
-	assertEquals("foundry", term.getFoundry(), "base");
-	assertEquals("layer", term.getLayer(), "s");
-	assertEquals("startPos", term.getStartPos(), 20);
-	assertEquals("endPos", term.getEndPos(), 23);
-	assertEquals("startChar", term.getStartChar(), 20);
-	assertEquals("endChar", term.getEndChar(), 25);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        bb.putInt(20); // startOffset
+        bb.putInt(25); // endOffset
+        bb.putInt(24); // endPos
+        term = new TermInfo("<>:s", 20, bb).analyze();
+        assertEquals("type", term.getType(), "span");
+        assertNull("value", term.getValue());
+        assertEquals("foundry", term.getFoundry(), "base");
+        assertEquals("layer", term.getLayer(), "s");
+        assertEquals("startPos", term.getStartPos(), 20);
+        assertEquals("endPos", term.getEndPos(), 23);
+        assertEquals("startChar", term.getStartChar(), 20);
+        assertEquals("endChar", term.getEndChar(), 25);
+        assertEquals("depth", term.getDepth(), 0);
 
-	bb.clear();
-	bb.putInt(20); // startOffset
-	bb.putInt(25); // endOffset
-	bb.putInt(24); // endPos
-	term = new TermInfo("<>:tag/x", 20, bb).analyze();
-	assertEquals("type", term.getType(), "span");
-	assertNull("value", term.getValue());
-	assertEquals("foundry", term.getFoundry(), "tag");
-	assertEquals("layer", term.getLayer(), "x");
-	assertEquals("startPos", term.getStartPos(), 20);
-	assertEquals("endPos", term.getEndPos(), 23);
-	assertEquals("startChar", term.getStartChar(), 20);
-	assertEquals("endChar", term.getEndChar(), 25);
-	assertEquals("depth", term.getDepth(), 0);
+        bb.clear();
+        bb.putInt(20); // startOffset
+        bb.putInt(25); // endOffset
+        bb.putInt(24); // endPos
+        term = new TermInfo("<>:tag/x", 20, bb).analyze();
+        assertEquals("type", term.getType(), "span");
+        assertNull("value", term.getValue());
+        assertEquals("foundry", term.getFoundry(), "tag");
+        assertEquals("layer", term.getLayer(), "x");
+        assertEquals("startPos", term.getStartPos(), 20);
+        assertEquals("endPos", term.getEndPos(), 23);
+        assertEquals("startChar", term.getStartChar(), 20);
+        assertEquals("endChar", term.getEndChar(), 25);
+        assertEquals("depth", term.getDepth(), 0);
     };
 };
\ No newline at end of file
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 e19b719..1cb78c9 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
@@ -19,278 +19,276 @@
 import de.ids_mannheim.korap.query.SpanNextQuery;
 
 @RunWith(JUnit4.class)
-public class TestUnorderedDistanceIndex{
-	
+public class TestUnorderedDistanceIndex {
+
     private KrillIndex ki;
-	private Result kr;
+    private Result kr;
 
-	private FieldDocument createFieldDoc0(){
-    	FieldDocument fd = new FieldDocument();
+
+    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#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]");
         return fd;
     }
-	
-	private FieldDocument createFieldDoc1(){
-		FieldDocument fd = new FieldDocument();
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc2(){
-		FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-    private SpanQuery createQuery(String x, String y, int min, int max, 
-    		boolean isOrdered){
-    	SpanQuery sq = new SpanDistanceQuery(
-        		new SpanTermQuery(new Term("base",x)),
-        		new SpanTermQuery(new Term("base",y)),
-        		new DistanceConstraint(min, max, isOrdered, false),        		
-        		true
-        );    	 
-    	return sq;
     }
-	
-    private SpanQuery createElementQuery(String x, String y, int min, int max, 
-    		boolean isOrdered){
-    	SpanQuery sq = new SpanDistanceQuery(
-        		new SpanElementQuery("base",x),
-        		new SpanElementQuery("base",y),
-        		new DistanceConstraint(min, max, isOrdered, false),
-        		true
-        );
-    	return sq;
+
+
+    private SpanQuery createQuery (String x, String y, int min, int max,
+            boolean isOrdered) {
+        SpanQuery sq = new SpanDistanceQuery(new SpanTermQuery(new Term("base",
+                x)), new SpanTermQuery(new Term("base", y)),
+                new DistanceConstraint(min, max, isOrdered, false), true);
+        return sq;
     }
-    
-    /** One document, multiple occurrences
-     * 	The first first and second spans are too far from each other
-     * 	One of the spans ends first
-     * 	One of the candidate list is empty
+
+
+    private SpanQuery createElementQuery (String x, String y, int min, int max,
+            boolean isOrdered) {
+        SpanQuery sq = new SpanDistanceQuery(new SpanElementQuery("base", x),
+                new SpanElementQuery("base", y), new DistanceConstraint(min,
+                        max, isOrdered, false), true);
+        return sq;
+    }
+
+
+    /**
+     * One document, multiple occurrences
+     * The first first and second spans are too far from each other
+     * One of the spans ends first
+     * One of the candidate list is empty
      * */
-	@Test
-	public void testCase1() throws IOException{
-		//System.out.println("testcase 1");
-		ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc0()); 
-	    ki.commit();    
-	    
-	    SpanQuery sq = createQuery("s:c","s:d",0,3,false);                
-	    kr = ki.search(sq, (short) 10);
-	    	    
-	    assertEquals(kr.getTotalResults(), 5);	    
-	}
-	
-	/** Multiple documents 
-	 * 	Ensure same doc
-	 * 	Both candidate lists are empty, but there is a span left in the doc
-	 * 	Both candidate lists are empty, but there are more matches in the doc
-	 * @throws IOException 
-	 * */
-	@Test
-	public void testCase2() throws IOException{
-		//System.out.println("testcase 2");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.commit();    
-	    
-	    SpanQuery sq = createQuery("s:c","s:d",1,2,false);                
-	    kr = ki.search(sq, (short) 10);
-	    	    
-	    assertEquals(kr.getTotalResults(), 6);	    
-	}
-	
-	/** Multiple documents 
-	 * 	Ensure same Doc
-	 * @throws IOException 
-	 * */
-	@Test
-	public void testCase3() throws IOException{		
-		//System.out.println("testcase 3");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.addDoc(createFieldDoc2());
-	    ki.commit();    
-	    
-	    SpanQuery sq = createQuery("s:e","s:f",1,2,false);                
-	    kr = ki.search(sq, (short) 10);
-	    	    
-	    assertEquals(kr.getTotalResults(), 3);
-	    assertEquals(0, kr.getMatch(0).getLocalDocID());
-	    assertEquals(7, kr.getMatch(0).getStartPos());
-	    assertEquals(9, kr.getMatch(0).getEndPos());
-	    assertEquals(2, kr.getMatch(1).getLocalDocID());
-	    assertEquals(0, kr.getMatch(1).getStartPos());
-	    assertEquals(3, kr.getMatch(1).getEndPos());
-	}
-	
-	/** Skip to */
-	@Test
-	public void testCase4() throws IOException{
-		//System.out.println("testcase 4");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.addDoc(createFieldDoc2());
-	    ki.commit();
-	    
-	    SpanQuery sq = new SpanNextQuery(
-	    		createQuery("s:d","s:e",1,2,false),
-	    		new SpanTermQuery(new Term("base","s:f"))	    		
-		);
-	    
-	    kr = ki.search(sq, (short) 10);
-	    assertEquals(kr.getTotalResults(), 2);
-	    assertEquals(2,kr.getMatch(0).getLocalDocID());
-	    assertEquals(2,kr.getMatch(0).getStartPos());
-	    assertEquals(6,kr.getMatch(0).getEndPos());
-	    assertEquals(3,kr.getMatch(1).getStartPos());
-	    assertEquals(6,kr.getMatch(1).getEndPos());
-	}
-	
-	 /** ElementQueries */    
     @Test
-    public void testCase5() throws IOException{    	
-    	ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc0()); 
-	    ki.commit();    
-	    
-	    // Intersection ---- Distance 0:0
-	    //System.out.println("Intersection ---- Distance 0:0");
-	    SpanQuery sq = createElementQuery("x","y",0,0,false);                
-	    kr = ki.search(sq, (short) 10);
-    	
-	    assertEquals(kr.getTotalResults(), 4);
-	    assertEquals(2, kr.getMatch(0).startPos);
-	    assertEquals(7, kr.getMatch(0).endPos);
-	    assertEquals(3, kr.getMatch(1).startPos);
-	    assertEquals(7, kr.getMatch(1).endPos);
-	    assertEquals(3, kr.getMatch(2).startPos);
-	    assertEquals(8, kr.getMatch(2).endPos);
-    	
-	    // Next to ---- Distance 1:1
-	    //System.out.println("Next to ---- Distance 1:1");
-	    sq = createElementQuery("x","y",1,1,false);                
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 1);
-	    assertEquals(5, kr.getMatch(0).startPos);
-	    assertEquals(10, kr.getMatch(0).endPos);
-	    
-	    // ---- Distance 1:2
-	    //System.out.println("---- Distance 1:2");
-	    sq = createElementQuery("x","y",1,2,false);                
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 2);	    
-	    assertEquals(4, kr.getMatch(0).startPos);
-	    assertEquals(9, kr.getMatch(0).endPos);
-	    assertEquals(5, kr.getMatch(1).startPos);
-	    assertEquals(10, kr.getMatch(1).endPos);
-	    
+    public void testCase1 () throws IOException {
+        //System.out.println("testcase 1");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.commit();
+
+        SpanQuery sq = createQuery("s:c", "s:d", 0, 3, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 5);
     }
-    
-    /** The same element type 
+
+
+    /**
+     * Multiple documents
+     * Ensure same doc
+     * Both candidate lists are empty, but there is a span left in the
+     * doc
+     * Both candidate lists are empty, but there are more matches in
+     * the doc
      * 
-     * 	WARNING: 
-     * 	This kind of query is not appropriate for an unordered distance span query.
-     * 	Instead, it must be an ordered distance span query. Such an unordered distance 
-     * 	span query yields "redundant results" because matches are searched for each 
-     * 	child span.
+     * @throws IOException
      * */
     @Test
-    public void testCase6() throws IOException{    	
-    	ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc0()); 
-	    ki.commit();    
-	    
-	    //---- Distance 1:2
-	    SpanQuery sq = createElementQuery("x","x",1,2,false);
-	    kr = ki.search(sq, (short) 10);
-	    
-	    assertEquals(kr.getTotalResults(), 4);
+    public void testCase2 () throws IOException {
+        //System.out.println("testcase 2");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanQuery sq = createQuery("s:c", "s:d", 1, 2, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 6);
     }
 
-    /** Nested distance queries
-     * */
-	@Test
-	public void testCase7() throws IOException{
-		//System.out.println("testcase 7");
-		ki = new KrillIndex();
-		ki.addDoc(createFieldDoc0());
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.commit();    
-	    
-	    SpanQuery sq = createQuery("s:c","s:d",1,2,false);
-	    SpanQuery sq2 = new SpanDistanceQuery(
-        		sq,
-        		new SpanTermQuery(new Term("base","s:e")),
-        		new DistanceConstraint(1, 2, true, false),        		
-        		true);
-	    kr = ki.search(sq2, (short) 10);	    
-	    assertEquals(kr.getTotalResults(), 3);	
-	    assertEquals(5, kr.getMatch(0).getStartPos());
-	    assertEquals(9, kr.getMatch(0).getEndPos());
-	    assertEquals(1, kr.getMatch(1).getLocalDocID());
-	    assertEquals(0, kr.getMatch(1).getStartPos());
-	    assertEquals(3, kr.getMatch(1).getEndPos());
-	    assertEquals(0, kr.getMatch(2).getStartPos());
-	    assertEquals(4, kr.getMatch(2).getEndPos());
-	}
 
-	/** Multiple NextSpans in the same first span position
-	 * */
-	@Test
-	public void testCase8() throws IOException{
-		ki = new KrillIndex();
-	    ki.addDoc(createFieldDoc1()); 
-	    ki.commit();
-	    SpanQuery sq = new SpanNextQuery(
-	    		new SpanTermQuery(new Term("base","s:d")),
-	    		createQuery("s:c","s:e",1,2,false)
-		);
-	    kr = ki.search(sq, (short) 10);
-    
-	    assertEquals(kr.getTotalResults(), 3);
-	    assertEquals(0,kr.getMatch(1).getStartPos());
-	    assertEquals(4,kr.getMatch(1).getEndPos());
-	    
-	}
-	
+    /**
+     * Multiple documents
+     * Ensure same Doc
+     * 
+     * @throws IOException
+     * */
+    @Test
+    public void testCase3 () throws IOException {
+        //System.out.println("testcase 3");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        SpanQuery sq = createQuery("s:e", "s:f", 1, 2, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 3);
+        assertEquals(0, kr.getMatch(0).getLocalDocID());
+        assertEquals(7, kr.getMatch(0).getStartPos());
+        assertEquals(9, kr.getMatch(0).getEndPos());
+        assertEquals(2, kr.getMatch(1).getLocalDocID());
+        assertEquals(0, kr.getMatch(1).getStartPos());
+        assertEquals(3, kr.getMatch(1).getEndPos());
+    }
+
+
+    /** Skip to */
+    @Test
+    public void testCase4 () throws IOException {
+        //System.out.println("testcase 4");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.addDoc(createFieldDoc2());
+        ki.commit();
+
+        SpanQuery sq = new SpanNextQuery(
+                createQuery("s:d", "s:e", 1, 2, false), new SpanTermQuery(
+                        new Term("base", "s:f")));
+
+        kr = ki.search(sq, (short) 10);
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(2, kr.getMatch(0).getLocalDocID());
+        assertEquals(2, kr.getMatch(0).getStartPos());
+        assertEquals(6, kr.getMatch(0).getEndPos());
+        assertEquals(3, kr.getMatch(1).getStartPos());
+        assertEquals(6, kr.getMatch(1).getEndPos());
+    }
+
+
+    /** ElementQueries */
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.commit();
+
+        // Intersection ---- Distance 0:0
+        //System.out.println("Intersection ---- Distance 0:0");
+        SpanQuery sq = createElementQuery("x", "y", 0, 0, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 4);
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(7, kr.getMatch(0).endPos);
+        assertEquals(3, kr.getMatch(1).startPos);
+        assertEquals(7, kr.getMatch(1).endPos);
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(8, kr.getMatch(2).endPos);
+
+        // Next to ---- Distance 1:1
+        //System.out.println("Next to ---- Distance 1:1");
+        sq = createElementQuery("x", "y", 1, 1, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(5, kr.getMatch(0).startPos);
+        assertEquals(10, kr.getMatch(0).endPos);
+
+        // ---- Distance 1:2
+        //System.out.println("---- Distance 1:2");
+        sq = createElementQuery("x", "y", 1, 2, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(4, kr.getMatch(0).startPos);
+        assertEquals(9, kr.getMatch(0).endPos);
+        assertEquals(5, kr.getMatch(1).startPos);
+        assertEquals(10, kr.getMatch(1).endPos);
+
+    }
+
+
+    /**
+     * The same element type
+     * 
+     * WARNING:
+     * This kind of query is not appropriate for an unordered distance
+     * span query.
+     * Instead, it must be an ordered distance span query. Such an
+     * unordered distance
+     * span query yields "redundant results" because matches are
+     * searched for each
+     * child span.
+     * */
+    @Test
+    public void testCase6 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.commit();
+
+        //---- Distance 1:2
+        SpanQuery sq = createElementQuery("x", "x", 1, 2, false);
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 4);
+    }
+
+
+    /**
+     * Nested distance queries
+     * */
+    @Test
+    public void testCase7 () throws IOException {
+        //System.out.println("testcase 7");
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc0());
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+
+        SpanQuery sq = createQuery("s:c", "s:d", 1, 2, false);
+        SpanQuery sq2 = new SpanDistanceQuery(sq, new SpanTermQuery(new Term(
+                "base", "s:e")), new DistanceConstraint(1, 2, true, false),
+                true);
+        kr = ki.search(sq2, (short) 10);
+        assertEquals(kr.getTotalResults(), 3);
+        assertEquals(5, kr.getMatch(0).getStartPos());
+        assertEquals(9, kr.getMatch(0).getEndPos());
+        assertEquals(1, kr.getMatch(1).getLocalDocID());
+        assertEquals(0, kr.getMatch(1).getStartPos());
+        assertEquals(3, kr.getMatch(1).getEndPos());
+        assertEquals(0, kr.getMatch(2).getStartPos());
+        assertEquals(4, kr.getMatch(2).getEndPos());
+    }
+
+
+    /**
+     * Multiple NextSpans in the same first span position
+     * */
+    @Test
+    public void testCase8 () throws IOException {
+        ki = new KrillIndex();
+        ki.addDoc(createFieldDoc1());
+        ki.commit();
+        SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("base",
+                "s:d")), createQuery("s:c", "s:e", 1, 2, false));
+        kr = ki.search(sq, (short) 10);
+
+        assertEquals(kr.getTotalResults(), 3);
+        assertEquals(0, kr.getMatch(1).getStartPos());
+        assertEquals(4, kr.getMatch(1).getEndPos());
+
+    }
+
 }
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 305e574..7700678 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
@@ -20,103 +20,92 @@
 
 @RunWith(JUnit4.class)
 public class TestUnorderedElementDistanceIndex {
-	
-	private KrillIndex ki;
-	private Result kr;
-	
-	private FieldDocument createFieldDoc0() {
-    	FieldDocument fd = new FieldDocument();
+
+    private KrillIndex ki;
+    private Result kr;
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc1() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc2() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc3() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	private FieldDocument createFieldDoc4() {
-    	FieldDocument fd = new FieldDocument();
+    }
+
+
+    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#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]");
         return fd;
-	}
-	
-	public SpanQuery createQuery(String elementType, String x, String y, 
-			int minDistance, int maxDistance, boolean isOrdered){
-		SpanElementQuery e = new SpanElementQuery("base", elementType);
-		return new SpanDistanceQuery(        		 
-        		new SpanTermQuery(new Term("base",x)), 
-        		new SpanTermQuery(new Term("base",y)),
-        		new DistanceConstraint(e,minDistance, maxDistance, isOrdered, false),
-        		true);
-	}
-	
-	/** Only terms within an element are matched. 
-	 * */
-	@Test
-	public void testCase1() throws IOException{
-		//System.out.println("testCase1");
-		ki = new KrillIndex();
+    }
+
+
+    public SpanQuery createQuery (String elementType, String x, String y,
+            int minDistance, int maxDistance, boolean isOrdered) {
+        SpanElementQuery e = new SpanElementQuery("base", elementType);
+        return new SpanDistanceQuery(new SpanTermQuery(new Term("base", x)),
+                new SpanTermQuery(new Term("base", y)), new DistanceConstraint(
+                        e, minDistance, maxDistance, isOrdered, false), true);
+    }
+
+
+    /**
+     * Only terms within an element are matched.
+     * */
+    @Test
+    public void testCase1 () throws IOException {
+        //System.out.println("testCase1");
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.commit();
-        
-        SpanQuery sq;        
-        sq = createQuery("s", "s:b", "s:c", 0, 1,false);        
+
+        SpanQuery sq;
+        sq = createQuery("s", "s:b", "s:c", 0, 1, false);
         kr = ki.search(sq, (short) 10);
-		
-        assertEquals((long) 5,kr.getTotalResults());
+
+        assertEquals((long) 5, kr.getTotalResults());
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(1, kr.getMatch(0).endPos);
         assertEquals(0, kr.getMatch(1).startPos);
@@ -126,29 +115,32 @@
         assertEquals(3, kr.getMatch(3).startPos);
         assertEquals(5, kr.getMatch(3).endPos);
         assertEquals(4, kr.getMatch(4).startPos);
-        assertEquals(7, kr.getMatch(4).endPos);        
+        assertEquals(7, kr.getMatch(4).endPos);
 
-	}
-	
-	/** Ensure same doc.
-	 * 	In the beginning, first and second spans are already too far from each other
-	 * 	(one-list-empty case, both-list-empty-case).
-	 * */
-	@Test
-	public void testCase2() throws IOException{
-		//System.out.println("testCase2");
-		ki = new KrillIndex();
+    }
+
+
+    /**
+     * Ensure same doc.
+     * In the beginning, first and second spans are already too far
+     * from each other
+     * (one-list-empty case, both-list-empty-case).
+     * */
+    @Test
+    public void testCase2 () throws IOException {
+        //System.out.println("testCase2");
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc1());
         ki.addDoc(createFieldDoc2());
         ki.commit();
-        
-        SpanQuery sq;        
-        sq = createQuery("p", "s:b", "s:e", 0, 2,false);        
+
+        SpanQuery sq;
+        sq = createQuery("p", "s:b", "s:e", 0, 2, false);
         kr = ki.search(sq, (short) 10);
 
-        assertEquals((long) 3,kr.getTotalResults());
-        assertEquals(2,kr.getMatch(0).getLocalDocID());
+        assertEquals((long) 3, kr.getTotalResults());
+        assertEquals(2, kr.getMatch(0).getLocalDocID());
         assertEquals(3, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
         assertEquals(4, kr.getMatch(1).startPos);
@@ -156,21 +148,23 @@
         assertEquals(6, kr.getMatch(2).startPos);
         assertEquals(8, kr.getMatch(2).endPos);
     }
-	
-	/** Multiple occurrences in an element. 	 
-	 * */
-	@Test
-	public void testCase3() throws IOException{
-		//System.out.println("testCase3");
-		ki = new KrillIndex();
+
+
+    /**
+     * Multiple occurrences in an element.
+     * */
+    @Test
+    public void testCase3 () throws IOException {
+        //System.out.println("testCase3");
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc1());
         ki.commit();
-        
-        SpanQuery sq;        
-        sq = createQuery("s", "s:c", "s:e", 1, 2,false);        
+
+        SpanQuery sq;
+        sq = createQuery("s", "s:c", "s:e", 1, 2, false);
         kr = ki.search(sq, (short) 10);
-	
-        assertEquals((long) 4,kr.getTotalResults());
+
+        assertEquals((long) 4, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(6, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
@@ -179,70 +173,71 @@
         assertEquals(6, kr.getMatch(2).endPos);
         assertEquals(3, kr.getMatch(3).startPos);
         assertEquals(7, kr.getMatch(3).endPos);
-	}
-	
-	/** Multiple documents  
-	 * 	Skip to */
-	@Test
-	public void testCase4() throws IOException{
-		//System.out.println("testCase4");
-		ki = new KrillIndex();		
+    }
+
+
+    /**
+     * Multiple documents
+     * Skip to
+     */
+    @Test
+    public void testCase4 () throws IOException {
+        //System.out.println("testCase4");
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc1());
-        ki.addDoc(createFieldDoc0());        
+        ki.addDoc(createFieldDoc0());
         ki.addDoc(createFieldDoc3());
         ki.addDoc(createFieldDoc4());
         ki.commit();
-        
+
         SpanQuery sq, edq;
-        edq = createQuery("s", "s:b", "s:c", 1, 1,false);
-		
-        sq = new SpanNextQuery(edq, 
-        		new SpanTermQuery(new Term("base", "s:e")));
-        
+        edq = createQuery("s", "s:b", "s:c", 1, 1, false);
+
+        sq = new SpanNextQuery(edq, new SpanTermQuery(new Term("base", "s:e")));
+
         kr = ki.search(sq, (short) 10);
-        
-        assertEquals((long) 4,kr.getTotalResults());
+
+        assertEquals((long) 4, kr.getTotalResults());
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(3, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
         assertEquals(6, kr.getMatch(1).endPos);
         assertEquals(3, kr.getMatch(2).startPos);
         assertEquals(6, kr.getMatch(2).endPos);
-        assertEquals(3,kr.getMatch(3).getLocalDocID());
+        assertEquals(3, kr.getMatch(3).getLocalDocID());
         assertEquals(0, kr.getMatch(3).startPos);
-        assertEquals(4, kr.getMatch(3).endPos);       
+        assertEquals(4, kr.getMatch(3).endPos);
 
     }
-	
-	/** Next */
-	@Test
-	public void testCase5() throws IOException{
-		ki = new KrillIndex();		
+
+
+    /** Next */
+    @Test
+    public void testCase5 () throws IOException {
+        ki = new KrillIndex();
         ki.addDoc(createFieldDoc0());
         ki.commit();
-		
+
         SpanQuery sq, edq;
-        edq = createQuery("s", "s:b", "s:c", 0, 2,false);
+        edq = createQuery("s", "s:b", "s:c", 0, 2, false);
         kr = ki.search(edq, (short) 10);
         assertEquals((long) 6, kr.getTotalResults());
 
-        sq = new SpanNextQuery( 
-        		new SpanTermQuery(new Term("base", "s:b"))
-        		,edq);
+        sq = new SpanNextQuery(new SpanTermQuery(new Term("base", "s:b")), edq);
         kr = ki.search(sq, (short) 10);
         assertEquals((long) 2, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).getStartPos());
         assertEquals(4, kr.getMatch(0).getEndPos());
         assertEquals(2, kr.getMatch(1).getStartPos());
         assertEquals(5, kr.getMatch(1).getEndPos());
-        
-//        System.out.print(kr.getTotalResults()+"\n");
-//		for (int i=0; i< kr.getTotalResults(); i++){
-//			System.out.println(
-//				kr.match(i).getLocalDocID()+" "+
-//				kr.match(i).startPos + " " +
-//				kr.match(i).endPos
-//		    );
-//		}
-	}
+
+        //        System.out.print(kr.getTotalResults()+"\n");
+        //		for (int i=0; i< kr.getTotalResults(); i++){
+        //			System.out.println(
+        //				kr.match(i).getLocalDocID()+" "+
+        //				kr.match(i).startPos + " " +
+        //				kr.match(i).endPos
+        //		    );
+        //		}
+    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
index dc3b4da..1b1ef4d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
@@ -26,188 +26,200 @@
 import de.ids_mannheim.korap.query.SpanRepetitionQuery;
 
 public class TestWPDIndex {
-	long start, end;
-	KrillIndex ki;
-	Result kr;
-	Krill ks;
-	
-	private SpanDistanceQuery createElementDistanceQuery(String e, String x, String y, 
-			int min, int max, boolean isOrdered, boolean exclusion){
-		SpanElementQuery eq = new SpanElementQuery("tokens", e);
-		SpanDistanceQuery sq = new SpanDistanceQuery(
-				new SpanTermQuery(new Term("tokens",x)),
-				new SpanTermQuery(new Term("tokens",y)),
-				new DistanceConstraint(eq, min, max, isOrdered, exclusion),
-        		true
-        ); 
-		return sq;
-	}
-	
-	private SpanDistanceQuery createDistanceQuery(String x, String y, int min, int max, 
-			boolean isOrdered, boolean exclusion){
-		SpanDistanceQuery sq = new SpanDistanceQuery(
-        		new SpanTermQuery(new Term("tokens",x)),
-        		new SpanTermQuery(new Term("tokens",y)),
-        		new DistanceConstraint(min, max, isOrdered, exclusion),
-        		true
-        );
-    	return sq;
+    long start, end;
+    KrillIndex ki;
+    Result kr;
+    Krill ks;
+
+
+    private SpanDistanceQuery createElementDistanceQuery (String e, String x,
+            String y, int min, int max, boolean isOrdered, boolean exclusion) {
+        SpanElementQuery eq = new SpanElementQuery("tokens", e);
+        SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(
+                new Term("tokens", x)),
+                new SpanTermQuery(new Term("tokens", y)),
+                new DistanceConstraint(eq, min, max, isOrdered, exclusion),
+                true);
+        return sq;
     }
-	
-	public TestWPDIndex() throws IOException {
-		InputStream is = getClass().getResourceAsStream("/korap.conf");
-		Properties prop = new Properties();
-		prop.load(is);
-		
-		String indexPath = prop.getProperty("lucene.indexDir");
-		MMapDirectory md = new MMapDirectory(new File(indexPath));
-		ki = new KrillIndex(md);
-	}
-	
-	/** Token distance spans */
-	@Test
-	public void testCase1() throws IOException{
-		SpanDistanceQuery sq;
-		// ordered
-		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true,false);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 8);
 
-		// unordered
-		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false,false);				
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 11);
-		
-		sq = createDistanceQuery("s:kommen", "s:Wir", 1, 1, false,false);				
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 11);
-		//System.out.println(kr.getTotalResults());
-		//for (Match km : kr.getMatches()){
-			//System.out.println(km.getDocID() +" "+km.getStartPos() +" "+ km.getEndPos());
-        	//System.out.println(km.getSnippetBrackets());
-        	//System.out.println(km.toJSON());
+
+    private SpanDistanceQuery createDistanceQuery (String x, String y, int min,
+            int max, boolean isOrdered, boolean exclusion) {
+        SpanDistanceQuery sq = new SpanDistanceQuery(new SpanTermQuery(
+                new Term("tokens", x)),
+                new SpanTermQuery(new Term("tokens", y)),
+                new DistanceConstraint(min, max, isOrdered, exclusion), true);
+        return sq;
+    }
+
+
+    public TestWPDIndex () throws IOException {
+        InputStream is = getClass().getResourceAsStream("/korap.conf");
+        Properties prop = new Properties();
+        prop.load(is);
+
+        String indexPath = prop.getProperty("lucene.indexDir");
+        MMapDirectory md = new MMapDirectory(new File(indexPath));
+        ki = new KrillIndex(md);
+    }
+
+
+    /** Token distance spans */
+    @Test
+    public void testCase1 () throws IOException {
+        SpanDistanceQuery sq;
+        // ordered
+        sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true, false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 8);
+
+        // unordered
+        sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false, false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 11);
+
+        sq = createDistanceQuery("s:kommen", "s:Wir", 1, 1, false, false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 11);
+        //System.out.println(kr.getTotalResults());
+        //for (Match km : kr.getMatches()){
+        //System.out.println(km.getDocID() +" "+km.getStartPos() +" "+ km.getEndPos());
+        //System.out.println(km.getSnippetBrackets());
+        //System.out.println(km.toJSON());
         //}	
-	}
-	
-	/** Token exclusion distance spans */
-	@Test
-	public void testCase2() throws IOException{
+    }
 
-		SpanQuery q = new SpanTermQuery(new Term("tokens","s:Wir"));
-		ks = new Krill(q);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 1907);
-		
-		SpanDistanceQuery sq;
-		// ordered
-		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true, true);				
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 1899);
-		
-		// unordered
-		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false, true);				
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 1896);	
-	}
-	
-	/** Element distance spans */
-	@Test
-	public void testCase3() throws IOException{
-		// ordered
-		SpanDistanceQuery sq = createElementDistanceQuery("s","s:weg", "s:fahren", 
-				0, 1, true, false);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);		
-		assertEquals(kr.getTotalResults(), 3);
-		
-		// unordered
-		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 0, 1, false,false);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 5);
-		
-		// only 0
-		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 0, 0, false,false);
-		kr = ki.search(sq, (short) 100);
-		assertEquals(kr.getTotalResults(), 2);
-		assertEquals("WPD_BBB.04463", kr.getMatch(0).getDocID());
-		assertEquals(1094,kr.getMatch(0).getStartPos());
-		assertEquals(1115,kr.getMatch(0).getEndPos());
-		assertEquals("WPD_III.00758", kr.getMatch(1).getDocID());
-		assertEquals(444,kr.getMatch(1).getStartPos());
-		assertEquals(451,kr.getMatch(1).getEndPos());
-		
-		// only 1
-		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 1, 1, false,false);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 3);		
-	}
-	
-	/** Element distance exclusion */
-	@Test
-	public void testCase4() throws IOException{
-		SpanDistanceQuery sq = createElementDistanceQuery("s","s:weg", "s:fahren", 1, 1, false, true);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 979);
-		//0.8s
-		
-		// Check if it includes some results
-		BooleanFilter bf = new BooleanFilter();
-		bf.or("ID", "WPD_BBB.04463", "WPD_III.00758");
-		KrillCollection kc = new KrillCollection();	
-		kc.filter(bf);
-		ks.setCollection(kc);
-		kr = ks.apply(ki);		
-		assertEquals(1094,kr.getMatch(0).getStartPos());
-		assertEquals(451,kr.getMatch(1).getEndPos());		
-	}
-			
-	/** Repetition */
-	@Test
-	public void testCase5() throws IOException{
-		SpanQuery sq;
-		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),1,2, true);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 4116416);
-		//0.9s
-		
-		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),1,1, true);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 3879671);
-		
-		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),2,2, true);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 236745);
-		//0.65s
-	}
-	
-	/** Next and repetition */
-	@Test
-	public void testCase6() throws IOException{
-		SpanQuery sq = new SpanNextQuery(
-        		new SpanTermQuery(new Term("tokens", "tt/p:NN")),
-        		new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),2,2, true)
-    		);
-		ks = new Krill(sq);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 30223);
-		// 1.1s
-		
-		SpanQuery sq2 = new SpanNextQuery(sq,
-				new SpanTermQuery(new Term("tokens", "tt/p:NN")));
-		ks = new Krill(sq2);
-		kr = ks.apply(ki);
-		assertEquals(kr.getTotalResults(), 26607);
-		// 1.1s
-	}
+
+    /** Token exclusion distance spans */
+    @Test
+    public void testCase2 () throws IOException {
+
+        SpanQuery q = new SpanTermQuery(new Term("tokens", "s:Wir"));
+        ks = new Krill(q);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 1907);
+
+        SpanDistanceQuery sq;
+        // ordered
+        sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 1899);
+
+        // unordered
+        sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 1896);
+    }
+
+
+    /** Element distance spans */
+    @Test
+    public void testCase3 () throws IOException {
+        // ordered
+        SpanDistanceQuery sq = createElementDistanceQuery("s", "s:weg",
+                "s:fahren", 0, 1, true, false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 3);
+
+        // unordered
+        sq = createElementDistanceQuery("s", "s:weg", "s:fahren", 0, 1, false,
+                false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 5);
+
+        // only 0
+        sq = createElementDistanceQuery("s", "s:weg", "s:fahren", 0, 0, false,
+                false);
+        kr = ki.search(sq, (short) 100);
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals("WPD_BBB.04463", kr.getMatch(0).getDocID());
+        assertEquals(1094, kr.getMatch(0).getStartPos());
+        assertEquals(1115, kr.getMatch(0).getEndPos());
+        assertEquals("WPD_III.00758", kr.getMatch(1).getDocID());
+        assertEquals(444, kr.getMatch(1).getStartPos());
+        assertEquals(451, kr.getMatch(1).getEndPos());
+
+        // only 1
+        sq = createElementDistanceQuery("s", "s:weg", "s:fahren", 1, 1, false,
+                false);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 3);
+    }
+
+
+    /** Element distance exclusion */
+    @Test
+    public void testCase4 () throws IOException {
+        SpanDistanceQuery sq = createElementDistanceQuery("s", "s:weg",
+                "s:fahren", 1, 1, false, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 979);
+        //0.8s
+
+        // Check if it includes some results
+        BooleanFilter bf = new BooleanFilter();
+        bf.or("ID", "WPD_BBB.04463", "WPD_III.00758");
+        KrillCollection kc = new KrillCollection();
+        kc.filter(bf);
+        ks.setCollection(kc);
+        kr = ks.apply(ki);
+        assertEquals(1094, kr.getMatch(0).getStartPos());
+        assertEquals(451, kr.getMatch(1).getEndPos());
+    }
+
+
+    /** Repetition */
+    @Test
+    public void testCase5 () throws IOException {
+        SpanQuery sq;
+        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens",
+                "mate/p:ADJA")), 1, 2, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 4116416);
+        //0.9s
+
+        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens",
+                "mate/p:ADJA")), 1, 1, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 3879671);
+
+        sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens",
+                "mate/p:ADJA")), 2, 2, true);
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 236745);
+        //0.65s
+    }
+
+
+    /** Next and repetition */
+    @Test
+    public void testCase6 () throws IOException {
+        SpanQuery sq = new SpanNextQuery(new SpanTermQuery(new Term("tokens",
+                "tt/p:NN")), new SpanRepetitionQuery(new SpanTermQuery(
+                new Term("tokens", "mate/p:ADJA")), 2, 2, true));
+        ks = new Krill(sq);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 30223);
+        // 1.1s
+
+        SpanQuery sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term(
+                "tokens", "tt/p:NN")));
+        ks = new Krill(sq2);
+        kr = ks.apply(ki);
+        assertEquals(kr.getTotalResults(), 26607);
+        // 1.1s
+    }
 }
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 e91be18..9acd416 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -50,20 +50,19 @@
 
         // <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
-                 "[(9-12)s:h]" +   // 4
-                 "[(12-15)s:i]" +  // 5
-                 "[(15-18)s:j]" +  // 6
-                 "[(18-21)s:h]" +  // 7
-                 "[(21-24)s:i]" +  // 8
-                 "[(24-27)s:j]" +  // 9
-                 "[(27-30)s:h]" +  // 10
-                 "[(30-33)s:i]" +  // 11
-                 "[(33-36)s:j]");  // 12
+        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
+                        "[(9-12)s:h]" +   // 4
+                        "[(12-15)s:i]" +  // 5
+                        "[(15-18)s:j]" +  // 6
+                        "[(18-21)s:h]" +  // 7
+                        "[(21-24)s:i]" +  // 8
+                        "[(24-27)s:j]" +  // 9
+                        "[(27-30)s:h]" +  // 10
+                        "[(30-33)s:i]" +  // 11
+                        "[(33-36)s:j]");  // 12
         ki.addDoc(fd);
 
         ki.commit();
@@ -71,13 +70,11 @@
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 10);
-	
+
         assertEquals("totalResults", kr.getTotalResults(), 6);
 
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
@@ -92,10 +89,11 @@
         assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
         assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
         assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
-        
+
         assertEquals(1, ki.numberOf("documents"));
     };
 
+
     @Test
     public void indexExample1b () throws IOException {
         // Cases 9, 12, 13
@@ -103,56 +101,52 @@
 
         // <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
-                 "[(9-12)s:h]" +   // 4
-                 "[(12-15)s:i]" +  // 5
-                 "[(15-18)s:j]" +  // 6
-                 "[(18-21)s:h]" +  // 7
-                 "[(21-24)s:i]" +  // 8
-                 "[(24-27)s:j]" +  // 9
-                 "[(27-30)s:h]" +  // 10
-                 "[(30-33)s:i]" +  // 11
-                 "[(33-36)s:j]");  // 12
+        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
+                        "[(9-12)s:h]" +   // 4
+                        "[(12-15)s:i]" +  // 5
+                        "[(15-18)s:j]" +  // 6
+                        "[(18-21)s:h]" +  // 7
+                        "[(21-24)s:i]" +  // 8
+                        "[(24-27)s:j]" +  // 9
+                        "[(27-30)s:h]" +  // 10
+                        "[(30-33)s:i]" +  // 11
+                        "[(33-36)s:j]");  // 12
         ki.addDoc(fd);
 
         // <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
-                 "[(9-12)s:h]" +   // 4
-                 "[(12-15)s:i]" +  // 5
-                 "[(15-18)s:j]" +  // 6
-                 "[(18-21)s:h]" +  // 7
-                 "[(21-24)s:i]" +  // 8
-                 "[(24-27)s:j]" +  // 9
-                 "[(27-30)s:h]" +  // 10
-                 "[(30-33)s:i]" +  // 11
-                 "[(33-36)s:j]");  // 12
+        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
+                        "[(9-12)s:h]" +   // 4
+                        "[(12-15)s:i]" +  // 5
+                        "[(15-18)s:j]" +  // 6
+                        "[(18-21)s:h]" +  // 7
+                        "[(21-24)s:i]" +  // 8
+                        "[(24-27)s:j]" +  // 9
+                        "[(27-30)s:h]" +  // 10
+                        "[(30-33)s:i]" +  // 11
+                        "[(33-36)s:j]");  // 12
         ki.addDoc(fd);
 
 
         // Save documents
         ki.commit();
-        
+
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 15);
-	
+
         assertEquals("totalResults", kr.getTotalResults(), 12);
-	
+
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
         assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
         assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
@@ -192,10 +186,10 @@
         assertEquals("Doc (11)", 1, kr.getMatch(11).internalDocID);
 
         /*
-		for (Match km : kr.getMatches()){		
-			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+        for (Match km : kr.getMatches()){		
+        	System.out.println(km.getStartPos() +","+km.getEndPos()+" "
                                +km.getSnippetBrackets());
-		};	
+        };	
         */
 
         assertEquals(2, ki.numberOf("documents"));
@@ -209,53 +203,49 @@
 
         // <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
-                 "[(9-12)s:h]" +   // 4
-                 "[(12-15)s:i]" +  // 5
-                 "[(15-18)s:j]" +  // 6
-                 "[(18-21)s:h]" +  // 7
-                 "[(21-24)s:i]" +  // 8
-                 "[(24-27)s:j]" +  // 9
-                 "[(27-30)s:h]" +  // 10
-                 "[(30-33)s:i]" +  // 11
-                 "[(33-36)s:j]");  // 12
+        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
+                        "[(9-12)s:h]" +   // 4
+                        "[(12-15)s:i]" +  // 5
+                        "[(15-18)s:j]" +  // 6
+                        "[(18-21)s:h]" +  // 7
+                        "[(21-24)s:i]" +  // 8
+                        "[(24-27)s:j]" +  // 9
+                        "[(27-30)s:h]" +  // 10
+                        "[(30-33)s:i]" +  // 11
+                        "[(33-36)s:j]");  // 12
         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|<>: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
-                 "[(9-12)s:a]" +   // 4
-                 "[(12-15)s:b]" +  // 5
-                 "[(15-18)s:c]" +  // 6
-                 "[(18-21)s:a]" +  // 7
-                 "[(21-24)s:b]" +  // 8
-                 "[(24-27)s:c]" +  // 9
-                 "[(27-30)s:a]" +  // 10
-                 "[(30-33)s:b]" +  // 11
-                 "[(33-36)s:c]");  // 12
+        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
+                        "[(9-12)s:a]" +   // 4
+                        "[(12-15)s:b]" +  // 5
+                        "[(15-18)s:c]" +  // 6
+                        "[(18-21)s:a]" +  // 7
+                        "[(21-24)s:b]" +  // 8
+                        "[(24-27)s:c]" +  // 9
+                        "[(27-30)s:a]" +  // 10
+                        "[(30-33)s:b]" +  // 11
+                        "[(33-36)s:c]");  // 12
         ki.addDoc(fd);
-        
+
         // Save documents
         ki.commit();
 
         SpanQuery sq;
         Result kr;
 
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 15);
-	
+
         assertEquals("totalResults", kr.getTotalResults(), 6);
 
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
@@ -288,47 +278,43 @@
 
         // <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
-                 "[(9-12)s:h]" +   // 4
-                 "[(12-15)s:i]" +  // 5
-                 "[(15-18)s:j]" +  // 6
-                 "[(18-21)s:h]" +  // 7
-                 "[(21-24)s:i]" +  // 8
-                 "[(24-27)s:j]" +  // 9
-                 "[(27-30)s:h]" +  // 10
-                 "[(30-33)s:i]" +  // 11
-                 "[(33-36)s:j]");  // 12
+        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
+                        "[(9-12)s:h]" +   // 4
+                        "[(12-15)s:i]" +  // 5
+                        "[(15-18)s:j]" +  // 6
+                        "[(18-21)s:h]" +  // 7
+                        "[(21-24)s:i]" +  // 8
+                        "[(24-27)s:j]" +  // 9
+                        "[(27-30)s:h]" +  // 10
+                        "[(30-33)s:i]" +  // 11
+                        "[(33-36)s:j]");  // 12
         ki.addDoc(fd);
 
         fd = new FieldDocument();
-        fd.addTV("base",
-                 "x   y   z   h   ",
-                 "[(0-3)s:x]" +  // 1
-                 "[(3-6)s:y]" +  // 2
-                 "[(6-9)s:z]" +  // 3
-                 "[(9-12)s:h]"); // 4
+        fd.addTV("base", "x   y   z   h   ", "[(0-3)s:x]" +  // 1
+                "[(3-6)s:y]" +  // 2
+                "[(6-9)s:z]" +  // 3
+                "[(9-12)s:h]"); // 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|<>: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
-                 "[(9-12)s:a]" +   // 4
-                 "[(12-15)s:b]" +  // 5
-                 "[(15-18)s:c]" +  // 6
-                 "[(18-21)s:a]" +  // 7
-                 "[(21-24)s:b]" +  // 8
-                 "[(24-27)s:c]" +  // 9
-                 "[(27-30)s:a]" +  // 10
-                 "[(30-33)s:b]" +  // 11
-                 "[(33-36)s:c]");  // 12
+        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
+                        "[(9-12)s:a]" +   // 4
+                        "[(12-15)s:b]" +  // 5
+                        "[(15-18)s:c]" +  // 6
+                        "[(18-21)s:a]" +  // 7
+                        "[(21-24)s:b]" +  // 8
+                        "[(24-27)s:c]" +  // 9
+                        "[(27-30)s:a]" +  // 10
+                        "[(30-33)s:b]" +  // 11
+                        "[(33-36)s:c]");  // 12
         ki.addDoc(fd);
 
         // Save documents
@@ -340,13 +326,11 @@
         sq = new SpanElementQuery("base", "a");
         kr = ki.search(sq, (short) 15);
 
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 15);
-	
+
         assertEquals("totalResults", kr.getTotalResults(), 6);
 
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
@@ -367,10 +351,11 @@
         assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
         assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
         assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
-        
+
         assertEquals(3, ki.numberOf("documents"));
     };
-    
+
+
     @Test
     public void indexExample2a () throws IOException {
         KrillIndex ki = new KrillIndex();
@@ -378,18 +363,18 @@
         // <a><a><a>h</a>hij</a>hij</a>
         FieldDocument fd = new FieldDocument();
         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
+                // <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
         ki.addDoc(fd);
 
         // Save documents
@@ -410,11 +395,9 @@
         assertEquals("EndPos (1)", 7, kr.getMatch(1).endPos);
         assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
         assertEquals("EndPos (2)", 9, kr.getMatch(2).endPos);
-	    
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 10);
 
@@ -444,6 +427,7 @@
         assertEquals("EndPos (9)", 9, kr.getMatch(9).endPos);
     };
 
+
     @Test
     public void indexExample2b () throws IOException {
         KrillIndex ki = new KrillIndex();
@@ -451,19 +435,18 @@
         // 6,9,12
         // <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
-                 "[(3-6)s:h]" +    // 2
-                 "[(6-9)s:i]" +    // 3
-                 "[(9-12)s:j]" +   // 4
-                 "[(12-15)s:h]" +  // 5
-                 "[(15-18)s:i]" +  // 6
-                 "[(18-21)s:j]" +  // 7
-                 "[(21-24)s:h]" +  // 8
-                 "[(24-27)s:i]" +  // 9
-                 "[(27-30)s:j]" +  // 10
-                 "[(30-33)s:h]");
+        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
+                        "[(3-6)s:h]" +    // 2
+                        "[(6-9)s:i]" +    // 3
+                        "[(9-12)s:j]" +   // 4
+                        "[(12-15)s:h]" +  // 5
+                        "[(15-18)s:i]" +  // 6
+                        "[(18-21)s:j]" +  // 7
+                        "[(21-24)s:h]" +  // 8
+                        "[(24-27)s:i]" +  // 9
+                        "[(27-30)s:j]" +  // 10
+                        "[(30-33)s:h]");
         ki.addDoc(fd);
 
         // Save documents
@@ -481,11 +464,9 @@
         assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
         assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
         assertEquals("EndPos (2)", 9, kr.getMatch(2).endPos);
-        
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 10);
 
@@ -518,22 +499,21 @@
         // 2, 6, 9, 12
         // <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
-                 "[(3-6)s:h]" +    // 2
-                 "[(6-9)s:i]" +  // 3
-                 "[(9-12)s:j]" +  // 4
-                 "[(12-15)s:h]" +  // 5
-                 "[(15-18)s:i]" +  // 6
-                 "[(18-21)s:j]" +  // 7
-                 "[(21-24)s:h]" +  // 8
-                 "[(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
+        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
+                        "[(3-6)s:h]" +    // 2
+                        "[(6-9)s:i]" +  // 3
+                        "[(9-12)s:j]" +  // 4
+                        "[(12-15)s:h]" +  // 5
+                        "[(15-18)s:i]" +  // 6
+                        "[(18-21)s:j]" +  // 7
+                        "[(21-24)s:h]" +  // 8
+                        "[(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
         ki.addDoc(fd);
-        
+
         // Save documents
         ki.commit();
 
@@ -542,7 +522,7 @@
         SpanQuery sq = new SpanElementQuery("base", "a");
 
         Result kr = ki.search(sq, (short) 10);
-    
+
         assertEquals("totalResults", kr.getTotalResults(), 4);
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
         assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
@@ -553,10 +533,8 @@
         assertEquals("StartPos (3)", 11, kr.getMatch(3).startPos);
         assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
 
-        sq = new SpanWithinQuery(
-	        new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 10);
 
@@ -567,7 +545,7 @@
         assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
         assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
         assertEquals("EndPos (2)", 4, kr.getMatch(2).endPos);
-      
+
         assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
         assertEquals("EndPos (3)", 7, kr.getMatch(3).endPos);
         assertEquals("StartPos (4)", 0, kr.getMatch(4).startPos);
@@ -589,24 +567,24 @@
     @Test
     public void indexExample2d () throws IOException {
         KrillIndex ki = new KrillIndex();
-        
+
         // 2, 6, 9, 12, 7
         // <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]" + // 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
+        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]"
+                        + // 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
         ki.addDoc(fd);
 
         // Save documents
@@ -617,7 +595,7 @@
         SpanQuery sq = new SpanElementQuery("base", "a");
 
         Result kr = ki.search(sq, (short) 10);
-    
+
         assertEquals("totalResults", kr.getTotalResults(), 5);
 
         assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
@@ -631,10 +609,8 @@
         assertEquals("StartPos (4)", 11, kr.getMatch(4).startPos);
         assertEquals("EndPos (4)", 12, kr.getMatch(4).endPos);
 
-        sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:h"))
-        );
+        sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:h")));
 
         kr = ki.search(sq, (short) 15);
 
@@ -678,84 +654,56 @@
 
         // <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]");
+        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]");
         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]" +
-                 "[(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]");
+        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]"
+                        + "[(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]");
         ki.addDoc(fd);
 
         // xyz
         fd = new FieldDocument();
-        fd.addTV("base",
-                 "x   y   z   ",
-                 "[(0-3)s:x]" +
-                 "[(3-6)s:y]" +
-                 "[(6-9)s:z]");
+        fd.addTV("base", "x   y   z   ", "[(0-3)s:x]" + "[(3-6)s:y]"
+                + "[(6-9)s:z]");
         ki.addDoc(fd);
-        
+
         // <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]" +
-                 "[(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]");
+        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]"
+                        + "[(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]");
         ki.addDoc(fd);
 
         // <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]" +
-                 "[(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]");
+        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]"
+                        + "[(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);
 
         // xyz
         fd = new FieldDocument();
-        fd.addTV("base",
-                 "a  b  c  ",
-                 "[(0-3)s:a]" +
-                 "[(3-6)s:b]" +
-                 "[(6-9)s:c]");
+        fd.addTV("base", "a  b  c  ", "[(0-3)s:a]" + "[(3-6)s:b]"
+                + "[(6-9)s:c]");
         ki.addDoc(fd);
 
         // Save documents
         ki.commit();
-    
+
         assertEquals(6, ki.numberOf("documents"));
 
         SpanQuery sq = new SpanElementQuery("base", "a");
@@ -782,7 +730,7 @@
         assertEquals("EndPos (7)", 9, kr.getMatch(7).endPos);
         assertEquals("StartPos (8)", 2, kr.getMatch(8).startPos);
         assertEquals("EndPos (8)", 6, kr.getMatch(8).endPos);
-        
+
         assertEquals("StartPos (9)", 0, kr.getMatch(9).startPos);
         assertEquals("EndPos (9)", 3, kr.getMatch(9).endPos);
         assertEquals("StartPos (10)", 0, kr.getMatch(10).startPos);
@@ -791,6 +739,7 @@
         assertEquals("EndPos (11)", 9, kr.getMatch(11).endPos);
     };
 
+
     @Test
     public void indexExample3Offsets () throws IOException {
         KrillIndex ki = new KrillIndex();
@@ -798,109 +747,87 @@
         // Er schrie: <s>"Das war ich!"</s>
         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]");
+        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]");
         ki.addDoc(fd);
 
         // Save documents
         ki.commit();
-        
-        SpanQuery sq = new SpanClassQuery(new SpanElementQuery("base", "sentence"), (byte)3);
+
+        SpanQuery sq = new SpanClassQuery(new SpanElementQuery("base",
+                "sentence"), (byte) 3);
         Result kr;
         kr = ki.search(sq, 0, (short) 15, true, (short) 1, true, (short) 1);
         assertEquals("totalResults", kr.getTotalResults(), 1);
-        
-        assertEquals("... schrie: [\"{3:Das war ich}!\"] und ...",kr.getMatch(0).getSnippetBrackets());
-        assertEquals("<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><mark>&quot;<mark class=\"class-3 level-0\">Das war ich</mark>!&quot;</mark><span class=\"context-right\"> und<span class=\"more\"></span></span>",kr.getMatch(0).getSnippetHTML());
+
+        assertEquals("... schrie: [\"{3:Das war ich}!\"] und ...",
+                kr.getMatch(0).getSnippetBrackets());
+        assertEquals(
+                "<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><mark>&quot;<mark class=\"class-3 level-0\">Das war ich</mark>!&quot;</mark><span class=\"context-right\"> und<span class=\"more\"></span></span>",
+                kr.getMatch(0).getSnippetHTML());
 
         kr = ki.search(sq, 0, (short) 15, true, (short) 0, true, (short) 0);
-        assertEquals("... [\"{3:Das war ich}!\"] ...",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("... [\"{3:Das war ich}!\"] ...", kr.getMatch(0)
+                .getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
         kr = ki.search(sq, 0, (short) 15, true, (short) 6, true, (short) 6);
-        assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging.",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging.", kr
+                .getMatch(0).getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
         kr = ki.search(sq, 0, (short) 15, true, (short) 2, true, (short) 2);
-        assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging ...",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging ...", kr
+                .getMatch(0).getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
-        sq = new SpanClassQuery(
-            new SpanWithinQuery(
-                new SpanElementQuery("base", "sentence"),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:Das")), (byte) 2
-                )
-            ),
-            (byte) 1
-        );
+        sq = new SpanClassQuery(new SpanWithinQuery(new SpanElementQuery(
+                "base", "sentence"), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:Das")), (byte) 2)), (byte) 1);
 
         kr = ki.search(sq, (short) 15);
-        assertEquals("Er schrie: [\"{1:{2:Das} war ich}!\"] und ging.",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("Er schrie: [\"{1:{2:Das} war ich}!\"] und ging.", kr
+                .getMatch(0).getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
-        sq = new SpanClassQuery(
-            new SpanWithinQuery(
-                new SpanElementQuery("base", "sentence"),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:war")), (byte) 2
-                )
-            ),
-            (byte) 1
-        );
+        sq = new SpanClassQuery(new SpanWithinQuery(new SpanElementQuery(
+                "base", "sentence"), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:war")), (byte) 2)), (byte) 1);
 
         kr = ki.search(sq, (short) 15);
-        assertEquals("Er schrie: [\"{1:Das {2:war} ich}!\"] und ging.",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("Er schrie: [\"{1:Das {2:war} ich}!\"] und ging.", kr
+                .getMatch(0).getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
-        sq = new SpanClassQuery(
-            new SpanWithinQuery(
-                new SpanElementQuery("base", "sentence"),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:ich")), (byte) 2
-                )
-            ),
-            (byte) 1
-        );
-        
+        sq = new SpanClassQuery(new SpanWithinQuery(new SpanElementQuery(
+                "base", "sentence"), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:ich")), (byte) 2)), (byte) 1);
+
         kr = ki.search(sq, (short) 15);
-        assertEquals("Er schrie: [\"{1:Das war {2:ich}}!\"] und ging.",kr.getMatch(0).getSnippetBrackets());
+        assertEquals("Er schrie: [\"{1:Das war {2:ich}}!\"] und ging.", kr
+                .getMatch(0).getSnippetBrackets());
         assertEquals("totalResults", kr.getTotalResults(), 1);
 
-        sq = new SpanClassQuery(
-            new SpanWithinQuery(
-                new SpanElementQuery("base", "sentence"),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:und")), (byte) 2
-                )
-            ),
-            (byte) 1
-        );
+        sq = new SpanClassQuery(new SpanWithinQuery(new SpanElementQuery(
+                "base", "sentence"), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:und")), (byte) 2)), (byte) 1);
 
         kr = ki.search(sq, (short) 15);
         assertEquals("totalResults", kr.getTotalResults(), 0);
 
-        sq = new SpanClassQuery(
-            new SpanWithinQuery(
-                new SpanElementQuery("base", "sentence"),
-                new SpanClassQuery(
-                    new SpanTermQuery(new Term("base", "s:schrie")), (byte) 2
-                )
-            ),
-            (byte) 1
-        );
+        sq = new SpanClassQuery(new SpanWithinQuery(new SpanElementQuery(
+                "base", "sentence"), new SpanClassQuery(new SpanTermQuery(
+                new Term("base", "s:schrie")), (byte) 2)), (byte) 1);
 
         kr = ki.search(sq, (short) 15);
         assertEquals("totalResults", kr.getTotalResults(), 0);
     };
 
+
     @Test
     public void indexExample4 () throws IOException {
         KrillIndex ki = new KrillIndex();
@@ -908,14 +835,12 @@
         // 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#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]");
         ki.addDoc(fd);
 
         // Save documents
@@ -923,10 +848,8 @@
 
         assertEquals(1, ki.numberOf("documents"));
 
-        SpanQuery sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanTermQuery(new Term("base", "s:x"))
-        );
+        SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanTermQuery(new Term("base", "s:x")));
 
         Result kr = ki.search(sq, (short) 10);
 
@@ -937,6 +860,7 @@
         assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
     };
 
+
     @Test
     public void indexExample5 () throws IOException {
         // 1,2,3,6,9,10,12
@@ -944,18 +868,15 @@
 
         // 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]");
+        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]");
         ki.addDoc(fd);
 
         // Save documents
@@ -963,13 +884,9 @@
 
         assertEquals(1, ki.numberOf("documents"));
 
-        SpanQuery sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:h")),
-                new SpanTermQuery(new Term("base", "s:i"))
-            )
-        );
+        SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")),
+                        new SpanTermQuery(new Term("base", "s:i"))));
 
         Result kr = ki.search(sq, (short) 10);
 
@@ -985,23 +902,22 @@
         assertEquals("EndPos (3)", 8, kr.getMatch(3).endPos);
     };
 
+
     @Test
     public void indexExample6 () throws IOException {
         KrillIndex ki = new KrillIndex();
         // 2,5,8,12,13
         // 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]");
+        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]");
         ki.addDoc(fd);
 
         // Save documents
@@ -1009,16 +925,11 @@
 
         assertEquals(1, ki.numberOf("documents"));
 
-        SpanQuery sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:h")),
-                new SpanNextQuery(
-                    new SpanTermQuery(new Term("base", "s:i")),
-                    new SpanTermQuery(new Term("base", "s:j"))
-                )
-            )
-        );
+        SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")),
+                        new SpanNextQuery(new SpanTermQuery(new Term("base",
+                                "s:i")), new SpanTermQuery(new Term("base",
+                                "s:j")))));
 
         Result kr = ki.search(sq, (short) 10);
         assertEquals("totalResults", kr.getTotalResults(), 0);
@@ -1031,16 +942,13 @@
         // 4,5,11,13
         // 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]");
+        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]");
         ki.addDoc(fd);
 
         // Save documents
@@ -1048,62 +956,50 @@
 
         assertEquals(1, ki.numberOf("documents"));
 
-        SpanQuery sq = new SpanWithinQuery(
-            new SpanElementQuery("base", "a"),
-            new SpanNextQuery(
-                new SpanTermQuery(new Term("base", "s:h")),
-                new SpanNextQuery(
-                    new SpanTermQuery(new Term("base", "s:i")),
-                    new SpanTermQuery(new Term("base", "s:j"))
-                )
-            )
-        );
+        SpanQuery sq = new SpanWithinQuery(new SpanElementQuery("base", "a"),
+                new SpanNextQuery(new SpanTermQuery(new Term("base", "s:h")),
+                        new SpanNextQuery(new SpanTermQuery(new Term("base",
+                                "s:i")), new SpanTermQuery(new Term("base",
+                                "s:j")))));
 
         Result kr = ki.search(sq, (short) 10);
-        
+
         assertEquals("totalResults", kr.getTotalResults(), 0);
     };
-    
+
 
     /** SpanElementQueries */
     @Test
-    public void indexExample8() throws IOException{	   
-        KrillIndex ki = new KrillIndex();		
+    public void indexExample8 () throws IOException {
+        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#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]");
         ki.addDoc(fd);
     };
-    
+
 
     // contains(<s>, (es wird | wird es))
     @Test
-    public void queryJSONpoly2() throws QueryException, IOException {
-        String jsonPath = getClass().getResource("/queries/poly2.json").getFile();
-        String jsonPQuery = readFile(jsonPath);		
+    public void queryJSONpoly2 () throws QueryException, IOException {
+        String jsonPath = getClass().getResource("/queries/poly2.json")
+                .getFile();
+        String jsonPQuery = readFile(jsonPath);
         SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson(jsonPQuery);
-		
+
         SpanWithinQuery sq = (SpanWithinQuery) sqwi.toQuery();
-		
+
         KrillIndex ki = new KrillIndex();
 
-        ki.addDoc(
-            getClass().getResourceAsStream("/wiki/DDD-08370.json.gz"),
-            true
-        );
-        ki.addDoc(
-            getClass().getResourceAsStream("/wiki/PPP-02924.json.gz"),
-            true
-        );
+        ki.addDoc(getClass().getResourceAsStream("/wiki/DDD-08370.json.gz"),
+                true);
+        ki.addDoc(getClass().getResourceAsStream("/wiki/PPP-02924.json.gz"),
+                true);
 
         ki.commit();
         Result kr = ki.search(sq, (short) 10);
@@ -1116,15 +1012,15 @@
         assertEquals(252, kr.getMatch(1).getEndPos());
 
         /*
-		for (Match km : kr.getMatches()){		
-			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
+        for (Match km : kr.getMatches()){		
+        	System.out.println(km.getStartPos() +","+km.getEndPos()+" "
                                +km.getSnippetBrackets());
-		};	
+        };	
         */
     };
-	
-	
-    private String readFile(String path) {
+
+
+    private String readFile (String path) {
         StringBuilder sb = new StringBuilder();
         try {
             BufferedReader in = new BufferedReader(new FileReader(path));
@@ -1133,7 +1029,8 @@
                 sb.append(str);
             };
             in.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             fail(e.getMessage());
         }
         return sb.toString();
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestFrameConstraint.java b/src/test/java/de/ids_mannheim/korap/query/TestFrameConstraint.java
index fd4285f..ed5c41d 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestFrameConstraint.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestFrameConstraint.java
@@ -7,7 +7,6 @@
 import de.ids_mannheim.korap.util.QueryException;
 import org.apache.lucene.search.spans.Spans;
 
-
 import static org.junit.Assert.*;
 import org.junit.Test;
 import org.junit.Ignore;
@@ -26,6 +25,7 @@
         assertEquals(fc.check(1), false);
     };
 
+
     @Test
     public void testBitVector () throws QueryException {
         int a = 1;
@@ -34,309 +34,293 @@
         assertEquals(3, a ^ b);
     };
 
+
     @Test
     public void testOr () throws QueryException {
         FrameConstraint fc = new FrameConstraint();
 
         // Nothing set
-        assertEquals(fc.check("precedes"),         false);
+        assertEquals(fc.check("precedes"), false);
         assertEquals(fc.check("precedesDirectly"), false);
-        assertEquals(fc.check("overlapsLeft"),     false);
-        assertEquals(fc.check("alignsLeft"),       false);
-        assertEquals(fc.check("startsWith"),       false);
-        assertEquals(fc.check("matches"),          false);
-        assertEquals(fc.check("isWithin"),         false);
-        assertEquals(fc.check("isAround"),         false);
-        assertEquals(fc.check("endsWith"),         false);
-        assertEquals(fc.check("alignsRight"),      false);
-        assertEquals(fc.check("overlapsRight"),    false);
+        assertEquals(fc.check("overlapsLeft"), false);
+        assertEquals(fc.check("alignsLeft"), false);
+        assertEquals(fc.check("startsWith"), false);
+        assertEquals(fc.check("matches"), false);
+        assertEquals(fc.check("isWithin"), false);
+        assertEquals(fc.check("isAround"), false);
+        assertEquals(fc.check("endsWith"), false);
+        assertEquals(fc.check("alignsRight"), false);
+        assertEquals(fc.check("overlapsRight"), false);
         assertEquals(fc.check("succeedsDirectly"), false);
-        assertEquals(fc.check("succeeds"),         false);
+        assertEquals(fc.check("succeeds"), false);
 
         // Some or
         fc.add("succeeds").add("succeedsDirectly");
-        assertEquals(fc.check("precedes"),         false);
+        assertEquals(fc.check("precedes"), false);
         assertEquals(fc.check("precedesDirectly"), false);
-        assertEquals(fc.check("overlapsLeft"),     false);
-        assertEquals(fc.check("alignsLeft"),       false);
-        assertEquals(fc.check("startsWith"),       false);
-        assertEquals(fc.check("matches"),          false);
-        assertEquals(fc.check("isWithin"),         false);
-        assertEquals(fc.check("isAround"),         false);
-        assertEquals(fc.check("endsWith"),         false);
-        assertEquals(fc.check("alignsRight"),      false);
-        assertEquals(fc.check("overlapsRight"),    false);
+        assertEquals(fc.check("overlapsLeft"), false);
+        assertEquals(fc.check("alignsLeft"), false);
+        assertEquals(fc.check("startsWith"), false);
+        assertEquals(fc.check("matches"), false);
+        assertEquals(fc.check("isWithin"), false);
+        assertEquals(fc.check("isAround"), false);
+        assertEquals(fc.check("endsWith"), false);
+        assertEquals(fc.check("alignsRight"), false);
+        assertEquals(fc.check("overlapsRight"), false);
         assertEquals(fc.check("succeedsDirectly"), true);
-        assertEquals(fc.check("succeeds"),         true);
+        assertEquals(fc.check("succeeds"), true);
 
         // Moar or
         fc.add("precedes").add("precedesDirectly");
-        assertEquals(fc.check("precedes"),         true);
+        assertEquals(fc.check("precedes"), true);
         assertEquals(fc.check("precedesDirectly"), true);
-        assertEquals(fc.check("overlapsLeft"),     false);
-        assertEquals(fc.check("alignsLeft"),       false);
-        assertEquals(fc.check("startsWith"),       false);
-        assertEquals(fc.check("matches"),          false);
-        assertEquals(fc.check("isWithin"),         false);
-        assertEquals(fc.check("isAround"),         false);
-        assertEquals(fc.check("endsWith"),         false);
-        assertEquals(fc.check("alignsRight"),      false);
-        assertEquals(fc.check("overlapsRight"),    false);
+        assertEquals(fc.check("overlapsLeft"), false);
+        assertEquals(fc.check("alignsLeft"), false);
+        assertEquals(fc.check("startsWith"), false);
+        assertEquals(fc.check("matches"), false);
+        assertEquals(fc.check("isWithin"), false);
+        assertEquals(fc.check("isAround"), false);
+        assertEquals(fc.check("endsWith"), false);
+        assertEquals(fc.check("alignsRight"), false);
+        assertEquals(fc.check("overlapsRight"), false);
         assertEquals(fc.check("succeedsDirectly"), true);
-        assertEquals(fc.check("succeeds"),         true);
+        assertEquals(fc.check("succeeds"), true);
 
         // Moar or
         fc.add("matches").add("startsWith");
-        assertEquals(fc.check("precedes"),         true);
+        assertEquals(fc.check("precedes"), true);
         assertEquals(fc.check("precedesDirectly"), true);
-        assertEquals(fc.check("overlapsLeft"),     false);
-        assertEquals(fc.check("alignsLeft"),       false);
-        assertEquals(fc.check("startsWith"),       true);
-        assertEquals(fc.check("matches"),          true);
-        assertEquals(fc.check("isWithin"),         false);
-        assertEquals(fc.check("isAround"),         false);
-        assertEquals(fc.check("endsWith"),         false);
-        assertEquals(fc.check("alignsRight"),      false);
-        assertEquals(fc.check("overlapsRight"),    false);
+        assertEquals(fc.check("overlapsLeft"), false);
+        assertEquals(fc.check("alignsLeft"), false);
+        assertEquals(fc.check("startsWith"), true);
+        assertEquals(fc.check("matches"), true);
+        assertEquals(fc.check("isWithin"), false);
+        assertEquals(fc.check("isAround"), false);
+        assertEquals(fc.check("endsWith"), false);
+        assertEquals(fc.check("alignsRight"), false);
+        assertEquals(fc.check("overlapsRight"), false);
         assertEquals(fc.check("succeedsDirectly"), true);
-        assertEquals(fc.check("succeeds"),         true);
+        assertEquals(fc.check("succeeds"), true);
 
         // Invert
         fc.invert();
-        assertEquals(fc.check("precedes"),         false);
+        assertEquals(fc.check("precedes"), false);
         assertEquals(fc.check("precedesDirectly"), false);
-        assertEquals(fc.check("overlapsLeft"),     true);
-        assertEquals(fc.check("alignsLeft"),       true);
-        assertEquals(fc.check("startsWith"),       false);
-        assertEquals(fc.check("matches"),          false);
-        assertEquals(fc.check("isWithin"),         true);
-        assertEquals(fc.check("isAround"),         true);
-        assertEquals(fc.check("endsWith"),         true);
-        assertEquals(fc.check("alignsRight"),      true);
-        assertEquals(fc.check("overlapsRight"),    true);
+        assertEquals(fc.check("overlapsLeft"), true);
+        assertEquals(fc.check("alignsLeft"), true);
+        assertEquals(fc.check("startsWith"), false);
+        assertEquals(fc.check("matches"), false);
+        assertEquals(fc.check("isWithin"), true);
+        assertEquals(fc.check("isAround"), true);
+        assertEquals(fc.check("endsWith"), true);
+        assertEquals(fc.check("alignsRight"), true);
+        assertEquals(fc.check("overlapsRight"), true);
         assertEquals(fc.check("succeedsDirectly"), false);
-        assertEquals(fc.check("succeeds"),         false);
+        assertEquals(fc.check("succeeds"), false);
 
-        fc.add("precedes").
-            add("precedesDirectly").
-            add("startsWith").
-            add("matches");
-        assertEquals(fc.check("precedes"),         true);
+        fc.add("precedes").add("precedesDirectly").add("startsWith")
+                .add("matches");
+        assertEquals(fc.check("precedes"), true);
         assertEquals(fc.check("precedesDirectly"), true);
-        assertEquals(fc.check("overlapsLeft"),     true);
-        assertEquals(fc.check("alignsLeft"),       true);
-        assertEquals(fc.check("startsWith"),       true);
-        assertEquals(fc.check("matches"),          true);
-        assertEquals(fc.check("isWithin"),         true);
-        assertEquals(fc.check("isAround"),         true);
-        assertEquals(fc.check("endsWith"),         true);
-        assertEquals(fc.check("alignsRight"),      true);
-        assertEquals(fc.check("overlapsRight"),    true);
+        assertEquals(fc.check("overlapsLeft"), true);
+        assertEquals(fc.check("alignsLeft"), true);
+        assertEquals(fc.check("startsWith"), true);
+        assertEquals(fc.check("matches"), true);
+        assertEquals(fc.check("isWithin"), true);
+        assertEquals(fc.check("isAround"), true);
+        assertEquals(fc.check("endsWith"), true);
+        assertEquals(fc.check("alignsRight"), true);
+        assertEquals(fc.check("overlapsRight"), true);
         assertEquals(fc.check("succeedsDirectly"), false);
-        assertEquals(fc.check("succeeds"),         false);
+        assertEquals(fc.check("succeeds"), false);
 
-        fc.add("succeeds").
-            add("succeedsDirectly");
-        assertEquals(fc.check("precedes"),         true);
+        fc.add("succeeds").add("succeedsDirectly");
+        assertEquals(fc.check("precedes"), true);
         assertEquals(fc.check("precedesDirectly"), true);
-        assertEquals(fc.check("overlapsLeft"),     true);
-        assertEquals(fc.check("alignsLeft"),       true);
-        assertEquals(fc.check("startsWith"),       true);
-        assertEquals(fc.check("matches"),          true);
-        assertEquals(fc.check("isWithin"),         true);
-        assertEquals(fc.check("isAround"),         true);
-        assertEquals(fc.check("endsWith"),         true);
-        assertEquals(fc.check("alignsRight"),      true);
-        assertEquals(fc.check("overlapsRight"),    true);
+        assertEquals(fc.check("overlapsLeft"), true);
+        assertEquals(fc.check("alignsLeft"), true);
+        assertEquals(fc.check("startsWith"), true);
+        assertEquals(fc.check("matches"), true);
+        assertEquals(fc.check("isWithin"), true);
+        assertEquals(fc.check("isAround"), true);
+        assertEquals(fc.check("endsWith"), true);
+        assertEquals(fc.check("alignsRight"), true);
+        assertEquals(fc.check("overlapsRight"), true);
         assertEquals(fc.check("succeedsDirectly"), true);
-        assertEquals(fc.check("succeeds"),         true);
+        assertEquals(fc.check("succeeds"), true);
     };
 
+
     @Test
     public void testOrVector () throws QueryException {
         FrameConstraint fc1 = new FrameConstraint();
         // Some or
         fc1.add("succeeds").add("succeedsDirectly");
-        assertEquals(fc1.check("precedes"),         false);
+        assertEquals(fc1.check("precedes"), false);
         assertEquals(fc1.check("precedesDirectly"), false);
-        assertEquals(fc1.check("overlapsLeft"),     false);
-        assertEquals(fc1.check("alignsLeft"),       false);
-        assertEquals(fc1.check("startsWith"),       false);
-        assertEquals(fc1.check("matches"),          false);
-        assertEquals(fc1.check("isWithin"),         false);
-        assertEquals(fc1.check("isAround"),         false);
-        assertEquals(fc1.check("endsWith"),         false);
-        assertEquals(fc1.check("alignsRight"),      false);
-        assertEquals(fc1.check("overlapsRight"),    false);
+        assertEquals(fc1.check("overlapsLeft"), false);
+        assertEquals(fc1.check("alignsLeft"), false);
+        assertEquals(fc1.check("startsWith"), false);
+        assertEquals(fc1.check("matches"), false);
+        assertEquals(fc1.check("isWithin"), false);
+        assertEquals(fc1.check("isAround"), false);
+        assertEquals(fc1.check("endsWith"), false);
+        assertEquals(fc1.check("alignsRight"), false);
+        assertEquals(fc1.check("overlapsRight"), false);
         assertEquals(fc1.check("succeedsDirectly"), true);
-        assertEquals(fc1.check("succeeds"),         true);
+        assertEquals(fc1.check("succeeds"), true);
 
         FrameConstraint fc2 = new FrameConstraint();
         fc2.add("precedes").add("precedesDirectly");
-        assertEquals(fc2.check("precedes"),         true);
+        assertEquals(fc2.check("precedes"), true);
         assertEquals(fc2.check("precedesDirectly"), true);
-        assertEquals(fc2.check("overlapsLeft"),     false);
-        assertEquals(fc2.check("alignsLeft"),       false);
-        assertEquals(fc2.check("startsWith"),       false);
-        assertEquals(fc2.check("matches"),          false);
-        assertEquals(fc2.check("isWithin"),         false);
-        assertEquals(fc2.check("isAround"),         false);
-        assertEquals(fc2.check("endsWith"),         false);
-        assertEquals(fc2.check("alignsRight"),      false);
-        assertEquals(fc2.check("overlapsRight"),    false);
+        assertEquals(fc2.check("overlapsLeft"), false);
+        assertEquals(fc2.check("alignsLeft"), false);
+        assertEquals(fc2.check("startsWith"), false);
+        assertEquals(fc2.check("matches"), false);
+        assertEquals(fc2.check("isWithin"), false);
+        assertEquals(fc2.check("isAround"), false);
+        assertEquals(fc2.check("endsWith"), false);
+        assertEquals(fc2.check("alignsRight"), false);
+        assertEquals(fc2.check("overlapsRight"), false);
         assertEquals(fc2.check("succeedsDirectly"), false);
-        assertEquals(fc2.check("succeeds"),         false);
+        assertEquals(fc2.check("succeeds"), false);
 
         fc1.add(fc2);
-        assertEquals(fc1.check("precedes"),         true);
+        assertEquals(fc1.check("precedes"), true);
         assertEquals(fc1.check("precedesDirectly"), true);
-        assertEquals(fc1.check("overlapsLeft"),     false);
-        assertEquals(fc1.check("alignsLeft"),       false);
-        assertEquals(fc1.check("startsWith"),       false);
-        assertEquals(fc1.check("matches"),          false);
-        assertEquals(fc1.check("isWithin"),         false);
-        assertEquals(fc1.check("isAround"),         false);
-        assertEquals(fc1.check("endsWith"),         false);
-        assertEquals(fc1.check("alignsRight"),      false);
-        assertEquals(fc1.check("overlapsRight"),    false);
+        assertEquals(fc1.check("overlapsLeft"), false);
+        assertEquals(fc1.check("alignsLeft"), false);
+        assertEquals(fc1.check("startsWith"), false);
+        assertEquals(fc1.check("matches"), false);
+        assertEquals(fc1.check("isWithin"), false);
+        assertEquals(fc1.check("isAround"), false);
+        assertEquals(fc1.check("endsWith"), false);
+        assertEquals(fc1.check("alignsRight"), false);
+        assertEquals(fc1.check("overlapsRight"), false);
         assertEquals(fc1.check("succeedsDirectly"), true);
-        assertEquals(fc1.check("succeeds"),         true);
+        assertEquals(fc1.check("succeeds"), true);
     };
 
+
     @Test
     public void testConstellation () throws QueryException {
         FrameConstraint fc1 = new FrameConstraint();
         fc1.invert();
 
         // Precedes
-        assertEquals(
-            FrameConstraint.PRECEDES,
-            fc1._constellation(new TestSpans(2,3), new TestSpans(4,5))
-        );
+        assertEquals(FrameConstraint.PRECEDES,
+                fc1._constellation(new TestSpans(2, 3), new TestSpans(4, 5)));
 
         // PrecedesDirectly
-        assertEquals(
-            FrameConstraint.PRECEDES_DIRECTLY,
-            fc1._constellation(new TestSpans(2,3), new TestSpans(3,5))
-        );
+        assertEquals(FrameConstraint.PRECEDES_DIRECTLY,
+                fc1._constellation(new TestSpans(2, 3), new TestSpans(3, 5)));
 
         // OverlapsLeft
-        assertEquals(
-            FrameConstraint.OVERLAPS_LEFT,
-            fc1._constellation(new TestSpans(2,4), new TestSpans(3,5))
-        );
+        assertEquals(FrameConstraint.OVERLAPS_LEFT,
+                fc1._constellation(new TestSpans(2, 4), new TestSpans(3, 5)));
 
         // AlignsLeft
-        assertEquals(
-            FrameConstraint.ALIGNS_LEFT,
-            fc1._constellation(new TestSpans(2,4), new TestSpans(2,5))
-        );
+        assertEquals(FrameConstraint.ALIGNS_LEFT,
+                fc1._constellation(new TestSpans(2, 4), new TestSpans(2, 5)));
 
         // StartsWith
-        assertEquals(
-            FrameConstraint.STARTS_WITH,
-            fc1._constellation(new TestSpans(2,5), new TestSpans(2,4))
-        );
+        assertEquals(FrameConstraint.STARTS_WITH,
+                fc1._constellation(new TestSpans(2, 5), new TestSpans(2, 4)));
 
         // Matches
-        assertEquals(
-            FrameConstraint.MATCHES,
-            fc1._constellation(new TestSpans(2,5), new TestSpans(2,5))
-        );
+        assertEquals(FrameConstraint.MATCHES,
+                fc1._constellation(new TestSpans(2, 5), new TestSpans(2, 5)));
 
         // IsWithin
-        assertEquals(
-            FrameConstraint.IS_WITHIN,
-            fc1._constellation(new TestSpans(3,4), new TestSpans(2,5))
-        );
+        assertEquals(FrameConstraint.IS_WITHIN,
+                fc1._constellation(new TestSpans(3, 4), new TestSpans(2, 5)));
 
         // IsAround
-        assertEquals(
-            FrameConstraint.IS_AROUND,
-            fc1._constellation(new TestSpans(2,5), new TestSpans(3,4))
-        );
+        assertEquals(FrameConstraint.IS_AROUND,
+                fc1._constellation(new TestSpans(2, 5), new TestSpans(3, 4)));
 
         // EndsWith
-        assertEquals(
-            FrameConstraint.ENDS_WITH,
-            fc1._constellation(new TestSpans(3,5), new TestSpans(4,5))
-        );
+        assertEquals(FrameConstraint.ENDS_WITH,
+                fc1._constellation(new TestSpans(3, 5), new TestSpans(4, 5)));
 
         // AlignsRight
-        assertEquals(
-            FrameConstraint.ALIGNS_RIGHT,
-            fc1._constellation(new TestSpans(3,4), new TestSpans(2,4))
-        );
+        assertEquals(FrameConstraint.ALIGNS_RIGHT,
+                fc1._constellation(new TestSpans(3, 4), new TestSpans(2, 4)));
 
         // OverlapsRight
-        assertEquals(
-            FrameConstraint.OVERLAPS_RIGHT,
-            fc1._constellation(new TestSpans(3,5), new TestSpans(2,4))
-        );
+        assertEquals(FrameConstraint.OVERLAPS_RIGHT,
+                fc1._constellation(new TestSpans(3, 5), new TestSpans(2, 4)));
 
         // SucceedsDirectly
-        assertEquals(
-            FrameConstraint.SUCCEEDS_DIRECTLY,
-            fc1._constellation(new TestSpans(4,6), new TestSpans(2,4))
-        );
+        assertEquals(FrameConstraint.SUCCEEDS_DIRECTLY,
+                fc1._constellation(new TestSpans(4, 6), new TestSpans(2, 4)));
 
         // Succeeds
-        assertEquals(
-            FrameConstraint.SUCCEEDS,
-            fc1._constellation(new TestSpans(5,6), new TestSpans(2,4))
-        );
+        assertEquals(FrameConstraint.SUCCEEDS,
+                fc1._constellation(new TestSpans(5, 6), new TestSpans(2, 4)));
     };
 
     private class TestSpans extends Spans {
         private int s, e;
 
+
         // Constructor
         public TestSpans (int start, int end) {
             this.s = start;
             this.e = end;
         };
 
+
         @Override
         public int doc () {
             return 0;
         };
 
+
         @Override
         public int start () {
             return this.s;
         };
 
+
         @Override
         public int end () {
             return this.e;
         };
 
+
         @Override
         public boolean skipTo (int target) {
             return true;
         };
 
+
         @Override
         public boolean next () {
             return true;
         };
 
-        public Collection<byte[]> getPayload() throws IOException {
+
+        public Collection<byte[]> getPayload () throws IOException {
             return null;
         }
 
+
         @Override
-        public boolean isPayloadAvailable() throws IOException {
+        public boolean isPayloadAvailable () throws IOException {
             return false;
         };
 
+
         @Override
-        public String toString () {				
+        public String toString () {
             return "";
         };
 
+
         @Override
-        public long cost () {				
+        public long cost () {
             return 1;
         };
 
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
index 96a473c..e4cd6ac 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQuery.java
@@ -24,45 +24,61 @@
     public void korapQuerySegment () throws QueryException {
         SpanQuery sq = new QueryBuilder("field1").seg("a").with("b").toQuery();
         assertEquals("spanSegment(field1:a, field1:b)", sq.toString());
-        
+
         sq = new QueryBuilder("field2").seg("a", "b").with("c").toQuery();
-        assertEquals("spanSegment(spanSegment(field2:a, field2:b), field2:c)", sq.toString());
+        assertEquals("spanSegment(spanSegment(field2:a, field2:b), field2:c)",
+                sq.toString());
     };
 
+
     @Test
     public void korapQueryRegexSegment () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field1");
         SpanQuery sq = kq.seg("a").with(kq.re("b.*c")).toQuery();
-        assertEquals("spanSegment(field1:a, SpanMultiTermQueryWrapper(field1:/b.*c/))", sq.toString());
+        assertEquals(
+                "spanSegment(field1:a, SpanMultiTermQueryWrapper(field1:/b.*c/))",
+                sq.toString());
 
         kq = new QueryBuilder("field2");
         sq = kq.seg(kq.re("a.*")).with("b").toQuery();
-        assertEquals("spanSegment(SpanMultiTermQueryWrapper(field2:/a.*/), field2:b)", sq.toString());
+        assertEquals(
+                "spanSegment(SpanMultiTermQueryWrapper(field2:/a.*/), field2:b)",
+                sq.toString());
     };
 
+
     @Test
     public void korapQueryRegexSegment2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
         SpanQuery sq = kq.seg("a").with(kq.or("b").or("c")).toQuery();
-        assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))", sq.toString());
+        assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))",
+                sq.toString());
 
         kq = new QueryBuilder("field");
         sq = kq.seg("a").with(kq.or("b", "c")).toQuery();
-        assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))", sq.toString());
+        assertEquals("spanSegment(field:a, spanOr([field:b, field:c]))",
+                sq.toString());
 
         kq = new QueryBuilder("field");
         // [ a & (b | /c.*d/) ]
         sq = kq.seg("a").with(kq.or("b").or(kq.re("c.*d"))).toQuery();
-        assertEquals("spanSegment(field:a, spanOr([field:b, SpanMultiTermQueryWrapper(field:/c.*d/)]))", sq.toString());
+        assertEquals(
+                "spanSegment(field:a, spanOr([field:b, SpanMultiTermQueryWrapper(field:/c.*d/)]))",
+                sq.toString());
     };
 
+
     @Test
     public void korapQuerySequenceSegment () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("a").with(kq.or("b", "c"))).append("d").append(kq.re("e.?f")).toQuery();
-        assertEquals("spanNext(spanNext(spanSegment(field:a, spanOr([field:b, field:c])), field:d), SpanMultiTermQueryWrapper(field:/e.?f/))", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("a").with(kq.or("b", "c"))).append("d")
+                .append(kq.re("e.?f")).toQuery();
+        assertEquals(
+                "spanNext(spanNext(spanSegment(field:a, spanOr([field:b, field:c])), field:d), SpanMultiTermQueryWrapper(field:/e.?f/))",
+                sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -70,6 +86,7 @@
         assertEquals("<field:np />", sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -77,6 +94,7 @@
         assertEquals("spanOr([<field:np />, <field:vp />])", sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery3 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -84,13 +102,18 @@
         assertEquals("spanNext(<field:np />, <field:vp />)", sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery4 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.tag("np"), kq.tag("vp")).append("test").toQuery();
-        assertEquals("spanNext(spanNext(<field:np />, <field:vp />), field:test)", sq.toString());
+        SpanQuery sq = kq.seq(kq.tag("np"), kq.tag("vp")).append("test")
+                .toQuery();
+        assertEquals(
+                "spanNext(spanNext(<field:np />, <field:vp />), field:test)",
+                sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery5 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -98,21 +121,32 @@
         assertEquals("spanContain(<field:s />, <field:np />)", sq.toString());
     };
 
+
     @Test
     public void KorapTagQuery6 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("tree"), kq.contains(kq.tag("s"), kq.tag("np")), kq.re("hey.*")).toQuery();
-        assertEquals("spanNext(spanNext(field:tree, spanContain(<field:s />, <field:np />)), SpanMultiTermQueryWrapper(field:/hey.*/))", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("tree"),
+                kq.contains(kq.tag("s"), kq.tag("np")), kq.re("hey.*"))
+                .toQuery();
+        assertEquals(
+                "spanNext(spanNext(field:tree, spanContain(<field:s />, <field:np />)), SpanMultiTermQueryWrapper(field:/hey.*/))",
+                sq.toString());
     };
-    
+
 
     @Test
     public void KorapClassQuery () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("tree"), kq._(1, kq.contains(kq.tag("s"), kq.tag("np"))), kq.re("hey.*")).toQuery();
-        assertEquals("spanNext(spanNext(field:tree, {1: spanContain(<field:s />, <field:np />)}), SpanMultiTermQueryWrapper(field:/hey.*/))", sq.toString());
+        SpanQuery sq = kq
+                .seq(kq.seg("tree"),
+                        kq._(1, kq.contains(kq.tag("s"), kq.tag("np"))),
+                        kq.re("hey.*")).toQuery();
+        assertEquals(
+                "spanNext(spanNext(field:tree, {1: spanContain(<field:s />, <field:np />)}), SpanMultiTermQueryWrapper(field:/hey.*/))",
+                sq.toString());
     };
 
+
     @Test
     public void KorapClassQuery2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -120,13 +154,19 @@
         assertEquals("{1: field:base:test}", sq.toString());
     };
 
+
     @Test
     public void KorapClassQuery3 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("tree"), kq.contains(kq.tag("s"), kq._(kq.tag("np"))), kq.re("hey.*")).toQuery();
-        assertEquals("spanNext(spanNext(field:tree, spanContain(<field:s />, {1: <field:np />})), SpanMultiTermQueryWrapper(field:/hey.*/))", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("tree"),
+                kq.contains(kq.tag("s"), kq._(kq.tag("np"))), kq.re("hey.*"))
+                .toQuery();
+        assertEquals(
+                "spanNext(spanNext(field:tree, spanContain(<field:s />, {1: <field:np />})), SpanMultiTermQueryWrapper(field:/hey.*/))",
+                sq.toString());
     };
 
+
     @Test
     public void KorapShrinkQuery () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -134,6 +174,7 @@
         assertEquals("focus(1: <field:np />)", sq.toString());
     };
 
+
     @Test
     public void KorapShrinkQuery1 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -141,6 +182,7 @@
         assertEquals("focus(1: <field:np />)", sq.toString());
     };
 
+
     @Test
     public void KorapShrinkQuery2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -148,20 +190,33 @@
         assertEquals("focus(1: {1: <field:np />})", sq.toString());
     };
 
+
     @Test
     public void KorapShrinkQuery3 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.focus(1, kq._(1, kq.seq(kq.tag("np"), kq._(kq.seg("test").without("no"))))).toQuery();
-        assertEquals("focus(1: {1: spanNext(<field:np />, {1: spanNot(field:test, field:no, 0, 0)})})", sq.toString());
+        SpanQuery sq = kq
+                .focus(1,
+                        kq._(1,
+                                kq.seq(kq.tag("np"),
+                                        kq._(kq.seg("test").without("no")))))
+                .toQuery();
+        assertEquals(
+                "focus(1: {1: spanNext(<field:np />, {1: spanNot(field:test, field:no, 0, 0)})})",
+                sq.toString());
     };
 
+
     @Test
     public void KorapShrinkQuery4 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1"), kq.focus(1, kq._(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
-        assertEquals("spanNext(spanNext(field:try1, focus(1: {1: field:try2})), field:try3)", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1"),
+                kq.focus(1, kq._(1, kq.seg("try2"))), kq.seg("try3")).toQuery();
+        assertEquals(
+                "spanNext(spanNext(field:try1, focus(1: {1: field:try2})), field:try3)",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery1 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -169,55 +224,85 @@
         assertEquals("spanNext(field:try1, field:try2)", sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3).toQuery();
-        assertEquals("spanDistance(field:try1, field:try2, [(w[2:3], ordered, notExcluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(2, 3).toQuery();
+        assertEquals(
+                "spanDistance(field:try1, field:try2, [(w[2:3], ordered, notExcluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery3 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3, "s").toQuery();
-        assertEquals("spanElementDistance(field:try1, field:try2, [(s[2:3], ordered, notExcluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(2, 3, "s").toQuery();
+        assertEquals(
+                "spanElementDistance(field:try1, field:try2, [(s[2:3], ordered, notExcluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery4 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3,"s").withConstraint(5,6,"w").toQuery();
-        assertEquals("spanMultipleDistance(field:try1, field:try2, [(s[2:3], ordered, notExcluded), (w[5:6], ordered, notExcluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(2, 3, "s").withConstraint(5, 6, "w").toQuery();
+        assertEquals(
+                "spanMultipleDistance(field:try1, field:try2, [(s[2:3], ordered, notExcluded), (w[5:6], ordered, notExcluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery5 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3,true).toQuery();
-        assertEquals("spanDistance(field:try1, field:try2, [(w[2:3], ordered, excluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(2, 3, true).toQuery();
+        assertEquals(
+                "spanDistance(field:try1, field:try2, [(w[2:3], ordered, excluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery6 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(2,3,"s", true).toQuery();
-        assertEquals("spanElementDistance(field:try1, field:try2, [(s[2:3], ordered, excluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(2, 3, "s", true).toQuery();
+        assertEquals(
+                "spanElementDistance(field:try1, field:try2, [(s[2:3], ordered, excluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery7 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).withConstraint(5,6).withConstraint(2,3,"s",true).toQuery();
-        assertEquals("spanMultipleDistance(field:try1, field:try2, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .withConstraint(5, 6).withConstraint(2, 3, "s", true).toQuery();
+        assertEquals(
+                "spanMultipleDistance(field:try1, field:try2, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapSequenceQuery8 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
-        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2")).append("try3").withConstraint(5,6).withConstraint(2,3,"s",true).toQuery();
-        assertEquals("spanMultipleDistance(spanMultipleDistance(field:try1, field:try2, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)]), field:try3, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)])", sq.toString());
+        SpanQuery sq = kq.seq(kq.seg("try1")).append(kq.seg("try2"))
+                .append("try3").withConstraint(5, 6)
+                .withConstraint(2, 3, "s", true).toQuery();
+        assertEquals(
+                "spanMultipleDistance(spanMultipleDistance(field:try1, field:try2, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)]), field:try3, [(w[5:6], ordered, notExcluded), (s[2:3], ordered, excluded)])",
+                sq.toString());
     };
 
+
     @Test
     public void KorapWithinQuery1 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -225,6 +310,7 @@
         assertEquals("spanContain(field:test, field:test2)", sq.toString());
     };
 
+
     @Test
     public void KorapWithinQuery2 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
@@ -232,13 +318,14 @@
         assertEquals("spanOverlap(field:test, field:test2)", sq.toString());
     };
 
+
     @Test
     public void KorapWithinQuery3 () throws QueryException {
         QueryBuilder kq = new QueryBuilder("field");
         SpanQuery sq = kq.startswith(kq.seg("test"), kq.seg("test2")).toQuery();
         assertEquals("spanStartsWith(field:test, field:test2)", sq.toString());
     };
-   
+
     // kq.seg("a").append(kq.ANY).append("b:c");
     // kq.repeat(kq.seg("a", "b"), 5)
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
index 2613a20..26565fa 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKrillQueryJSON.java
@@ -21,349 +21,465 @@
 
     @Test
     public void queryJSONBsp1 () throws QueryException {
-	SpanQueryWrapper 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]
-	assertEquals(sqwi.toQuery().toString(),
-            "spanOr([tokens:base:foo, spanRepetition(spanNext(tokens:base:foo, tokens:base:bar){1,100})])");
-	assertTrue(sqwi.isOptional());
+        // There is a repetition in here
+        // ([base=foo]|[base=bar])[base=foobar]
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanOr([tokens:base:foo, spanRepetition(spanNext(tokens:base:foo, tokens:base:bar){1,100})])");
+        assertTrue(sqwi.isOptional());
     };
 
+
     @Test
     public void queryJSONBsp1b () throws QueryException {
 
-	SpanQueryWrapper 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:mate/l:foo, spanNext(tokens:mate/l:foo, tokens:mate/l:bar)])");
+        // [base=foo]|([base=foo][base=bar]) meta author=Goethe&year=1815
+        assertEquals(sqwi.toQuery().toString(),
+                "spanOr([tokens:mate/l:foo, spanNext(tokens:mate/l:foo, tokens:mate/l:bar)])");
     };
 
 
     @Test
     public void queryJSONBsp2 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:foo, tokens:mate/l:bar]), tokens:mate/l:foobar)");
+        // ([base=foo]|[base=bar])[base=foobar]
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanNext(spanOr([tokens:mate/l:foo, tokens:mate/l:bar]), tokens:mate/l:foobar)");
     };
 
+
     @Test
     public void queryJSONBsp3 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp3.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp3.jsonld").getFile());
 
-	// focus({[base=Mann]})
-	assertEquals(sqwi.toQuery().toString(), "focus(1: {1: tokens:mate/l:Mann})");
+        // focus({[base=Mann]})
+        assertEquals(sqwi.toQuery().toString(),
+                "focus(1: {1: tokens:mate/l:Mann})");
     };
 
+
     @Test
     public void queryJSONBsp4 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp4.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp4.jsonld").getFile());
 
-	// focus({[base=foo]}[orth=bar])
-	assertEquals(sqwi.toQuery().toString(), "focus(1: spanNext({1: tokens:mate/l:foo}, tokens:s:bar))");
+        // focus({[base=foo]}[orth=bar])
+        assertEquals(sqwi.toQuery().toString(),
+                "focus(1: spanNext({1: tokens:mate/l:foo}, tokens:s:bar))");
     };
 
+
     @Test
     public void queryJSONBsp5 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp5.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp5.jsonld").getFile());
 
-	// focus(1:[base=Der]{1:[base=Mann]}) 
-	assertEquals(sqwi.toQuery().toString(), "focus(1: spanNext(tokens:mate/l:Der, {1: tokens:mate/l:Mann}))");
+        // focus(1:[base=Der]{1:[base=Mann]}) 
+        assertEquals(sqwi.toQuery().toString(),
+                "focus(1: spanNext(tokens:mate/l:Der, {1: tokens:mate/l:Mann}))");
     };
 
+
     @Test
     public void queryJSONBsp6 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp6.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp6.jsonld").getFile());
 
-	// [base=katze]
-	assertEquals(sqwi.toQuery().toString(), "tokens:mate/l:Katze");
+        // [base=katze]
+        assertEquals(sqwi.toQuery().toString(), "tokens:mate/l:Katze");
     };
 
+
     @Test
     public void queryJSONBsp7 () throws QueryException {
-	SpanQueryWrapper 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());
-	assertTrue(sqwi.isNegative());
+        // [!base=Katze]
+        assertEquals("tokens:mate/l:Katze", sqwi.toQuery().toString());
+        assertTrue(sqwi.isNegative());
     };
 
+
     @Test
     public void queryJSONBsp9 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:Katze, tokens:s:Katzen)");
+        // [base=Katze&orth=Katzen]
+        assertEquals(sqwi.toQuery().toString(),
+                "spanSegment(tokens:mate/l:Katze, tokens:s:Katzen)");
     };
 
+
     @Test
     public void queryJSONBsp9b () throws QueryException {
-	SpanQueryWrapper 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)");
+        // [base=Katze&orth=Katzen]
+        assertEquals(sqwi.toQuery().toString(),
+                "spanSegment(tokens:mate/m:number:pl, tokens:tt/p:NN)");
     };
 
 
     @Test
     public void queryJSONBsp10 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:Katze, tokens:s:und), tokens:s:Hunde)");
+        // [base=Katze][orth=und][orth=Hunde]
+        assertEquals(sqwi.toQuery().toString(),
+                "spanNext(spanNext(tokens:mate/l:Katze, tokens:s:und), tokens:s:Hunde)");
     };
 
+
     @Test
     public void queryJSONBsp11 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bsp11.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bsp11.jsonld").getFile());
 
-	// [base!=Katze | orth!=Katzen]
-	/*
-	  Imagine a([^b]|[^c])d
-	  Matches abd and acd
-	  Interpretation would be not(spanAnd(...))
-	*/
-	assertEquals(sqwi.toQuery().toString(), "spanOr([tokens:mate/l:Katze, tokens:s:Katzen])");
-	assertTrue(sqwi.isNegative());
+        // [base!=Katze | orth!=Katzen]
+        /*
+          Imagine a([^b]|[^c])d
+          Matches abd and acd
+          Interpretation would be not(spanAnd(...))
+        */
+        assertEquals(sqwi.toQuery().toString(),
+                "spanOr([tokens:mate/l:Katze, tokens:s:Katzen])");
+        assertTrue(sqwi.isNegative());
     };
 
+
     @Test
     public void queryJSONBsp12 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:Mann)");
+        // contains(<np>,[base=Mann])
+        assertEquals(sqwi.toQuery().toString(),
+                "spanContain(<tokens:np />, tokens:mate/l:Mann)");
     };
 
+
     @Test
     public void queryJSONBsp13 () throws QueryException {
-	SpanQueryWrapper 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:p:Det)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanStartsWith(<tokens:np />, tokens:p:Det)");
     };
 
+
     @Test
     public void queryJSONBsp13b () throws QueryException {
-	SpanQueryWrapper 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)");
+        // startswith(<np>,[pos=Det])
+        assertEquals(sqwi.toQuery().toString(),
+                "spanStartsWith(<tokens:np />, tokens:mate/p:Det)");
     };
 
+
     @Test
     public void queryJSONBsp14 () throws QueryException {
-	SpanQueryWrapper 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/)");
+        // 'vers{2,3}uch'
+        assertEquals(sqwi.toQuery().toString(),
+                "SpanMultiTermQueryWrapper(tokens:/s:vers{2,3}uch/)");
     };
 
+
     @Test
     public void queryJSONBsp15 () throws QueryException {
-	SpanQueryWrapper 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/)");
+        // [orth='vers.*ch']
+        assertEquals(sqwi.toQuery().toString(),
+                "SpanMultiTermQueryWrapper(tokens:/s:vers.*ch/)");
     };
 
+
     @Test
     public void queryJSONBsp16 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:bar, tokens:mate/l:foo]), tokens:s:foobar)");
+        // [(base=bar|base=foo)&orth=foobar]
+        assertEquals(sqwi.toQuery().toString(),
+                "spanSegment(spanOr([tokens:mate/l:bar, tokens:mate/l:foo]), tokens:s:foobar)");
     };
 
+
     @Test
     public void queryJSONBsp17 () throws QueryException {
-	SpanQueryWrapper 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:mate/l:Mann)");
+        // within(<np>,[base=Mann])
+        assertEquals(sqwi.toQuery().toString(),
+                "spanContain(<tokens:np />, tokens:mate/l:Mann)");
     };
 
+
     @Test
     public void queryJSONDemo () throws QueryException {
-	SpanQueryWrapper sqwi = new KrillQuery("tokens").fromJson("{ \"query\" : { \"@type\" : \"koral:token\", \"wrap\" : { \"@type\" : \"koral:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
+        SpanQueryWrapper sqwi = new KrillQuery("tokens")
+                .fromJson("{ \"query\" : { \"@type\" : \"koral:token\", \"wrap\" : { \"@type\" : \"koral:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
 
-	assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
+        assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
     };
 
+
     @Test
     public void queryJSONBspClass () throws QueryException {
-	SpanQueryWrapper 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(), "{1: spanNext(tokens:tt/p:ADJA, tokens:mate/p:NN)}");
+        // within(<np>,[base=Mann])
+        assertEquals(sqwi.toQuery().toString(),
+                "{1: spanNext(tokens:tt/p:ADJA, tokens:mate/p:NN)}");
     };
-    
+
+
     @Test
     public void queryJSONcosmas3 () throws QueryException {
-	SpanQueryWrapper 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)])");
+        // "das /+w1:3 Buch"
+        assertEquals(sqwi.toQuery().toString(),
+                "spanDistance(tokens:s:das, tokens:s:Buch, [(w[1:3], ordered, notExcluded)])");
     };
 
+
     @Test
     public void queryJSONcosmas4 () throws QueryException {
-	SpanQueryWrapper 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)])");
+        // "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)])");
     };
 
+
     @Test
     public void queryJSONcosmas4b () throws QueryException {
-	SpanQueryWrapper 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)])");
+        // "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)])");
     };
 
+
     @Test
     public void queryJSONcosmas10 () throws QueryException {
-	SpanQueryWrapper 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)");
+        // "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)");
     };
 
+
     @Test
     public void queryJSONcosmas10b () throws QueryException {
-	SpanQueryWrapper 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)");
+        // "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)");
     };
 
+
     @Test
     public void queryJSONcosmas16 () throws QueryException {
-	SpanQueryWrapper 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(), "focus(1: spanStartsWith(<tokens:s />, {1: tokens:i:wegen}))");
+        // "$wegen #IN(L) <s>"
+        assertEquals(sqwi.toQuery().toString(),
+                "focus(1: spanStartsWith(<tokens:s />, {1: tokens:i:wegen}))");
     };
 
+
     @Test
     public void queryJSONcosmas17 () throws QueryException {
-	SpanQueryWrapper 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)");
+        // "#BED($wegen , +sa)"
+        assertEquals(sqwi.toQuery().toString(),
+                "spanStartsWith(<tokens:s />, tokens:i:wegen)");
     };
 
+
     @Test
     public void queryJSONcosmas20 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/cosmas20.json").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/cosmas20.json").getFile());
 
-	//     "MORPH(V) #IN(R) #ELEM(S)"
-	assertEquals(sqwi.toQuery().toString(), "focus(1: spanEndsWith(<tokens:s />, {1: tokens:p:V}))");
+        //     "MORPH(V) #IN(R) #ELEM(S)"
+        assertEquals(sqwi.toQuery().toString(),
+                "focus(1: spanEndsWith(<tokens:s />, {1: tokens:p:V}))");
     };
 
+
     @Test
     public void queryJSONrepetition () throws QueryException {
-	SpanQueryWrapper 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(tokens:s:der, spanOr([tokens:tt/p:NN, spanNext(spanRepetition(tokens:cnx/p:A{1,2}), tokens:tt/p:NN)]))");
+        // der[cnx/p=A]{0,2}[tt/p=NN]
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanNext(tokens:s:der, spanOr([tokens:tt/p:NN, spanNext(spanRepetition(tokens:cnx/p:A{1,2}), tokens:tt/p:NN)]))");
     };
 
+
     @Test
     public void queryJSONboundaryBug () throws QueryException {
-	SpanQueryWrapper 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)])");
+        // Tal []{1,} Wald
+        assertEquals(sqwi.toQuery().toString(),
+                "spanDistance(tokens:s:Tal, tokens:s:Wald, [(w[2:100], ordered, notExcluded)])");
     };
 
+
     @Test
     public void queryJSONcosmasBoundaryBug () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/cosmas_boundary.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/cosmas_boundary.jsonld").getFile());
 
-	// Namen /s1 Leben
-	assertEquals(sqwi.toQuery().toString(), "focus(129: spanElementDistance({129: tokens:s:Namen}, {129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))");
+        // Namen /s1 Leben
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "focus(129: spanElementDistance({129: tokens:s:Namen}, {129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))");
     };
 
+
     @Test
     public void queryJSONfoundryForOrthBug () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/foundry_for_orth.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/foundry_for_orth.jsonld").getFile());
 
-	// opennlp/orth:Baum
-	assertEquals(sqwi.toQuery().toString(), "tokens:s:Baum");
+        // opennlp/orth:Baum
+        assertEquals(sqwi.toQuery().toString(), "tokens:s:Baum");
     };
 
+
     @Test
     public void queryJSONfoundryForOrthBug2 () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/foundry_for_orth_2.jsonld").getFile());
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/foundry_for_orth_2.jsonld").getFile());
 
-	// baum/i
-	assertEquals(sqwi.toQuery().toString(), "tokens:i:baum");
+        // baum/i
+        assertEquals(sqwi.toQuery().toString(), "tokens:i:baum");
     };
 
+
     @Test
     public void queryJSONunderspecifiedTokenBug () {
-	// ((MORPH(APPR) ODER MORPH(APPRART)) /+w1 Urlaub
-	try {
-	    String json = getString(getClass().getResource("/queries/bugs/underspecified_token.jsonld").getFile());
-	    new KrillQuery("tokens").fromJson(json);
-	}
-	catch (QueryException e) {
-	    assertEquals(701, e.getErrorCode());
-	};
+        // ((MORPH(APPR) ODER MORPH(APPRART)) /+w1 Urlaub
+        try {
+            String json = getString(getClass().getResource(
+                    "/queries/bugs/underspecified_token.jsonld").getFile());
+            new KrillQuery("tokens").fromJson(json);
+        }
+        catch (QueryException e) {
+            assertEquals(701, e.getErrorCode());
+        };
     };
 
+
     @Test
     public void queryJSONspecialLayerBug () throws QueryException {
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/special_layer.jsonld").getFile());
-	assertEquals(sqwi.toQuery().toString(), "spanNext(spanNext(spanNext(tokens:s:Baum, tokens:cnx/p:CC), tokens:tt/l:Baum), <tokens:xip/c:MC />)");
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/special_layer.jsonld").getFile());
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanNext(spanNext(spanNext(tokens:s:Baum, tokens:cnx/p:CC), tokens:tt/l:Baum), <tokens:xip/c:MC />)");
     };
 
 
     @Test
     public void queryJSONrepetitionGroupRewriteBug () throws QueryException {
-	// ([cnx/p="A"][]){2}
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/repetition_group_rewrite.jsonld").getFile());
+        // ([cnx/p="A"][]){2}
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/repetition_group_rewrite.jsonld").getFile());
 
-	assertEquals(sqwi.toQuery().toString(), "spanRepetition(spanExpansion(SpanMultiTermQueryWrapper(tokens:/cnx/p:A/), []{1, 1}, right){2,2})");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanRepetition(spanExpansion(SpanMultiTermQueryWrapper(tokens:/cnx/p:A/), []{1, 1}, right){2,2})");
     };
 
+
     @Test
     public void queryJSONoverlapsFrameWorkaround () throws QueryException {
-	// overlaps(<s>,[tt/p=CARD][tt/p="N.*"])
-	SpanQueryWrapper sqwi = jsonQuery(getClass().getResource("/queries/bugs/overlaps_frame_workaround.jsonld").getFile());
+        // overlaps(<s>,[tt/p=CARD][tt/p="N.*"])
+        SpanQueryWrapper sqwi = jsonQuery(getClass().getResource(
+                "/queries/bugs/overlaps_frame_workaround.jsonld").getFile());
 
-	assertEquals(sqwi.toQuery().toString(), "spanOverlap(<tokens:s />, spanNext(tokens:tt/p:CARD, SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/)))");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanOverlap(<tokens:s />, spanNext(tokens:tt/p:CARD, SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/)))");
     };
 
 
     public static String getString (String path) {
-	StringBuilder contentBuilder = new StringBuilder();
-	try {
-	    BufferedReader in = new BufferedReader(new FileReader(path));
-	    String str;
-	    while ((str = in.readLine()) != null) {
-		contentBuilder.append(str);
-	    };
-	    in.close();
-	} catch (IOException e) {
-	    fail(e.getMessage());
-	}
-	return contentBuilder.toString();
+        StringBuilder contentBuilder = new StringBuilder();
+        try {
+            BufferedReader in = new BufferedReader(new FileReader(path));
+            String str;
+            while ((str = in.readLine()) != null) {
+                contentBuilder.append(str);
+            };
+            in.close();
+        }
+        catch (IOException e) {
+            fail(e.getMessage());
+        }
+        return contentBuilder.toString();
     };
 
+
     public static SpanQueryWrapper jsonQuery (String jsonFile) {
-	SpanQueryWrapper sqwi;
-	
-	try {
-	    String json = getString(jsonFile);
-	    sqwi = new KrillQuery("tokens").fromJson(json);
-	}
-	catch (QueryException e) {
-	    fail(e.getMessage());
-	    sqwi = new QueryBuilder("tokens").seg("???");
-	};
-	return sqwi;
+        SpanQueryWrapper sqwi;
+
+        try {
+            String json = getString(jsonFile);
+            sqwi = new KrillQuery("tokens").fromJson(json);
+        }
+        catch (QueryException e) {
+            fail(e.getMessage());
+            sqwi = new QueryBuilder("tokens").seg("???");
+        };
+        return sqwi;
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
index 9be1fcc..70b559e 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanAlterQuery.java
@@ -14,45 +14,56 @@
 import org.junit.runners.JUnit4;
 
 @RunWith(JUnit4.class)
-public class TestSpanAlterQuery  {
+public class TestSpanAlterQuery {
     @Test
     public void spanAlterQuery () throws QueryException {
 
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b");
-	assertEquals("field:b", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b");
+        assertEquals("field:b", ssaquery.toQuery().toString());
     };
 
+
     @Test
     public void spanAlterQuery2 () throws QueryException {
 
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b").or("c");
-	assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b").or("c");
+        assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery()
+                .toString());
     };
 
+
     @Test
     public void spanAlterQuery3 () throws QueryException {
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b").or("c").or("d");
-	assertEquals("spanOr([field:b, field:c, field:d])", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b").or("c").or("d");
+        assertEquals("spanOr([field:b, field:c, field:d])", ssaquery.toQuery()
+                .toString());
     };
 
 
     @Test
     public void spanAlterQuery4 () throws QueryException {
-	SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("d").or(segquery).or("e");
-	assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
+        SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field",
+                "a", "b", "c");
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("d").or(segquery).or("e");
+        assertEquals(
+                "spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])",
+                ssaquery.toQuery().toString());
     };
 
+
     @Test
     public void spanAlterQuery5 () throws QueryException {
-	SpanRegexQueryWrapper srequery = new SpanRegexQueryWrapper("field", "a[bc]d.?e");
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("f").or(srequery).or("g");
-	assertEquals("spanOr([field:f, SpanMultiTermQueryWrapper(field:/a[bc]d.?e/), field:g])", ssaquery.toQuery().toString());
+        SpanRegexQueryWrapper srequery = new SpanRegexQueryWrapper("field",
+                "a[bc]d.?e");
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("f").or(srequery).or("g");
+        assertEquals(
+                "spanOr([field:f, SpanMultiTermQueryWrapper(field:/a[bc]d.?e/), field:g])",
+                ssaquery.toQuery().toString());
     };
 
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanElementQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanElementQuery.java
index 8fab7b3..de50d78 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanElementQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanElementQuery.java
@@ -24,12 +24,14 @@
         assertEquals("<field:b />", sequery.toString());
     };
 
+
     @Test
     public void spanElement2Query () {
         SpanElementQuery sequery = new SpanElementQuery("field", "xyz");
         assertEquals("<field:xyz />", sequery.toString());
     };
 
+
     @Test
     public void spanElement3Query () {
         SpanElementQuery sequery = new SpanElementQuery("field", "");
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
index e0ea83a..9791fa4 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentAlterQuery.java
@@ -18,41 +18,52 @@
     @Test
     public void spanAlterQuery () throws QueryException {
 
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b");
-	assertEquals("field:b", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b");
+        assertEquals("field:b", ssaquery.toQuery().toString());
     };
 
+
     @Test
     public void spanAlterQuery2 () throws QueryException {
 
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b").or("c");
-	assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b").or("c");
+        assertEquals("spanOr([field:b, field:c])", ssaquery.toQuery()
+                .toString());
     };
 
+
     @Test
     public void spanAlterQuery3 () throws QueryException {
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("b").or("c").or("d");
-	assertEquals("spanOr([field:b, field:c, field:d])", ssaquery.toQuery().toString());
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("b").or("c").or("d");
+        assertEquals("spanOr([field:b, field:c, field:d])", ssaquery.toQuery()
+                .toString());
     };
 
 
     @Test
     public void spanAlterQuery4 () throws QueryException {
-	SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("d").or(segquery).or("e");
-	assertEquals("spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])", ssaquery.toQuery().toString());
+        SpanSegmentQueryWrapper segquery = new SpanSegmentQueryWrapper("field",
+                "a", "b", "c");
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("d").or(segquery).or("e");
+        assertEquals(
+                "spanOr([field:d, spanSegment(spanSegment(field:a, field:b), field:c), field:e])",
+                ssaquery.toQuery().toString());
     };
 
+
     @Test
     public void spanAlterQuery5 () throws QueryException {
-	SpanRegexQueryWrapper srequery = new SpanRegexQueryWrapper("field", "a[bc]d.?e");
-	SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
-	ssaquery.or("f").or(srequery).or("g");
-	assertEquals("spanOr([field:f, SpanMultiTermQueryWrapper(field:/a[bc]d.?e/), field:g])", ssaquery.toQuery().toString());
+        SpanRegexQueryWrapper srequery = new SpanRegexQueryWrapper("field",
+                "a[bc]d.?e");
+        SpanAlterQueryWrapper ssaquery = new SpanAlterQueryWrapper("field");
+        ssaquery.or("f").or(srequery).or("g");
+        assertEquals(
+                "spanOr([field:f, SpanMultiTermQueryWrapper(field:/a[bc]d.?e/), field:g])",
+                ssaquery.toQuery().toString());
     };
 
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
index 444a188..8c857a2 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentQuery.java
@@ -18,86 +18,114 @@
     @Test
     public void spanSegmentQuery () throws QueryException {
 
-	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field","a");
-	assertEquals("field:a", ssquery.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field",
+                "a");
+        assertEquals("field:a", ssquery.toQuery().toString());
 
-	ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
+        ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
+        assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery()
+                .toString());
 
-	ssquery = new SpanSegmentQueryWrapper("field","a", "b", "c");
-	assertEquals("spanSegment(spanSegment(field:a, field:b), field:c)", ssquery.toQuery().toString());
+        ssquery = new SpanSegmentQueryWrapper("field", "a", "b", "c");
+        assertEquals("spanSegment(spanSegment(field:a, field:b), field:c)",
+                ssquery.toQuery().toString());
     };
 
+
     @Test
     public void spanSegmentQueryExclusive () throws QueryException {
 
-	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field","a");
-	assertEquals("field:a", ssquery.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field",
+                "a");
+        assertEquals("field:a", ssquery.toQuery().toString());
 
-	ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
+        ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
+        assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery()
+                .toString());
 
-	ssquery.without("c");
-	assertEquals("spanNot(spanSegment(field:a, field:b), field:c, 0, 0)", ssquery.toQuery().toString());
+        ssquery.without("c");
+        assertEquals("spanNot(spanSegment(field:a, field:b), field:c, 0, 0)",
+                ssquery.toQuery().toString());
 
-	ssquery.without("d");
-	assertEquals("spanNot(spanSegment(field:a, field:b), spanOr([field:c, field:d]), 0, 0)", ssquery.toQuery().toString());
+        ssquery.without("d");
+        assertEquals(
+                "spanNot(spanSegment(field:a, field:b), spanOr([field:c, field:d]), 0, 0)",
+                ssquery.toQuery().toString());
     };
 
 
     @Test
     public void spanSegmentRegexQuery () throws QueryException {
-	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field");
-	assertNull(ssquery.toQuery());
-	ssquery.with("a");
-	assertEquals("field:a", ssquery.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field");
+        assertNull(ssquery.toQuery());
+        ssquery.with("a");
+        assertEquals("field:a", ssquery.toQuery().toString());
 
-	ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
+        ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
 
-	assertEquals("spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/))", ssquery.toQuery().toString());
+        assertEquals(
+                "spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/))",
+                ssquery.toQuery().toString());
 
-	ssquery.with("c");
+        ssquery.with("c");
 
-	assertEquals("spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c)", ssquery.toQuery().toString());
+        assertEquals(
+                "spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c)",
+                ssquery.toQuery().toString());
 
-	ssquery.with("d").with("e");
+        ssquery.with("d").with("e");
 
-	assertEquals("spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e)", ssquery.toQuery().toString());
+        assertEquals(
+                "spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e)",
+                ssquery.toQuery().toString());
 
-	ssquery.without(new SpanRegexQueryWrapper("field", "x.?y"));
+        ssquery.without(new SpanRegexQueryWrapper("field", "x.?y"));
 
-	assertEquals("spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), SpanMultiTermQueryWrapper(field:/x.?y/), 0, 0)", ssquery.toQuery().toString());
+        assertEquals(
+                "spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), SpanMultiTermQueryWrapper(field:/x.?y/), 0, 0)",
+                ssquery.toQuery().toString());
 
-	ssquery.without(new SpanRegexQueryWrapper("field", "z{5,9}"));
+        ssquery.without(new SpanRegexQueryWrapper("field", "z{5,9}"));
 
-	assertEquals("spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), spanOr([SpanMultiTermQueryWrapper(field:/x.?y/), SpanMultiTermQueryWrapper(field:/z{5,9}/)]), 0, 0)", ssquery.toQuery().toString());
+        assertEquals(
+                "spanNot(spanSegment(spanSegment(spanSegment(spanSegment(field:a, SpanMultiTermQueryWrapper(field:/a.*b/)), field:c), field:d), field:e), spanOr([SpanMultiTermQueryWrapper(field:/x.?y/), SpanMultiTermQueryWrapper(field:/z{5,9}/)]), 0, 0)",
+                ssquery.toQuery().toString());
 
     };
 
+
     @Test
     public void spanSegmentAlterQuery () throws QueryException {
-	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field");
-	assertNull(ssquery.toQuery());
+        SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field");
+        assertNull(ssquery.toQuery());
 
-	ssquery.with("a");
-	assertEquals("field:a", ssquery.toQuery().toString());
-	ssquery.with(new SpanAlterQueryWrapper("field", "c", "d"));
-	ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
+        ssquery.with("a");
+        assertEquals("field:a", ssquery.toQuery().toString());
+        ssquery.with(new SpanAlterQueryWrapper("field", "c", "d"));
+        ssquery.with(new SpanRegexQueryWrapper("field", "a.*b"));
 
-	assertEquals("spanSegment(spanSegment(field:a, spanOr([field:c, field:d])), SpanMultiTermQueryWrapper(field:/a.*b/))", ssquery.toQuery().toString());
+        assertEquals(
+                "spanSegment(spanSegment(field:a, spanOr([field:c, field:d])), SpanMultiTermQueryWrapper(field:/a.*b/))",
+                ssquery.toQuery().toString());
     };
 
 
     @Test
     public void spanSegmentCloneQuery () throws QueryException {
-	SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field", "a", "b");
-	assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery = new SpanSegmentQueryWrapper("field",
+                "a", "b");
+        assertEquals("spanSegment(field:a, field:b)", ssquery.toQuery()
+                .toString());
 
-	SpanSegmentQueryWrapper ssquery2 = new SpanSegmentQueryWrapper("field", ssquery);
-	assertEquals(ssquery.toQuery().toString(), ssquery2.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery2 = new SpanSegmentQueryWrapper("field",
+                ssquery);
+        assertEquals(ssquery.toQuery().toString(), ssquery2.toQuery()
+                .toString());
 
-	SpanSegmentQueryWrapper ssquery3 = ssquery2.clone();
-	assertEquals(ssquery.toQuery().toString(), ssquery3.toQuery().toString());
-	assertEquals(ssquery2.toQuery().toString(), ssquery3.toQuery().toString());
+        SpanSegmentQueryWrapper ssquery3 = ssquery2.clone();
+        assertEquals(ssquery.toQuery().toString(), ssquery3.toQuery()
+                .toString());
+        assertEquals(ssquery2.toQuery().toString(), ssquery3.toQuery()
+                .toString());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
index d93d402..94b3437 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSegmentSequenceQuery.java
@@ -19,66 +19,88 @@
 
     @Test
     public void spanSegmentSequenceQuery () throws QueryException {
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field");
 
-	assertNull(sssq.toQuery());
- 
-	sssq.append("a").append("b");
+        assertNull(sssq.toQuery());
 
-	assertEquals("spanNext(field:a, field:b)", sssq.toQuery().toString());
+        sssq.append("a").append("b");
 
-	sssq.append("c");
+        assertEquals("spanNext(field:a, field:b)", sssq.toQuery().toString());
 
-	assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq.toQuery().toString());
+        sssq.append("c");
+
+        assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq
+                .toQuery().toString());
     };
 
+
     @Test
     public void spanSegmentSequenceQuery2 () throws QueryException {
-	SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper("field", "-c", "-d", "-e");
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field", "a", "b");
+        SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper("field",
+                "-c", "-d", "-e");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field",
+                "a", "b");
 
-	sssq.append(ssq);
+        sssq.append(ssq);
 
-	assertEquals("spanNext(spanNext(field:a, field:b), spanSegment(spanSegment(field:-c, field:-d), field:-e))", sssq.toQuery().toString());
+        assertEquals(
+                "spanNext(spanNext(field:a, field:b), spanSegment(spanSegment(field:-c, field:-d), field:-e))",
+                sssq.toQuery().toString());
 
     };
 
+
     @Test
     public void spanSegmentSequenceQuery3 () throws QueryException {
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field", "a", "b");
-	SpanRegexQueryWrapper ssreq = new SpanRegexQueryWrapper("field", "c.?d");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field",
+                "a", "b");
+        SpanRegexQueryWrapper ssreq = new SpanRegexQueryWrapper("field", "c.?d");
 
-	sssq.append(ssreq);
+        sssq.append(ssreq);
 
-	assertEquals("spanNext(spanNext(field:a, field:b), SpanMultiTermQueryWrapper(field:/c.?d/))", sssq.toQuery().toString());
+        assertEquals(
+                "spanNext(spanNext(field:a, field:b), SpanMultiTermQueryWrapper(field:/c.?d/))",
+                sssq.toQuery().toString());
     };
 
+
     @Test
     public void spanSegmentSequenceQueryPrepend () throws QueryException {
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field", "b", "c");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field",
+                "b", "c");
 
-	sssq.prepend("a");
+        sssq.prepend("a");
 
-	assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq.toQuery().toString());
+        assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq
+                .toQuery().toString());
     };
 
+
     @Test
     public void spanSegmentSequenceQueryPrepend2 () throws QueryException {
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field", "d", "e");
-	SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper("field", "-a", "-b", "-c");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field",
+                "d", "e");
+        SpanSegmentQueryWrapper ssq = new SpanSegmentQueryWrapper("field",
+                "-a", "-b", "-c");
 
-	sssq.prepend(ssq);
+        sssq.prepend(ssq);
 
-	assertEquals("spanNext(spanNext(spanSegment(spanSegment(field:-a, field:-b), field:-c), field:d), field:e)", sssq.toQuery().toString());
+        assertEquals(
+                "spanNext(spanNext(spanSegment(spanSegment(field:-a, field:-b), field:-c), field:d), field:e)",
+                sssq.toQuery().toString());
     };
 
+
     @Test
     public void spanSegmentSequenceQueryPrepend3 () throws QueryException {
-	SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field", "c", "d");
-	SpanRegexQueryWrapper ssreq = new SpanRegexQueryWrapper("field", "a.?b");
+        SpanSequenceQueryWrapper sssq = new SpanSequenceQueryWrapper("field",
+                "c", "d");
+        SpanRegexQueryWrapper ssreq = new SpanRegexQueryWrapper("field", "a.?b");
 
-	sssq.prepend(ssreq);
+        sssq.prepend(ssreq);
 
-	assertEquals("spanNext(spanNext(SpanMultiTermQueryWrapper(field:/a.?b/), field:c), field:d)", sssq.toQuery().toString());
+        assertEquals(
+                "spanNext(spanNext(SpanMultiTermQueryWrapper(field:/a.?b/), field:c), field:d)",
+                sssq.toQuery().toString());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQuery.java
index 8772dfb..1c6deaf 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQuery.java
@@ -32,7 +32,8 @@
         assertFalse(sssq.hasConstraints());
 
         sssq.append("c");
-        assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq.toQuery().toString());
+        assertEquals("spanNext(spanNext(field:a, field:b), field:c)", sssq
+                .toQuery().toString());
         assertFalse(sssq.hasConstraints());
 
         sssq = new SpanSequenceQueryWrapper("field");
@@ -44,19 +45,26 @@
         assertEquals("spanNext(field:a, field:b)", sssq.toQuery().toString());
         assertFalse(sssq.hasConstraints());
 
-        sssq.withConstraint(2,3);
+        sssq.withConstraint(2, 3);
         assertTrue(sssq.hasConstraints());
 
-        assertEquals("spanDistance(field:a, field:b, [(w[2:3], ordered, notExcluded)])", sssq.toQuery().toString());
+        assertEquals(
+                "spanDistance(field:a, field:b, [(w[2:3], ordered, notExcluded)])",
+                sssq.toQuery().toString());
 
         sssq.append("c");
-        assertEquals("spanDistance(spanDistance(field:a, field:b, [(w[2:3], ordered, notExcluded)]), field:c, [(w[2:3], ordered, notExcluded)])", sssq.toQuery().toString());
-        sssq.withConstraint(6,8, "s");
+        assertEquals(
+                "spanDistance(spanDistance(field:a, field:b, [(w[2:3], ordered, notExcluded)]), field:c, [(w[2:3], ordered, notExcluded)])",
+                sssq.toQuery().toString());
+        sssq.withConstraint(6, 8, "s");
         assertTrue(sssq.hasConstraints());
 
-        assertEquals("spanMultipleDistance(spanMultipleDistance(field:a, field:b, [(w[2:3], ordered, notExcluded), (s[6:8], ordered, notExcluded)]), field:c, [(w[2:3], ordered, notExcluded), (s[6:8], ordered, notExcluded)])", sssq.toQuery().toString());
+        assertEquals(
+                "spanMultipleDistance(spanMultipleDistance(field:a, field:b, [(w[2:3], ordered, notExcluded), (s[6:8], ordered, notExcluded)]), field:c, [(w[2:3], ordered, notExcluded), (s[6:8], ordered, notExcluded)])",
+                sssq.toQuery().toString());
     };
 
+
     @Ignore
     public void spanSequenceQueryWrapper () throws QueryException {
 
@@ -65,14 +73,15 @@
         SpanClassQueryWrapper scqw;
 
         // Synopsis 1
-        ssqw =
-            new SpanSequenceQueryWrapper("tokens", "der", "Baum");
-        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery().toString());
+        ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum");
+        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery()
+                .toString());
 
         // Synopsis 2
         ssqw = new SpanSequenceQueryWrapper("tokens");
         ssqw.append("der").append("Baum");
-        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery().toString());
+        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery()
+                .toString());
 
         // Append a sequence
         ssqw = new SpanSequenceQueryWrapper("tokens");
@@ -82,14 +91,14 @@
         ssqw.append(ssqw2);
         // This may not be final
         assertEquals(
-            "spanNext(spanNext(spanNext(tokens:der, tokens:Baum), tokens:fiel), tokens:still)",
-            ssqw.toQuery().toString()
-        );
+                "spanNext(spanNext(spanNext(tokens:der, tokens:Baum), tokens:fiel), tokens:still)",
+                ssqw.toQuery().toString());
 
         // Synopsis 3
         ssqw = new SpanSequenceQueryWrapper("tokens", "Baum");
         ssqw.prepend("der");
-        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery().toString());
+        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery()
+                .toString());
 
         // Prepend a sequence
         ssqw = new SpanSequenceQueryWrapper("tokens");
@@ -100,44 +109,41 @@
 
         // This may change
         assertEquals(
-            "spanNext(spanNext(spanNext(tokens:der, tokens:Baum), tokens:fiel), tokens:still)",
-            ssqw.toQuery().toString()
-        );
+                "spanNext(spanNext(spanNext(tokens:der, tokens:Baum), tokens:fiel), tokens:still)",
+                ssqw.toQuery().toString());
 
         // Add constraint
-        ssqw.withConstraint(2,4);
+        ssqw.withConstraint(2, 4);
         // This may change
-        assertEquals(
-            "spanDistance(spanDistance(spanDistance(tokens:der, "+
-            "tokens:Baum, [(w[2:4], ordered, notExcluded)]), "+
-            "tokens:fiel, [(w[2:4], ordered, notExcluded)]), "+
-            "tokens:still, [(w[2:4], ordered, notExcluded)])",
-            ssqw.toQuery().toString()
-        );
-
-        ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum").withConstraint(1,1);
-        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery().toString());
-
-        ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum").withConstraint(1,2, "s");
-        assertEquals("spanElementDistance(tokens:der, tokens:Baum, [(s[1:2], ordered, notExcluded)])", ssqw.toQuery().toString());
+        assertEquals("spanDistance(spanDistance(spanDistance(tokens:der, "
+                + "tokens:Baum, [(w[2:4], ordered, notExcluded)]), "
+                + "tokens:fiel, [(w[2:4], ordered, notExcluded)]), "
+                + "tokens:still, [(w[2:4], ordered, notExcluded)])", ssqw
+                .toQuery().toString());
 
         ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum")
-            .withConstraint(1,2, "s")
-            .withConstraint(2,3, "x");
-        assertEquals("spanMultipleDistance(tokens:der, tokens:Baum, " +
-                     "[(s[1:2], ordered, notExcluded), " +
-                     "(x[2:3], ordered, notExcluded)])",
-                     ssqw.toQuery().toString());
+                .withConstraint(1, 1);
+        assertEquals("spanNext(tokens:der, tokens:Baum)", ssqw.toQuery()
+                .toString());
 
-        ssqw = new SpanSequenceQueryWrapper("tokens")
-            .append("Baum")
-            .prepend("der")
-            .withConstraint(1,2, "s", true)
-            .withConstraint(2,3, "x");
-        assertEquals("spanMultipleDistance(tokens:der, " +
-                     "tokens:Baum, [(s[1:2], ordered, excluded), " +
-                     "(x[2:3], ordered, notExcluded)])",
-                     ssqw.toQuery().toString());
+        ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum")
+                .withConstraint(1, 2, "s");
+        assertEquals(
+                "spanElementDistance(tokens:der, tokens:Baum, [(s[1:2], ordered, notExcluded)])",
+                ssqw.toQuery().toString());
+
+        ssqw = new SpanSequenceQueryWrapper("tokens", "der", "Baum")
+                .withConstraint(1, 2, "s").withConstraint(2, 3, "x");
+        assertEquals("spanMultipleDistance(tokens:der, tokens:Baum, "
+                + "[(s[1:2], ordered, notExcluded), "
+                + "(x[2:3], ordered, notExcluded)])", ssqw.toQuery().toString());
+
+        ssqw = new SpanSequenceQueryWrapper("tokens").append("Baum")
+                .prepend("der").withConstraint(1, 2, "s", true)
+                .withConstraint(2, 3, "x");
+        assertEquals("spanMultipleDistance(tokens:der, "
+                + "tokens:Baum, [(s[1:2], ordered, excluded), "
+                + "(x[2:3], ordered, notExcluded)])", ssqw.toQuery().toString());
 
 
         // Support empty class ins sequence 
@@ -145,10 +151,8 @@
         srqw = new SpanRepetitionQueryWrapper();
         scqw = new SpanClassQueryWrapper(srqw, (short) 3);
         ssqw.append(scqw);
-        assertEquals(
-            "spanExpansion(field:Der, []{1, 1}, right, class:3)",
-            ssqw.toQuery().toString()
-        );
+        assertEquals("spanExpansion(field:Der, []{1, 1}, right, class:3)", ssqw
+                .toQuery().toString());
 
         // Support empty class ins sequence 
         ssqw = new SpanSequenceQueryWrapper("field");
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
index 8545881..d95ccfc 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSequenceQueryJSON.java
@@ -22,6 +22,7 @@
 
     static String path = "/queries/sequence/";
 
+
     // Test Extensions
 
     @Test
@@ -32,47 +33,60 @@
         assertTrue(sqwi.isEmpty());
     };
 
+
     @Test
     public void queryJSONseqEmptyEnd () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-last.jsonld");
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:s:der, []{1, 1}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:s:der, []{1, 1}, right)");
     };
 
+
     @Test
     public void queryJSONseqEmptyEndClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-last-class.jsonld");
         // der{3:[]}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:s:der, []{1, 1}, right, class:3)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:s:der, []{1, 1}, right, class:3)");
     };
 
+
     @Test
     public void queryJSONseqEmptyEndRepetition () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-last-repetition.jsonld");
         // der[]{3,5}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:s:der, []{3, 5}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:s:der, []{3, 5}, right)");
     };
 
+
     @Test
     public void queryJSONseqEmptyStart () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-first.jsonld");
         // [][tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, []{1, 1}, left)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, []{1, 1}, left)");
     };
 
+
     @Test
     public void queryJSONseqEmptyStartClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-first-class.jsonld");
         // {2:[]}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:2)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:2)");
     };
 
+
     @Test
     public void queryJSONseqEmptyStartRepetition () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-first-repetition.jsonld");
         // []{2,7}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, []{2, 7}, left)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, []{2, 7}, left)");
     };
 
+
     @Test
     public void queryJSONseqEmptyStartRepetition2 () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-first-repetition-2.jsonld");
@@ -80,71 +94,95 @@
         assertEquals(sqwi.toQuery().toString(), "tokens:tt/p:NN");
     };
 
+
     @Test
     public void queryJSONseqEmptyMiddle () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-middle.jsonld");
         // der[][tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{1, 1}, left))");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{1, 1}, left))");
     };
 
+
     @Test
     public void queryJSONseqEmptyMiddleClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-middle-class.jsonld");
         // der{1:[]}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:1))");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:1))");
     };
 
+
     @Test
     public void queryJSONseqEmptyMiddleRepetition () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-middle-repetition.jsonld");
         // der[]{4,8}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{4, 8}, left))");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanNext(tokens:s:der, spanExpansion(tokens:tt/p:NN, []{4, 8}, left))");
     };
 
+
     @Test
     public void queryJSONseqEmptySurround () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround.jsonld");
         // [][tt/p=NN][]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right)");
     };
 
+
     @Test
     public void queryJSONseqEmptySurroundClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround-class.jsonld");
         // [][tt/p=NN]{2:[]}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right, class:2)");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{1, 1}, right, class:2)");
     };
 
+
     @Test
     public void queryJSONseqEmptySurroundClass2 () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround-class-2.jsonld");
         // {3:[]}[tt/p=NN]{2:[]}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:3), []{1, 1}, right, class:2)");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left, class:3), []{1, 1}, right, class:2)");
     };
 
+
     @Test
     public void queryJSONseqEmptySurroundRepetition () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround-repetition.jsonld");
         // [][tt/p=NN][]{2,7}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{2, 7}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{1, 1}, left), []{2, 7}, right)");
     };
 
+
     @Test
     public void queryJSONseqEmptySurroundRepetition2 () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround-repetition-2.jsonld");
         // []{3,5}[tt/p=NN][]{2,7}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 5}, left), []{2, 7}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 5}, left), []{2, 7}, right)");
     };
 
+
     @Test
-    public void queryJSONseqEmptySurroundRepetitionClass () throws QueryException {
+    public void queryJSONseqEmptySurroundRepetitionClass ()
+            throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("empty-surround-repetition-class.jsonld");
         // {1:[]}{3,8}[tt/p=NN]{2:[]{2,7}}
         // Ist gleichbedeutend mit
         // {1:[]{3,8}}[tt/p=NN]{2:[]}{2,7}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 8}, left, class:1), []{2, 7}, right, class:2)");
+        assertEquals(
+                sqwi.toQuery().toString(),
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, []{3, 8}, left, class:1), []{2, 7}, right, class:2)");
     };
 
+
     @Test
     public void queryJSONseqNegative () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative.jsonld");
@@ -152,34 +190,43 @@
         assertTrue(sqwi.isNegative());
     };
 
+
     @Test
     public void queryJSONseqNegativeStart () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-first.jsonld");
         // [tt/p!=NN][tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, left)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, left)");
     };
 
+
     @Test
     public void queryJSONseqNegativeEnd () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last.jsonld");
         // [tt/p=NN][tt/p!=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right)");
     };
 
+
     @Test
     public void queryJSONseqNegativeStartRepetition () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-first-repetition.jsonld");
         // [tt/p!=NN]{4,5}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, left)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, left)");
     };
 
+
     @Test
     public void queryJSONseqNegativeStartRepetition2 () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-first-repetition-2.jsonld");
         // [tt/p!=NN]{0,5}[tt/p=NN]
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{0, 5}, left)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{0, 5}, left)");
     };
 
+
     @Test
     public void queryJSONseqNegativeStartRepetition3 () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-first-repetition-3.jsonld");
@@ -187,28 +234,36 @@
         assertEquals(sqwi.toQuery().toString(), "tokens:tt/p:NN");
     };
 
+
     @Test
     public void queryJSONseqNegativeEndClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last-class.jsonld");
         // [tt/p=NN]{2:[tt/p!=NN]}
         SpanQuery sq = sqwi.toQuery();
-        assertEquals(sq.toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right, class:2)");
+        assertEquals(sq.toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{1, 1}, right, class:2)");
     };
 
+
     @Test
     public void queryJSONseqNegativeEndRepetitionClass () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last-class-repetition.jsonld");
         // [tt/p=NN]{2:[tt/p!=NN]{4,5}}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
     };
 
+
     @Test
-    public void queryJSONseqNegativeEndRepetitionClass2 () throws QueryException {
+    public void queryJSONseqNegativeEndRepetitionClass2 ()
+            throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last-class-repetition-2.jsonld");
         // [tt/p=NN]{2:[tt/p!=NN]}{4,5}
-        assertEquals(sqwi.toQuery().toString(), "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
+        assertEquals(sqwi.toQuery().toString(),
+                "spanExpansion(tokens:tt/p:NN, !tokens:tt/p:NN{4, 5}, right, class:2)");
     };
 
+
     @Test
     public void queryJSONseqNegativelastConstraint () {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last-constraint.jsonld");
@@ -217,15 +272,20 @@
             fail("Should throw an exception");
         }
         catch (QueryException qe) {
-            assertEquals("Distance constraints not supported with empty or negative operands", qe.getMessage());
+            assertEquals(
+                    "Distance constraints not supported with empty or negative operands",
+                    qe.getMessage());
         };
     };
 
+
     @Test
     public void queryJSONseqNegativeEndSequence () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("negative-last-sequence.jsonld");
         // [tt/p=NN]([tt/p!=DET][tt/p!=NN])
-        assertEquals("spanExpansion(spanExpansion(tokens:tt/p:NN, !tokens:tt/p:DET{1, 1}, right), !tokens:tt/p:ADJ{1, 1}, right)", sqwi.toQuery().toString());
+        assertEquals(
+                "spanExpansion(spanExpansion(tokens:tt/p:NN, !tokens:tt/p:DET{1, 1}, right), !tokens:tt/p:ADJ{1, 1}, right)",
+                sqwi.toQuery().toString());
     };
 
 
@@ -235,15 +295,20 @@
         // [tt/p!=NN]([tt/p!=DET][tt/p=NN])
 
         // spanNext(tokens:tt/p:NN, 
-        assertEquals("spanExpansion(spanExpansion(tokens:tt/p:ADJ, !tokens:tt/p:DET{1, 1}, left), !tokens:tt/p:NN{1, 1}, left)", sqwi.toQuery().toString());
+        assertEquals(
+                "spanExpansion(spanExpansion(tokens:tt/p:ADJ, !tokens:tt/p:DET{1, 1}, left), !tokens:tt/p:NN{1, 1}, left)",
+                sqwi.toQuery().toString());
     };
 
+
     @Test
     public void queryJSONseqMultipleDistances () throws QueryException {
         SpanQueryWrapper sqwi = jsonQueryFile("multiple-distances.jsonld");
         // er []{,10} kann []{1,10} sagte 
 
-        assertEquals("spanDistance(tokens:s:er, spanDistance(tokens:s:kann, tokens:s:sagte, [(w[2:11], ordered, notExcluded)]), [(w[1:11], ordered, notExcluded)])", sqwi.toQuery().toString());
+        assertEquals(
+                "spanDistance(tokens:s:er, spanDistance(tokens:s:kann, tokens:s:sagte, [(w[2:11], ordered, notExcluded)]), [(w[1:11], ordered, notExcluded)])",
+                sqwi.toQuery().toString());
     };
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
index 5c5ea26..df85409 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanSubspanQueryJSON.java
@@ -13,223 +13,239 @@
  * @author margaretha, diewald
  */
 public class TestSpanSubspanQueryJSON {
-	
-	@Test
-	public void testTermQuery() throws QueryException {
-		// subspan(tokens:tt/l:Haus, 0, 1)
-		String filepath = getClass().getResource(
-				"/queries/submatch/termquery.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("tokens:tt/l:Haus", sq.toString());
-	}
 
-	@Test
-	public void testTermStartOffset() throws QueryException {
-		// subspan(tokens:tt/l:Haus, -1, 0)
-		String filepath = getClass().getResource(
-				"/queries/submatch/term-start-offset.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("tokens:tt/l:Haus", sq.toString());
-	}
-
-	@Test
-	public void testTermNull() throws QueryException {
-		// subspan(tokens:tt/l:Haus, 1, 1)
-		String filepath = getClass().getResource(
-				"/queries/submatch/term-null.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(null, sq);
-	}
-
-	@Test
-	public void testElementQuery() throws QueryException {
-		// submatch(1,4:<s>)
-		String filepath = getClass().getResource(
-				"/queries/submatch/simpleElement.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan(spanContain(<tokens:s />, tokens:tt/l:Haus), 1, 4)",
-				sq.toString());
-	}
-
-	@Test
-	public void testNoLength() throws QueryException {
-		// submatch(1,:<s>)
-		String filepath = getClass().getResource(
-				"/queries/submatch/noLength.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("subspan(<tokens:s />, 1, 0)", sq.toString());
-	}
-	
-	@Test
-	public void testMinusStartOffset() throws QueryException {
-		// submatch(-1,4:<s>)
-		String filepath = getClass().getResource("/queries/submatch/minusStart.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("subspan(<tokens:s />, -1, 4)", sq.toString());
-	}
-
-	@Test
-	public void testEmptyMinusStartOffset() throws QueryException {
-		// no optimization
-		// submatch(-1,4:der []{1,8})
-		String filepath = getClass().getResource(
-				"/queries/submatch/empty-minusStart.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan(spanExpansion(tokens:s:der, []{1, 8}, right), -1, 4)",
-				sq.toString());
-	}
-
-	@Test
-	public void testEmptyMax() throws QueryException {
-		// no optimization
-		// submatch(1,2:der []{1,8})
-		String filepath = getClass().getResource(
-				"/queries/submatch/empty-max.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan(spanExpansion(tokens:s:der, []{1, 8}, right), 1, 2)",
-				sq.toString());
-	}
-
-	@Test
-	public void testCaseEmptyWrapped() throws QueryException {
-		String filepath = getClass().getResource(
-				"/queries/submatch/wrapped.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"focus(129: spanElementDistance({129: tokens:s:der}, {129: subspan"
-						+ "(<tokens:s />, 0, 1)}, [(s[0:0], ordered, notExcluded)]))",
-				sq.toString());
-	}
-
-	@Test
-	public void testCaseEmptyEmbedded() throws QueryException {
-		// die subspan(der []{1,}, 2,3)
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("spanNext({1: tokens:s:die}, {1: subspan(spanExpansion("
-				+ "tokens:s:der, []{1, 100}, right), 2, 3)})", sq.toString());
-	}
-
-	@Test
-	public void testCaseEmptyEmbeddedNull() throws QueryException {
-		// die subspan([],5,6)
-		// start offset is bigger than the original span
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded-null.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("tokens:s:die", sq.toString());
-	}
-
-	@Test
-	public void testCaseEmptyEmbeddedValid() throws QueryException {
-		// die subspan([]{0,5},2)
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded-valid-empty.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("spanExpansion(tokens:s:die, []{2, 5}, right)",
-				sq.toString());
-	}
-
-	@Test
-	public void testNegativeToken() throws QueryException {
-		// submatch(0,1:[base != Baum])
-		String filepath = getClass().getResource(
-				"/queries/submatch/negative-token.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals("tokens:l:Baum", sq.toString());
-	}
-
-	@Test
-	public void testNegativeSequence() throws QueryException {
-		// das submatch(0,1:[base != Baum])
-		String filepath = getClass().getResource(
-				"/queries/submatch/negative-seq.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right)",
-				sq.toString());
-	}
-
-	@Test
-	public void testNegativeSequenceWithClass() throws QueryException {
-		// das {1:submatch(0,1:[base != Baum])}
-		String filepath = getClass().getResource(
-				"/queries/submatch/negative-sequence-class.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right, class:1)",
-				sq.toString());
-	}
-
-	@Test
-	public void testNegativeEmbeddedSequence() throws QueryException {
-		// submatch(1,1:das [base != Baum])
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded-negative-seq.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan(spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right), 1, 1)",
-				sq.toString());
-	}
-
-	@Test
-	public void testNegativeEmbeddedSequenceWithClass() throws QueryException {
-		// submatch(0,1:{1:[base != Baum] dass})
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded-negative-class-seq.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan({1: spanExpansion(tokens:s:dass, !tokens:l:Baum{1, 1}, left)}, 0, 1)",
-				sq.toString());
-	}
+    @Test
+    public void testTermQuery () throws QueryException {
+        // subspan(tokens:tt/l:Haus, 0, 1)
+        String filepath = getClass().getResource(
+                "/queries/submatch/termquery.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("tokens:tt/l:Haus", sq.toString());
+    }
 
 
-	@Test
-	public void testEmbeddedNegativeRepetition() throws QueryException {
-		// submatch(1,1:das [base != Baum]{1,3})
-		String filepath = getClass().getResource(
-				"/queries/submatch/embedded-negative-repetition.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"subspan(spanExpansion(tokens:s:das, !tokens:l:Baum{1, 3}, right), 1, 1)",
-				sq.toString());
-	}
+    @Test
+    public void testTermStartOffset () throws QueryException {
+        // subspan(tokens:tt/l:Haus, -1, 0)
+        String filepath = getClass().getResource(
+                "/queries/submatch/term-start-offset.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("tokens:tt/l:Haus", sq.toString());
+    }
 
-	@Test
-	public void testNegativeRepetition() throws QueryException {
-		// das submatch(1,4:[base != Baum]{1,3})
-		String filepath = getClass().getResource(
-				"/queries/submatch/negative-repetition.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanExpansion(tokens:s:das, !tokens:l:Baum{2, 2}, right)",
-				sq.toString());
-	}
+
+    @Test
+    public void testTermNull () throws QueryException {
+        // subspan(tokens:tt/l:Haus, 1, 1)
+        String filepath = getClass().getResource(
+                "/queries/submatch/term-null.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(null, sq);
+    }
+
+
+    @Test
+    public void testElementQuery () throws QueryException {
+        // submatch(1,4:<s>)
+        String filepath = getClass().getResource(
+                "/queries/submatch/simpleElement.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan(spanContain(<tokens:s />, tokens:tt/l:Haus), 1, 4)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNoLength () throws QueryException {
+        // submatch(1,:<s>)
+        String filepath = getClass().getResource(
+                "/queries/submatch/noLength.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("subspan(<tokens:s />, 1, 0)", sq.toString());
+    }
+
+
+    @Test
+    public void testMinusStartOffset () throws QueryException {
+        // submatch(-1,4:<s>)
+        String filepath = getClass().getResource(
+                "/queries/submatch/minusStart.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("subspan(<tokens:s />, -1, 4)", sq.toString());
+    }
+
+
+    @Test
+    public void testEmptyMinusStartOffset () throws QueryException {
+        // no optimization
+        // submatch(-1,4:der []{1,8})
+        String filepath = getClass().getResource(
+                "/queries/submatch/empty-minusStart.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan(spanExpansion(tokens:s:der, []{1, 8}, right), -1, 4)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testEmptyMax () throws QueryException {
+        // no optimization
+        // submatch(1,2:der []{1,8})
+        String filepath = getClass().getResource(
+                "/queries/submatch/empty-max.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan(spanExpansion(tokens:s:der, []{1, 8}, right), 1, 2)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testCaseEmptyWrapped () throws QueryException {
+        String filepath = getClass().getResource(
+                "/queries/submatch/wrapped.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "focus(129: spanElementDistance({129: tokens:s:der}, {129: subspan"
+                        + "(<tokens:s />, 0, 1)}, [(s[0:0], ordered, notExcluded)]))",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testCaseEmptyEmbedded () throws QueryException {
+        // die subspan(der []{1,}, 2,3)
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("spanNext({1: tokens:s:die}, {1: subspan(spanExpansion("
+                + "tokens:s:der, []{1, 100}, right), 2, 3)})", sq.toString());
+    }
+
+
+    @Test
+    public void testCaseEmptyEmbeddedNull () throws QueryException {
+        // die subspan([],5,6)
+        // start offset is bigger than the original span
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded-null.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("tokens:s:die", sq.toString());
+    }
+
+
+    @Test
+    public void testCaseEmptyEmbeddedValid () throws QueryException {
+        // die subspan([]{0,5},2)
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded-valid-empty.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("spanExpansion(tokens:s:die, []{2, 5}, right)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeToken () throws QueryException {
+        // submatch(0,1:[base != Baum])
+        String filepath = getClass().getResource(
+                "/queries/submatch/negative-token.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("tokens:l:Baum", sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeSequence () throws QueryException {
+        // das submatch(0,1:[base != Baum])
+        String filepath = getClass().getResource(
+                "/queries/submatch/negative-seq.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeSequenceWithClass () throws QueryException {
+        // das {1:submatch(0,1:[base != Baum])}
+        String filepath = getClass().getResource(
+                "/queries/submatch/negative-sequence-class.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right, class:1)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeEmbeddedSequence () throws QueryException {
+        // submatch(1,1:das [base != Baum])
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded-negative-seq.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan(spanExpansion(tokens:s:das, !tokens:l:Baum{1, 1}, right), 1, 1)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeEmbeddedSequenceWithClass () throws QueryException {
+        // submatch(0,1:{1:[base != Baum] dass})
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded-negative-class-seq.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan({1: spanExpansion(tokens:s:dass, !tokens:l:Baum{1, 1}, left)}, 0, 1)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testEmbeddedNegativeRepetition () throws QueryException {
+        // submatch(1,1:das [base != Baum]{1,3})
+        String filepath = getClass().getResource(
+                "/queries/submatch/embedded-negative-repetition.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "subspan(spanExpansion(tokens:s:das, !tokens:l:Baum{1, 3}, right), 1, 1)",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testNegativeRepetition () throws QueryException {
+        // das submatch(1,4:[base != Baum]{1,3})
+        String filepath = getClass().getResource(
+                "/queries/submatch/negative-repetition.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanExpansion(tokens:s:das, !tokens:l:Baum{2, 2}, right)",
+                sq.toString());
+    }
 }
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
index be9c46f..7e146ad 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithAttributeJSON.java
@@ -11,102 +11,111 @@
 
 public class TestSpanWithAttributeJSON {
 
-	@Test
-	public void testElementSingleAttribute() throws QueryException {
-		String filepath = getClass().getResource(
-				"/queries/attribute/element-single-attribute.jsonld").getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanElementWithAttribute(<tokens:head />, spanAttribute(tokens:type:top))",
-				sq.toString());
-	}
+    @Test
+    public void testElementSingleAttribute () throws QueryException {
+        String filepath = getClass().getResource(
+                "/queries/attribute/element-single-attribute.jsonld").getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanElementWithAttribute(<tokens:head />, spanAttribute(tokens:type:top))",
+                sq.toString());
+    }
 
-	@Test
-	public void testElementSingleNotAttribute() throws QueryException {
-		String filepath = getClass().getResource(
-				"/queries/attribute/element-single-not-attribute.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanElementWithAttribute(<tokens:head />, spanAttribute(!tokens:type:top))",
-				sq.toString());
-	}
 
-	@Test
-	public void testElementMultipleAndNotAttributes() throws QueryException {
-		String filepath = getClass().getResource(
-						"/queries/attribute/element-multiple-and-not-attributes.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanElementWithAttribute(<tokens:div />, [spanAttribute(tokens:type:Zeitschrift), "
-						+ "spanAttribute(!tokens:complete:Y), spanAttribute(tokens:n:0)])",
-				sq.toString());
-	}
+    @Test
+    public void testElementSingleNotAttribute () throws QueryException {
+        String filepath = getClass().getResource(
+                "/queries/attribute/element-single-not-attribute.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanElementWithAttribute(<tokens:head />, spanAttribute(!tokens:type:top))",
+                sq.toString());
+    }
 
-	@Test
-	public void testElementMultipleOrAttributes() throws QueryException {
-		String filepath = getClass().getResource(
-				"/queries/attribute/element-multiple-or-attributes.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanOr([spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:type:Zeitschrift)), "
-						+ "spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:complete:Y)), "
-						+ "spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:n:0))])",
-				sq.toString());
-	}
 
-	@Test
-	public void testAnyElementWithAttribute() throws QueryException {
-		String filepath = getClass().getResource(
-				"/queries/attribute/any-element-with-attribute.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanWithAttribute(spanAttribute(tokens:type:top))",
-				sq.toString());
-	}
+    @Test
+    public void testElementMultipleAndNotAttributes () throws QueryException {
+        String filepath = getClass()
+                .getResource(
+                        "/queries/attribute/element-multiple-and-not-attributes.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanElementWithAttribute(<tokens:div />, [spanAttribute(tokens:type:Zeitschrift), "
+                        + "spanAttribute(!tokens:complete:Y), spanAttribute(tokens:n:0)])",
+                sq.toString());
+    }
 
-	@Test
-	public void testAnyElementWithMultipleOrAttributes() throws QueryException {
-		String filepath = getClass().getResource(
-						"/queries/attribute/any-element-with-multiple-or-attributes.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanOr([spanWithAttribute(spanAttribute(tokens:type:Zeitschrift)), "
-						+ "spanWithAttribute(spanAttribute(tokens:complete:Y)), "
-						+ "spanWithAttribute(spanAttribute(tokens:n:0))])",
-				sq.toString());
-	}
 
-	@Test
-	public void testAnyElementMultipleAndNotAttributes() throws QueryException {
-		String filepath = getClass()
-				.getResource(
-						"/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-		SpanQuery sq = sqwi.toQuery();
-		assertEquals(
-				"spanWithAttribute([spanAttribute(tokens:type:Zeitschrift), "
-						+ "spanAttribute(!tokens:complete:Y), spanAttribute(tokens:n:0)])",
-				sq.toString());
-	}
+    @Test
+    public void testElementMultipleOrAttributes () throws QueryException {
+        String filepath = getClass().getResource(
+                "/queries/attribute/element-multiple-or-attributes.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanOr([spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:type:Zeitschrift)), "
+                        + "spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:complete:Y)), "
+                        + "spanElementWithAttribute(<tokens:div />, spanAttribute(tokens:n:0))])",
+                sq.toString());
+    }
 
-	@Test(expected = AssertionError.class)
-	public void testAnyElementSingleNotAttribute() throws QueryException {
-		String filepath = getClass().getResource(
-						"/queries/attribute/any-element-with-single-not-attribute.jsonld")
-				.getFile();
-		SpanQueryWrapper sqwi = getJSONQuery(filepath);
-	}
+
+    @Test
+    public void testAnyElementWithAttribute () throws QueryException {
+        String filepath = getClass().getResource(
+                "/queries/attribute/any-element-with-attribute.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals("spanWithAttribute(spanAttribute(tokens:type:top))",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testAnyElementWithMultipleOrAttributes () throws QueryException {
+        String filepath = getClass()
+                .getResource(
+                        "/queries/attribute/any-element-with-multiple-or-attributes.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanOr([spanWithAttribute(spanAttribute(tokens:type:Zeitschrift)), "
+                        + "spanWithAttribute(spanAttribute(tokens:complete:Y)), "
+                        + "spanWithAttribute(spanAttribute(tokens:n:0))])",
+                sq.toString());
+    }
+
+
+    @Test
+    public void testAnyElementMultipleAndNotAttributes () throws QueryException {
+        String filepath = getClass()
+                .getResource(
+                        "/queries/attribute/any-element-with-multiple-and-not-attributes.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+        SpanQuery sq = sqwi.toQuery();
+        assertEquals(
+                "spanWithAttribute([spanAttribute(tokens:type:Zeitschrift), "
+                        + "spanAttribute(!tokens:complete:Y), spanAttribute(tokens:n:0)])",
+                sq.toString());
+    }
+
+
+    @Test(expected = AssertionError.class)
+    public void testAnyElementSingleNotAttribute () throws QueryException {
+        String filepath = getClass()
+                .getResource(
+                        "/queries/attribute/any-element-with-single-not-attribute.jsonld")
+                .getFile();
+        SpanQueryWrapper sqwi = getJSONQuery(filepath);
+    }
 
 }
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
index c81fc79..858dbf1 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestSpanWithinQuery.java
@@ -17,15 +17,19 @@
     @Test
     public void spanSegmentWithinQuery () throws QueryException {
 
-	SpanSequenceQueryWrapper ssquery = new SpanSequenceQueryWrapper("field", "a", "b", "c");
-	SpanWithinQuery ssequery = new SpanWithinQuery("s", ssquery.toQuery());
+        SpanSequenceQueryWrapper ssquery = new SpanSequenceQueryWrapper(
+                "field", "a", "b", "c");
+        SpanWithinQuery ssequery = new SpanWithinQuery("s", ssquery.toQuery());
 
-	assertEquals("spanContain(<field:s />, spanNext(spanNext(field:a, field:b), field:c))", ssequery.toString());
+        assertEquals(
+                "spanContain(<field:s />, spanNext(spanNext(field:a, field:b), field:c))",
+                ssequery.toString());
 
-	ssquery = new SpanSequenceQueryWrapper("field", "a", "b");
-	ssequery = new SpanWithinQuery("p", ssquery.toQuery());
-	assertEquals("spanContain(<field:p />, spanNext(field:a, field:b))", ssequery.toString());
+        ssquery = new SpanSequenceQueryWrapper("field", "a", "b");
+        ssequery = new SpanWithinQuery("p", ssquery.toQuery());
+        assertEquals("spanContain(<field:p />, spanNext(field:a, field:b))",
+                ssequery.toString());
 
     };
-    
+
 };
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
index 153ff5f..180fecb 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
@@ -26,42 +26,35 @@
 public class TestTemporaryQueryLimitations {
 
     @Test
-    public void classRefCheckNotSupported () throws IOException, QueryException  {
+    public void classRefCheckNotSupported () throws IOException, QueryException {
 
-	// Construct index
-	KrillIndex ki = new KrillIndex();
-	String json = new String(
-"{" +
-"  \"fields\" : [" +
-"    { "+
-"      \"primaryData\" : \"abc\"" +
-"    }," +
-"    {" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" +
-"      ]" +
-"    }" +
-"  ]" +
-"}");
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        String json = new String("{" + "  \"fields\" : [" + "    { "
+                + "      \"primaryData\" : \"abc\"" + "    }," + "    {"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]" + "      ]"
+                + "    }" + "  ]" + "}");
 
-	FieldDocument fd = ki.addDoc(json);
-	ki.commit();
+        FieldDocument fd = ki.addDoc(json);
+        ki.commit();
 
-	json = getString(getClass().getResource("/queries/bugs/cosmas_classrefcheck.jsonld").getFile());
-	
-	Krill ks = new Krill(json);
-	Result kr = ks.apply(ki);
-	assertEquals(kr.getSerialQuery(),"focus(130: {131: spanContain({129: <tokens:s />}, {130: tokens:s:wegen})})");
-	assertEquals(kr.getTotalResults(),0);
-	assertEquals(kr.getStartIndex(),0);
+        json = getString(getClass().getResource(
+                "/queries/bugs/cosmas_classrefcheck.jsonld").getFile());
 
-	assertEquals("This is a warning coming from the serialization",
-		     kr.getWarning(1).getMessage());
-	assertEquals("Class reference checks are currently not supported" +
-		     " - results may not be correct",
-		     kr.getWarning(0).getMessage());
+        Krill ks = new Krill(json);
+        Result kr = ks.apply(ki);
+        assertEquals(kr.getSerialQuery(),
+                "focus(130: {131: spanContain({129: <tokens:s />}, {130: tokens:s:wegen})})");
+        assertEquals(kr.getTotalResults(), 0);
+        assertEquals(kr.getStartIndex(), 0);
+
+        assertEquals("This is a warning coming from the serialization", kr
+                .getWarning(1).getMessage());
+        assertEquals("Class reference checks are currently not supported"
+                + " - results may not be correct", kr.getWarning(0)
+                .getMessage());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestMessage.java b/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
index 094a38b..8da908a 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
@@ -14,40 +14,46 @@
 
     @Test
     public void StringMessage () {
-	Messages km = new Messages();
-	assertEquals("[]", km.toJsonString());
+        Messages km = new Messages();
+        assertEquals("[]", km.toJsonString());
     };
 
+
     @Test
     public void StringMessageSet () {
-	Messages km = new Messages();
-	km.add(612,"Foo");
-	assertEquals("[[612,\"Foo\"]]", km.toJsonString());
-	km.add(613,"Bar");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\"]]", km.toJsonString());
+        Messages km = new Messages();
+        km.add(612, "Foo");
+        assertEquals("[[612,\"Foo\"]]", km.toJsonString());
+        km.add(613, "Bar");
+        assertEquals("[[612,\"Foo\"],[613,\"Bar\"]]", km.toJsonString());
     };
 
+
     @Test
     public void StringMessageParameters () {
-	Messages km = new Messages();
-	km.add(612,"Foo");
-	assertEquals("[[612,\"Foo\"]]", km.toJsonString());
-	km.add(613,"Bar", "Instanz");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"]]", km.toJsonString());
-	km.add(614,"Test");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"],[614,\"Test\"]]", km.toJsonString());
+        Messages km = new Messages();
+        km.add(612, "Foo");
+        assertEquals("[[612,\"Foo\"]]", km.toJsonString());
+        km.add(613, "Bar", "Instanz");
+        assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"]]",
+                km.toJsonString());
+        km.add(614, "Test");
+        assertEquals(
+                "[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"],[614,\"Test\"]]",
+                km.toJsonString());
     };
 
+
     @Test
     public void CheckIterability () {
-	Messages km = new Messages();
-	km.add(612,"Foo");
-	km.add(613,"Bar", "Instanz");
-	km.add(614,"Test");
-	String test = "";
-	for (Message msg : km)
-	    test += msg.getCode();
+        Messages km = new Messages();
+        km.add(612, "Foo");
+        km.add(613, "Bar", "Instanz");
+        km.add(614, "Test");
+        String test = "";
+        for (Message msg : km)
+            test += msg.getCode();
 
-	assertEquals(test, "612613614");
+        assertEquals(test, "612613614");
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java b/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
index 9bbf396..ed305de 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
@@ -19,187 +19,188 @@
 
     ObjectMapper mapper = new ObjectMapper();
 
+
     @Test
     public void testNotification () {
-	Notifications notes = new Notifications();
-	assertEquals("{}", notes.toJsonString());
+        Notifications notes = new Notifications();
+        assertEquals("{}", notes.toJsonString());
     };
 
+
     @Test
     public void testNotificationWarnings () throws IOException {
-	Notifications notes = new Notifications();
-	assertFalse(notes.hasWarnings());
-	assertFalse(notes.hasMessages());
-	assertFalse(notes.hasErrors());
+        Notifications notes = new Notifications();
+        assertFalse(notes.hasWarnings());
+        assertFalse(notes.hasMessages());
+        assertFalse(notes.hasErrors());
 
-	notes.addWarning(613, "Foo");
-	notes.addWarning(614, "Bar", "Spiel");
+        notes.addWarning(613, "Foo");
+        notes.addWarning(614, "Bar", "Spiel");
 
-	assertEquals("{\"warnings\":[[613,\"Foo\"],[614,\"Bar\"," +
-		     "\"Spiel\"]]}", notes.toJsonString());
+        assertEquals("{\"warnings\":[[613,\"Foo\"],[614,\"Bar\","
+                + "\"Spiel\"]]}", notes.toJsonString());
 
-	assertTrue(notes.hasWarnings());
-	assertFalse(notes.hasMessages());
-	assertFalse(notes.hasErrors());
+        assertTrue(notes.hasWarnings());
+        assertFalse(notes.hasMessages());
+        assertFalse(notes.hasErrors());
 
-	notes.addError(412, "Test");
+        notes.addError(412, "Test");
 
-	assertTrue(notes.hasWarnings());
-	assertFalse(notes.hasMessages());
-	assertTrue(notes.hasErrors());
+        assertTrue(notes.hasWarnings());
+        assertFalse(notes.hasMessages());
+        assertTrue(notes.hasErrors());
 
-	JsonNode noteJson = mapper.readTree(notes.toJsonString());
+        JsonNode noteJson = mapper.readTree(notes.toJsonString());
 
-	// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],"errors":[[412,"Test"]]}
-	assertEquals(613, noteJson.at("/warnings/0/0").asInt());
-	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
-	assertEquals(614, noteJson.at("/warnings/1/0").asInt());
-	assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
-	assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
-	assertEquals(412, noteJson.at("/errors/0/0").asInt());
-	assertEquals("Test", noteJson.at("/errors/0/1").asText());
+        // {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],"errors":[[412,"Test"]]}
+        assertEquals(613, noteJson.at("/warnings/0/0").asInt());
+        assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
+        assertEquals(614, noteJson.at("/warnings/1/0").asInt());
+        assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
+        assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
+        assertEquals(412, noteJson.at("/errors/0/0").asInt());
+        assertEquals("Test", noteJson.at("/errors/0/1").asText());
 
-	notes.addMessage(567, "Probe", "huhu", "hihi");
+        notes.addMessage(567, "Probe", "huhu", "hihi");
 
-	assertTrue(notes.hasWarnings());
-	assertTrue(notes.hasMessages());
-	assertTrue(notes.hasErrors());
+        assertTrue(notes.hasWarnings());
+        assertTrue(notes.hasMessages());
+        assertTrue(notes.hasErrors());
 
-	noteJson = mapper.readTree(notes.toJsonString());
+        noteJson = mapper.readTree(notes.toJsonString());
 
-	// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],
-	// "errors":[[412,"Test"]]}
-	assertEquals(613, noteJson.at("/warnings/0/0").asInt());
-	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
-	assertEquals(614, noteJson.at("/warnings/1/0").asInt());
-	assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
-	assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
-	assertEquals(412, noteJson.at("/errors/0/0").asInt());
-	assertEquals("Test", noteJson.at("/errors/0/1").asText());
-	assertEquals(567, noteJson.at("/messages/0/0").asInt());
-	assertEquals("Probe", noteJson.at("/messages/0/1").asText());
-	assertEquals("huhu", noteJson.at("/messages/0/2").asText());
-	assertEquals("hihi", noteJson.at("/messages/0/3").asText());
+        // {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],
+        // "errors":[[412,"Test"]]}
+        assertEquals(613, noteJson.at("/warnings/0/0").asInt());
+        assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
+        assertEquals(614, noteJson.at("/warnings/1/0").asInt());
+        assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
+        assertEquals("Spiel", noteJson.at("/warnings/1/2").asText());
+        assertEquals(412, noteJson.at("/errors/0/0").asInt());
+        assertEquals("Test", noteJson.at("/errors/0/1").asText());
+        assertEquals(567, noteJson.at("/messages/0/0").asInt());
+        assertEquals("Probe", noteJson.at("/messages/0/1").asText());
+        assertEquals("huhu", noteJson.at("/messages/0/2").asText());
+        assertEquals("hihi", noteJson.at("/messages/0/3").asText());
 
-	// Todo: Check how to check for missing node
+        // Todo: Check how to check for missing node
 
-	Messages msgs = notes.getWarnings();
-	assertEquals("[[613,\"Foo\"],[614,\"Bar\",\"Spiel\"]]",
-		     msgs.toJsonString());
+        Messages msgs = notes.getWarnings();
+        assertEquals("[[613,\"Foo\"],[614,\"Bar\",\"Spiel\"]]",
+                msgs.toJsonString());
     };
 
 
     @Test
     public void testNotificationCopy () throws IOException {
 
-	Notifications notes1 = new Notifications();
-	notes1.addWarning(1, "Foo");
-	notes1.addWarning(2, "Bar", "Test");
-	notes1.addError(3, "Probe");
+        Notifications notes1 = new Notifications();
+        notes1.addWarning(1, "Foo");
+        notes1.addWarning(2, "Bar", "Test");
+        notes1.addError(3, "Probe");
 
-	Notifications notes2 = new Notifications();
-	notes2.addMessage(4, "Krah");
-	notes2.addWarning(5, "Wu", "Niegel");
+        Notifications notes2 = new Notifications();
+        notes2.addMessage(4, "Krah");
+        notes2.addWarning(5, "Wu", "Niegel");
 
-	assertTrue(notes1.hasWarnings());
-	assertFalse(notes1.hasMessages());
-	assertTrue(notes1.hasErrors());
+        assertTrue(notes1.hasWarnings());
+        assertFalse(notes1.hasMessages());
+        assertTrue(notes1.hasErrors());
 
-	assertTrue(notes2.hasWarnings());
-	assertTrue(notes2.hasMessages());
-	assertFalse(notes2.hasErrors());
+        assertTrue(notes2.hasWarnings());
+        assertTrue(notes2.hasMessages());
+        assertFalse(notes2.hasErrors());
 
-	// Copy notations
-	notes1.copyNotificationsFrom(notes2);
-	assertTrue(notes1.hasWarnings());
-	assertTrue(notes1.hasMessages());
-	assertTrue(notes1.hasErrors());
+        // Copy notations
+        notes1.copyNotificationsFrom(notes2);
+        assertTrue(notes1.hasWarnings());
+        assertTrue(notes1.hasMessages());
+        assertTrue(notes1.hasErrors());
 
-	JsonNode noteJson = mapper.readTree(notes1.toJsonString());
-	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
-	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
-	assertEquals(2, noteJson.at("/warnings/1/0").asInt());
-	assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
-	assertEquals("Test", noteJson.at("/warnings/1/2").asText());
-	assertEquals(5, noteJson.at("/warnings/2/0").asInt());
-	assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
-	assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
-	assertEquals(4, noteJson.at("/messages/0/0").asInt());
-	assertEquals("Krah", noteJson.at("/messages/0/1").asText());
-	assertEquals(3, noteJson.at("/errors/0/0").asInt());
-	assertEquals("Probe", noteJson.at("/errors/0/1").asText());
+        JsonNode noteJson = mapper.readTree(notes1.toJsonString());
+        assertEquals(1, noteJson.at("/warnings/0/0").asInt());
+        assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
+        assertEquals(2, noteJson.at("/warnings/1/0").asInt());
+        assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
+        assertEquals("Test", noteJson.at("/warnings/1/2").asText());
+        assertEquals(5, noteJson.at("/warnings/2/0").asInt());
+        assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
+        assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
+        assertEquals(4, noteJson.at("/messages/0/0").asInt());
+        assertEquals("Krah", noteJson.at("/messages/0/1").asText());
+        assertEquals(3, noteJson.at("/errors/0/0").asInt());
+        assertEquals("Probe", noteJson.at("/errors/0/1").asText());
     };
 
+
     @Test
     public void testNotificationJSONCopy () throws IOException {
 
-	Notifications notes1 = new Notifications();
-	notes1.addWarning(1, "Foo");
-	notes1.addWarning(2, "Bar", "Test");
-	notes1.addError(3, "Probe");
+        Notifications notes1 = new Notifications();
+        notes1.addWarning(1, "Foo");
+        notes1.addWarning(2, "Bar", "Test");
+        notes1.addError(3, "Probe");
 
-	assertTrue(notes1.hasWarnings());
-	assertFalse(notes1.hasMessages());
-	assertTrue(notes1.hasErrors());
+        assertTrue(notes1.hasWarnings());
+        assertFalse(notes1.hasMessages());
+        assertTrue(notes1.hasErrors());
 
-	JsonNode noteJson = mapper.readTree(
-	    "{\"warnings\":[[5,\"Wu\",\"Niegel\"]]," +
-	    "\"messages\":[[4,\"Krah\"]]}"
-        );
-	notes1.copyNotificationsFrom(noteJson);
+        JsonNode noteJson = mapper
+                .readTree("{\"warnings\":[[5,\"Wu\",\"Niegel\"]],"
+                        + "\"messages\":[[4,\"Krah\"]]}");
+        notes1.copyNotificationsFrom(noteJson);
 
-	assertTrue(notes1.hasWarnings());
-	assertTrue(notes1.hasMessages());
-	assertTrue(notes1.hasErrors());
+        assertTrue(notes1.hasWarnings());
+        assertTrue(notes1.hasMessages());
+        assertTrue(notes1.hasErrors());
 
-	noteJson = mapper.readTree(notes1.toJsonString());
+        noteJson = mapper.readTree(notes1.toJsonString());
 
-	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
-	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
-	assertEquals(2, noteJson.at("/warnings/1/0").asInt());
-	assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
-	assertEquals("Test", noteJson.at("/warnings/1/2").asText());
-	assertEquals(5, noteJson.at("/warnings/2/0").asInt());
-	assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
-	assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
+        assertEquals(1, noteJson.at("/warnings/0/0").asInt());
+        assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
+        assertEquals(2, noteJson.at("/warnings/1/0").asInt());
+        assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
+        assertEquals("Test", noteJson.at("/warnings/1/2").asText());
+        assertEquals(5, noteJson.at("/warnings/2/0").asInt());
+        assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
+        assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
 
-	assertEquals(4, noteJson.at("/messages/0/0").asInt());
-	assertEquals("Krah", noteJson.at("/messages/0/1").asText());
+        assertEquals(4, noteJson.at("/messages/0/0").asInt());
+        assertEquals("Krah", noteJson.at("/messages/0/1").asText());
 
-	assertEquals(3, noteJson.at("/errors/0/0").asInt());
-	assertEquals("Probe", noteJson.at("/errors/0/1").asText());
+        assertEquals(3, noteJson.at("/errors/0/0").asInt());
+        assertEquals("Probe", noteJson.at("/errors/0/1").asText());
 
-	noteJson = mapper.readTree(
-	    "{\"warnings\":[[8, \"Tanja\", \"Gaby\"]],\"errors\":" +
-	    "[[\"Klößchen\"],[9,\"Karl\"]]}"
-        );
-	notes1.copyNotificationsFrom(noteJson);
+        noteJson = mapper
+                .readTree("{\"warnings\":[[8, \"Tanja\", \"Gaby\"]],\"errors\":"
+                        + "[[\"Klößchen\"],[9,\"Karl\"]]}");
+        notes1.copyNotificationsFrom(noteJson);
 
-	assertTrue(notes1.hasWarnings());
-	assertTrue(notes1.hasMessages());
-	assertTrue(notes1.hasErrors());
+        assertTrue(notes1.hasWarnings());
+        assertTrue(notes1.hasMessages());
+        assertTrue(notes1.hasErrors());
 
-	noteJson = mapper.readTree(notes1.toJsonString());
+        noteJson = mapper.readTree(notes1.toJsonString());
 
-	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
-	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
-	assertEquals(2, noteJson.at("/warnings/1/0").asInt());
-	assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
-	assertEquals("Test", noteJson.at("/warnings/1/2").asText());
-	assertEquals(5, noteJson.at("/warnings/2/0").asInt());
-	assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
-	assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
-	assertEquals(8, noteJson.at("/warnings/3/0").asInt());
-	assertEquals("Tanja", noteJson.at("/warnings/3/1").asText());
-	assertEquals("Gaby", noteJson.at("/warnings/3/2").asText());
+        assertEquals(1, noteJson.at("/warnings/0/0").asInt());
+        assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
+        assertEquals(2, noteJson.at("/warnings/1/0").asInt());
+        assertEquals("Bar", noteJson.at("/warnings/1/1").asText());
+        assertEquals("Test", noteJson.at("/warnings/1/2").asText());
+        assertEquals(5, noteJson.at("/warnings/2/0").asInt());
+        assertEquals("Wu", noteJson.at("/warnings/2/1").asText());
+        assertEquals("Niegel", noteJson.at("/warnings/2/2").asText());
+        assertEquals(8, noteJson.at("/warnings/3/0").asInt());
+        assertEquals("Tanja", noteJson.at("/warnings/3/1").asText());
+        assertEquals("Gaby", noteJson.at("/warnings/3/2").asText());
 
-	assertEquals(4, noteJson.at("/messages/0/0").asInt());
-	assertEquals("Krah", noteJson.at("/messages/0/1").asText());
+        assertEquals(4, noteJson.at("/messages/0/0").asInt());
+        assertEquals("Krah", noteJson.at("/messages/0/1").asText());
 
-	assertEquals(3, noteJson.at("/errors/0/0").asInt());
-	assertEquals("Probe", noteJson.at("/errors/0/1").asText());
-	assertEquals("Klößchen", noteJson.at("/errors/1/0").asText());
-	assertEquals(9, noteJson.at("/errors/2/0").asInt());
-	assertEquals("Karl", noteJson.at("/errors/2/1").asText());
+        assertEquals(3, noteJson.at("/errors/0/0").asInt());
+        assertEquals("Probe", noteJson.at("/errors/0/1").asText());
+        assertEquals("Klößchen", noteJson.at("/errors/1/0").asText());
+        assertEquals(9, noteJson.at("/errors/2/0").asInt());
+        assertEquals("Karl", noteJson.at("/errors/2/1").asText());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
index 220ce19..c6d40ee 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
@@ -20,13 +20,14 @@
 
     ObjectMapper mapper = new ObjectMapper();
 
+
     @Test
     public void testResponse () throws IOException {
-		Response resp = new Response();
-		assertEquals("{}", resp.toJsonString());
-		resp.setVersion("0.24");
+        Response resp = new Response();
+        assertEquals("{}", resp.toJsonString());
+        resp.setVersion("0.24");
         resp.setNode("Tanja");
-        assertEquals("0.24",resp.getVersion());
+        assertEquals("0.24", resp.getVersion());
         assertEquals("Tanja", resp.getNode());
 
         assertFalse(resp.hasWarnings());
@@ -49,13 +50,14 @@
         assertEquals("took a while", respJson.at("/benchmark").asText());
     };
 
+
     @Test
     public void testResponseNotifications () throws IOException {
         Response resp = new Response();
         assertEquals("{}", resp.toJsonString());
         resp.setVersion("0.24");
         resp.setNode("Tanja");
-        assertEquals("0.24",resp.getVersion());
+        assertEquals("0.24", resp.getVersion());
         assertEquals("Tanja", resp.getNode());
 
         assertFalse(resp.hasWarnings());
@@ -75,13 +77,14 @@
         respJson = mapper.readTree(resp.toJsonString());
         assertEquals("0.24", respJson.at("/version").asText());
         assertEquals("Tanja", respJson.at("/node").asText());
-        
+
         assertEquals("Fehler 1", respJson.at("/warnings/0/1").asText());
         assertEquals("Fehler 2", respJson.at("/warnings/1/1").asText());
         assertEquals("Fehler 3", respJson.at("/warnings/2/1").asText());
         assertEquals("Fehler 4", respJson.at("/errors/0/1").asText());
     };
 
+
     @Test
     public void testResponseDeserialzation () throws IOException {
         String jsonResponse = "{\"version\":\"0.38\"}";
@@ -120,9 +123,9 @@
         kresp = mapper.readValue(jsonResponse, Response.class);
         assertEquals("tanja", kresp.getNode());
 
-        jsonResponse = "{\"node\":\"tanja\", \"version\":\"seaweed-0.49\", " +
-            " \"benchmark\":\"40.5s\",  \"listener\":\"10.0.10.14:678\"," +
-            "\"timeExceeded\":true }";
+        jsonResponse = "{\"node\":\"tanja\", \"version\":\"seaweed-0.49\", "
+                + " \"benchmark\":\"40.5s\",  \"listener\":\"10.0.10.14:678\","
+                + "\"timeExceeded\":true }";
         kresp = mapper.readValue(jsonResponse, Response.class);
         assertEquals("0.49", kresp.getVersion());
         assertEquals("seaweed", kresp.getName());
@@ -132,12 +135,12 @@
         assertTrue(kresp.hasTimeExceeded());
         assertTrue(kresp.hasWarnings());
 
-        jsonResponse = "{\"warnings\":[[123,\"This is a warning\"]," +
-            "[124,\"This is a second warning\"]],"+
-            "\"errors\":[[125,\"This is a single error\"]], "+
-            " \"node\":\"tanja\", \"version\":\"seaweed-0.49\", " +
-            " \"benchmark\":\"40.5s\",  \"listener\":\"10.0.10.14:678\"," +
-            "\"timeExceeded\":true }";
+        jsonResponse = "{\"warnings\":[[123,\"This is a warning\"],"
+                + "[124,\"This is a second warning\"]],"
+                + "\"errors\":[[125,\"This is a single error\"]], "
+                + " \"node\":\"tanja\", \"version\":\"seaweed-0.49\", "
+                + " \"benchmark\":\"40.5s\",  \"listener\":\"10.0.10.14:678\","
+                + "\"timeExceeded\":true }";
         kresp = mapper.readValue(jsonResponse, Response.class);
         assertTrue(kresp.hasWarnings());
         assertTrue(kresp.hasErrors());
@@ -146,7 +149,8 @@
 
         // THIS MAY BREAK!
         assertEquals(kresp.getWarning(0).getMessage(), "This is a warning");
-        assertEquals(kresp.getWarning(1).getMessage(), "This is a second warning");
+        assertEquals(kresp.getWarning(1).getMessage(),
+                "This is a second warning");
         assertEquals(kresp.getWarning(2).getMessage(), "Response time exceeded");
         assertEquals("0.49", kresp.getVersion());
         assertEquals("seaweed", kresp.getName());
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
index 33175d2..622a80b 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKrill.java
@@ -34,9 +34,7 @@
 public class TestKrill {
     @Test
     public void searchCount () {
-        Krill k = new Krill(
-          new QueryBuilder("field1").seg("a").with("b")
-        );
+        Krill k = new Krill(new QueryBuilder("field1").seg("a").with("b"));
 
         KrillMeta meta = k.getMeta();
 
@@ -51,11 +49,10 @@
         assertEquals(meta.getCount(), meta.getCountMax());
     };
 
+
     @Test
     public void searchStartIndex () {
-        Krill k = new Krill(
-            new QueryBuilder("field1").seg("a").with("b")
-        );
+        Krill k = new Krill(new QueryBuilder("field1").seg("a").with("b"));
 
         KrillMeta meta = k.getMeta();
 
@@ -72,13 +69,13 @@
         assertEquals(meta.getStartIndex(), 0);
     };
 
+
     @Test
     public void searchQuery () {
-        Krill ks = new Krill(
-            new QueryBuilder("field1").seg("a").with("b")
-        );
+        Krill ks = new Krill(new QueryBuilder("field1").seg("a").with("b"));
         // query
-        assertEquals(ks.getSpanQuery().toString(), "spanSegment(field1:a, field1:b)");
+        assertEquals(ks.getSpanQuery().toString(),
+                "spanSegment(field1:a, field1:b)");
     };
 
 
@@ -87,41 +84,30 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        Krill ks = new Krill(
-	        new QueryBuilder("tokens").seg("s:Buchstaben")
-        );
+        Krill ks = new Krill(new QueryBuilder("tokens").seg("s:Buchstaben"));
 
         // Todo: This is not an acceptable collection, but sigh
         ks.getCollection().filter(
-            new CollectionBuilder().and("textClass", "reisen")
-        );
+                new CollectionBuilder().and("textClass", "reisen"));
 
         KrillMeta meta = ks.getMeta();
         meta.setCount(3);
         meta.setStartIndex(5);
         meta.getContext().left.setLength(1);
         meta.getContext().right.setLength(1);
-        
+
         Result kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 6);
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "... dem [Buchstaben] A ..."
-        );
+        assertEquals(kr.getMatch(0).getSnippetBrackets(),
+                "... dem [Buchstaben] A ...");
 
         JsonNode res = ks.toJsonNode();
         assertEquals(3, res.at("/meta/count").asInt());
@@ -138,65 +124,48 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/metaquery3.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/metaquery3.jsonld").getFile());
 
         Krill ks = new Krill(json);
-		Result kr = ks.apply(ki);
+        Result kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 66);
         assertEquals(5, kr.getItemsPerPage());
         assertEquals(5, kr.getStartIndex());
-        assertEquals(
-            "... a: A ist [der klangreichste] der V ...",
-            kr.getMatch(0).getSnippetBrackets()
-        );
+        assertEquals("... a: A ist [der klangreichste] der V ...",
+                kr.getMatch(0).getSnippetBrackets());
     };
 
+
     @Test
     public void searchJSON2 () throws IOException {
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439",
-                                      "00012-fakemeta",
-                                      "00030-fakemeta",
-                                      /*
-                                        "02035-substring",
-                                        "05663-unbalanced",
-                                        "07452-deep"
-                                      */
-            }) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439", "00012-fakemeta", "00030-fakemeta",
+        /*
+          "02035-substring",
+          "05663-unbalanced",
+          "07452-deep"
+        */
+        }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/metaquery4.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/metaquery4.jsonld").getFile());
 
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
@@ -210,17 +179,15 @@
 
         assertEquals(kr.getTotalResults(), 5);
 
-        json = getString(
-            getClass().getResource("/queries/metaquery5.jsonld").getFile()
-        );
+        json = getString(getClass().getResource("/queries/metaquery5.jsonld")
+                .getFile());
 
         ks = new Krill(json);
         kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 1);
 
-        json = getString(
-            getClass().getResource("/queries/metaquery6.jsonld").getFile()
-        );
+        json = getString(getClass().getResource("/queries/metaquery6.jsonld")
+                .getFile());
         ks = new Krill(json);
         kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 1);
@@ -232,18 +199,11 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"
-            }) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                      getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
         Result kr = new Krill("{ query").apply(ki);
@@ -257,23 +217,16 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-fail1.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-fail1.jsonld").getFile());
 
         Result kr = new Krill(json).apply(ki);
         assertEquals(0, kr.getStartIndex());
@@ -287,23 +240,16 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-fail2.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-fail2.jsonld").getFile());
 
         Result kr = new Krill(json).apply(ki);
         assertEquals(50, kr.getItemsPerPage());
@@ -317,32 +263,25 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-context.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-context.jsonld").getFile());
 
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 10);
-        assertEquals("A bzw. a ist der erste Buchstabe des" +
-                     " lateinischen [Alphabets] und ein Vokal." +
-                     " Der Buchstabe A hat in deutschen Texten" +
-                     " eine durchschnittliche Häufigkeit  ...",
-                     kr.getMatch(0).getSnippetBrackets());
+        assertEquals("A bzw. a ist der erste Buchstabe des"
+                + " lateinischen [Alphabets] und ein Vokal."
+                + " Der Buchstabe A hat in deutschen Texten"
+                + " eine durchschnittliche Häufigkeit  ...", kr.getMatch(0)
+                .getSnippetBrackets());
 
         ks.getMeta().setCount(5);
         ks.getMeta().setStartPage(2);
@@ -351,49 +290,41 @@
         assertEquals(5, kr.getStartIndex());
         assertEquals(5, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().getResource("/queries/bsp-context-2.jsonld").getFile()
-        );
+        json = getString(getClass()
+                .getResource("/queries/bsp-context-2.jsonld").getFile());
 
         kr = new Krill(json).apply(ki);
 
         assertEquals(kr.getTotalResults(), -1);
-        assertEquals("... lls seit den Griechen beibehalten worden." +
-                     " 3. Bedeutungen in der Biologie steht A für"+
-                     " das Nukleosid Adenosin steht A die Base"+
-                     " Adenin steht A für die Aminosäure Alanin"+
-                     " in der Informatik steht a für den dezimalen"+
-                     " [Wert] 97 sowohl im ASCII- als auch im"+
-                     " Unicode-Zeichensatz steht A für den dezimalen"+
-                     " Wert 65 sowohl im ASCII- als auch im"+
-                     " Unicode-Zeichensatz als Kfz-Kennzeichen"+
-                     " steht A in Deutschland für Augsburg."+
-                     " in Österreich auf ...",
-                     kr.getMatch(0).getSnippetBrackets());
+        assertEquals("... lls seit den Griechen beibehalten worden."
+                + " 3. Bedeutungen in der Biologie steht A für"
+                + " das Nukleosid Adenosin steht A die Base"
+                + " Adenin steht A für die Aminosäure Alanin"
+                + " in der Informatik steht a für den dezimalen"
+                + " [Wert] 97 sowohl im ASCII- als auch im"
+                + " Unicode-Zeichensatz steht A für den dezimalen"
+                + " Wert 65 sowohl im ASCII- als auch im"
+                + " Unicode-Zeichensatz als Kfz-Kennzeichen"
+                + " steht A in Deutschland für Augsburg."
+                + " in Österreich auf ...", kr.getMatch(0).getSnippetBrackets());
     };
 
+
     @Test
     public void searchJSONstartPage () throws IOException {
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-paging.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-paging.jsonld").getFile());
 
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
@@ -401,18 +332,16 @@
         assertEquals(5, kr.getStartIndex());
         assertEquals(5, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().getResource("/queries/bsp-cutoff.jsonld").getFile()
-        );
+        json = getString(getClass().getResource("/queries/bsp-cutoff.jsonld")
+                .getFile());
         ks = ks = new Krill(json);
         kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), -1);
         assertEquals(2, kr.getStartIndex());
         assertEquals(2, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().getResource("/queries/metaquery9.jsonld").getFile()
-        );
+        json = getString(getClass().getResource("/queries/metaquery9.jsonld")
+                .getFile());
         KrillCollection kc = new KrillCollection(json);
         kc.setIndex(ki);
         assertEquals(7, kc.numberOf("documents"));
@@ -424,24 +353,15 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
-        String json = getString(
-            getClass().
-            getResource("/queries/bsp-itemsPerResource.jsonld").
-            getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-itemsPerResource.jsonld").getFile());
 
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
@@ -464,11 +384,11 @@
         assertEquals("WPD_AAA.00001", kr.getMatch(0).getDocID());
         assertEquals("WPD_AAA.00002", kr.getMatch(1).getDocID());
         assertEquals("WPD_AAA.00004", kr.getMatch(2).getDocID());
-        
+
         assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getStartIndex());
         assertEquals(20, kr.getItemsPerPage());
-        
+
         ks = new Krill(json);
         ks.getMeta().setItemsPerResource(2);
 
@@ -479,7 +399,7 @@
         assertEquals("WPD_AAA.00002", kr.getMatch(2).getDocID());
         assertEquals("WPD_AAA.00002", kr.getMatch(3).getDocID());
         assertEquals("WPD_AAA.00004", kr.getMatch(4).getDocID());
-        
+
         assertEquals(kr.getTotalResults(), 5);
         assertEquals(0, kr.getStartIndex());
         assertEquals(20, kr.getItemsPerPage());
@@ -491,7 +411,7 @@
         meta.setCount(1);
 
         kr = ks.apply(ki);
-	
+
         assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
 
         assertEquals(kr.getTotalResults(), 3);
@@ -512,32 +432,22 @@
         KrillIndex ki = new KrillIndex();
         // Indexing test files
         int uid = 1;
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
-            ki.addDoc(
-                uid++,
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
+            ki.addDoc(uid++,
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().
-            getResource("/queries/bsp-uid-example.jsonld").
-            getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-uid-example.jsonld").getFile());
 
         Krill ks = new Krill(json);
         ks.getMeta().setItemsPerResource(1);
 
         KrillCollection kc = new KrillCollection();
-        kc.filterUIDs(new String[]{"1", "4"});
+        kc.filterUIDs(new String[] { "1", "4" });
         kc.setIndex(ki);
         ks.setCollection(kc);
 
@@ -554,42 +464,37 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        FieldDocument fd = ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/goe/AGA-03828.json.gz"),
-            true
-        );
+        FieldDocument fd = ki.addDoc(1,
+                getClass().getResourceAsStream("/goe/AGA-03828.json.gz"), true);
         ki.commit();
 
         assertEquals(fd.getUID(), 1);
-        assertEquals(fd.getTextSigle(),   "GOE_AGA.03828");
-        assertEquals(fd.getDocSigle(),    "GOE_AGA");
+        assertEquals(fd.getTextSigle(), "GOE_AGA.03828");
+        assertEquals(fd.getDocSigle(), "GOE_AGA");
         assertEquals(fd.getCorpusSigle(), "GOE");
-        assertEquals(fd.getTitle()  ,     "Autobiographische Einzelheiten");
+        assertEquals(fd.getTitle(), "Autobiographische Einzelheiten");
         assertNull(fd.getSubTitle());
-        assertEquals(fd.getTextType(),    "Autobiographie");
+        assertEquals(fd.getTextType(), "Autobiographie");
         assertNull(fd.getTextTypeArt());
         assertNull(fd.getTextTypeRef());
         assertNull(fd.getTextColumn());
         assertNull(fd.getTextDomain());
-        assertEquals(fd.getPages(),       "529-547");
-        assertEquals(fd.getLicense(),     "QAO-NC");
+        assertEquals(fd.getPages(), "529-547");
+        assertEquals(fd.getLicense(), "QAO-NC");
         assertEquals(fd.getCreationDate().toString(), "18200000");
-        assertEquals(fd.getPubDate().toString(),      "19820000");
-        assertEquals(fd.getAuthor(),      "Goethe, Johann Wolfgang von");
+        assertEquals(fd.getPubDate().toString(), "19820000");
+        assertEquals(fd.getAuthor(), "Goethe, Johann Wolfgang von");
         assertNull(fd.getTextClass());
-        assertEquals(fd.getLanguage(),    "de");
-        assertEquals(fd.getPubPlace(),    "München");
-        assertEquals(fd.getReference(),
-                     "Goethe, Johann Wolfgang von:"+
-                     " Autobiographische Einzelheiten,"+
-                     " (Geschrieben bis 1832), In: Goethe,"+
-                     " Johann Wolfgang von: Goethes Werke,"+
-                     " Bd. 10, Autobiographische Schriften"+
-                     " II, Hrsg.: Trunz, Erich. München: "+
-                     "Verlag C. H. Beck, 1982, S. 529-547");
-        assertEquals(fd.getPublisher(),   "Verlag C. H. Beck");
+        assertEquals(fd.getLanguage(), "de");
+        assertEquals(fd.getPubPlace(), "München");
+        assertEquals(fd.getReference(), "Goethe, Johann Wolfgang von:"
+                + " Autobiographische Einzelheiten,"
+                + " (Geschrieben bis 1832), In: Goethe,"
+                + " Johann Wolfgang von: Goethes Werke,"
+                + " Bd. 10, Autobiographische Schriften"
+                + " II, Hrsg.: Trunz, Erich. München: "
+                + "Verlag C. H. Beck, 1982, S. 529-547");
+        assertEquals(fd.getPublisher(), "Verlag C. H. Beck");
         assertNull(fd.getEditor());
         assertNull(fd.getFileEditionStatement());
         assertNull(fd.getBiblEditionStatement());
@@ -597,36 +502,32 @@
 
         assertEquals(fd.getTokenSource(), "opennlp#tokens");
         assertEquals(fd.getFoundries(),
-                     "base base/paragraphs base/sentences corenlp "+
-                     "corenlp/constituency corenlp/morpho "+
-                     "corenlp/namedentities corenlp/sentences "+
-                     "glemm glemm/morpho mate mate/morpho"+
-                     " opennlp opennlp/morpho opennlp/sentences"+
-                     " treetagger treetagger/morpho "+
-                     "treetagger/sentences");
+                "base base/paragraphs base/sentences corenlp "
+                        + "corenlp/constituency corenlp/morpho "
+                        + "corenlp/namedentities corenlp/sentences "
+                        + "glemm glemm/morpho mate mate/morpho"
+                        + " opennlp opennlp/morpho opennlp/sentences"
+                        + " treetagger treetagger/morpho "
+                        + "treetagger/sentences");
         assertEquals(fd.getLayerInfos(),
-                     "base/s=spans corenlp/c=spans corenlp/ne=tokens"+
-                     " corenlp/p=tokens corenlp/s=spans glemm/l=tokens"+
-                     " mate/l=tokens mate/m=tokens mate/p=tokens"+
-                     " opennlp/p=tokens opennlp/s=spans tt/l=tokens"+
-                     " tt/p=tokens tt/s=spans");
+                "base/s=spans corenlp/c=spans corenlp/ne=tokens"
+                        + " corenlp/p=tokens corenlp/s=spans glemm/l=tokens"
+                        + " mate/l=tokens mate/m=tokens mate/p=tokens"
+                        + " opennlp/p=tokens opennlp/s=spans tt/l=tokens"
+                        + " tt/p=tokens tt/s=spans");
 
         assertEquals(fd.getCorpusTitle(), "Goethes Werke");
         assertNull(fd.getCorpusSubTitle());
-        assertEquals(fd.getCorpusAuthor(),  "Goethe, Johann Wolfgang von");
-        assertEquals(fd.getCorpusEditor(),  "Trunz, Erich");
+        assertEquals(fd.getCorpusAuthor(), "Goethe, Johann Wolfgang von");
+        assertEquals(fd.getCorpusEditor(), "Trunz, Erich");
         assertEquals(fd.getDocTitle(),
-            "Goethe: Autobiographische Schriften II, (1817-1825, 1832)"
-        );
+                "Goethe: Autobiographische Schriften II, (1817-1825, 1832)");
         assertNull(fd.getDocSubTitle());
         assertNull(fd.getDocEditor());
         assertNull(fd.getDocAuthor());
 
-        Krill ks = new Krill(
-            new QueryBuilder("tokens").
-            seg("mate/m:case:nom").
-            with("mate/m:number:pl")
-        );
+        Krill ks = new Krill(new QueryBuilder("tokens").seg("mate/m:case:nom")
+                .with("mate/m:number:pl"));
         Result kr = ks.apply(ki);
 
         assertEquals(kr.getTotalResults(), 148);
@@ -640,64 +541,58 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        FieldDocument fd = ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-        );
+        FieldDocument fd = ki.addDoc(1,
+                getClass().getResourceAsStream("/bzk/D59-00089.json.gz"), true);
         ki.commit();
 
         assertEquals(fd.getUID(), 1);
-        assertEquals(fd.getTextSigle(),   "BZK_D59.00089");
-        assertEquals(fd.getDocSigle(),    "BZK_D59");
+        assertEquals(fd.getTextSigle(), "BZK_D59.00089");
+        assertEquals(fd.getDocSigle(), "BZK_D59");
         assertEquals(fd.getCorpusSigle(), "BZK");
-        assertEquals(fd.getTitle()  ,     "Saragat-Partei zerfällt");
-        assertEquals(fd.getPubDate().toString(),      "19590219");
+        assertEquals(fd.getTitle(), "Saragat-Partei zerfällt");
+        assertEquals(fd.getPubDate().toString(), "19590219");
 
         assertNull(fd.getSubTitle());
         assertNull(fd.getAuthor());
         assertNull(fd.getEditor());
-        assertEquals(fd.getPubPlace(),    "Berlin");
+        assertEquals(fd.getPubPlace(), "Berlin");
         assertNull(fd.getPublisher());
-        assertEquals(fd.getTextType(),    "Zeitung: Tageszeitung");
+        assertEquals(fd.getTextType(), "Zeitung: Tageszeitung");
         assertNull(fd.getTextTypeArt());
         assertEquals(fd.getTextTypeRef(), "Tageszeitung");
-        assertEquals(fd.getTextDomain(),  "Politik");
+        assertEquals(fd.getTextDomain(), "Politik");
         assertEquals(fd.getCreationDate().toString(), "19590219");
-        assertEquals(fd.getLicense(),     "ACA-NC-LC");
-        assertEquals(fd.getTextColumn(),  "POLITIK");
+        assertEquals(fd.getLicense(), "ACA-NC-LC");
+        assertEquals(fd.getTextColumn(), "POLITIK");
         assertNull(fd.getPages());
         assertEquals(fd.getTextClass(), "politik ausland");
         assertNull(fd.getFileEditionStatement());
         assertNull(fd.getBiblEditionStatement());
-        
-        assertEquals(fd.getLanguage(),    "de");
-        assertEquals(
-            fd.getReference(),
-            "Neues Deutschland, [Tageszeitung], 19.02.1959, Jg. 14,"+
-            " Berliner Ausgabe, S. 7. - Sachgebiet: Politik, "+
-            "Originalressort: POLITIK; Saragat-Partei zerfällt");
+
+        assertEquals(fd.getLanguage(), "de");
+        assertEquals(fd.getReference(),
+                "Neues Deutschland, [Tageszeitung], 19.02.1959, Jg. 14,"
+                        + " Berliner Ausgabe, S. 7. - Sachgebiet: Politik, "
+                        + "Originalressort: POLITIK; Saragat-Partei zerfällt");
         assertNull(fd.getPublisher());
         assertNull(fd.getKeywords());
 
         assertEquals(fd.getTokenSource(), "opennlp#tokens");
 
         assertEquals(
-            fd.getFoundries(),
-            "base base/paragraphs base/sentences corenlp "+
-            "corenlp/constituency corenlp/morpho corenlp/namedentities"+
-            " corenlp/sentences glemm glemm/morpho mate mate/morpho"+
-            " opennlp opennlp/morpho opennlp/sentences treetagger"+
-            " treetagger/morpho treetagger/sentences");
+                fd.getFoundries(),
+                "base base/paragraphs base/sentences corenlp "
+                        + "corenlp/constituency corenlp/morpho corenlp/namedentities"
+                        + " corenlp/sentences glemm glemm/morpho mate mate/morpho"
+                        + " opennlp opennlp/morpho opennlp/sentences treetagger"
+                        + " treetagger/morpho treetagger/sentences");
 
-        assertEquals(
-            fd.getLayerInfos(),
-            "base/s=spans corenlp/c=spans corenlp/ne=tokens"+
-            " corenlp/p=tokens corenlp/s=spans glemm/l=tokens"+
-            " mate/l=tokens mate/m=tokens mate/p=tokens"+
-            " opennlp/p=tokens opennlp/s=spans tt/l=tokens"+
-            " tt/p=tokens tt/s=spans");
+        assertEquals(fd.getLayerInfos(),
+                "base/s=spans corenlp/c=spans corenlp/ne=tokens"
+                        + " corenlp/p=tokens corenlp/s=spans glemm/l=tokens"
+                        + " mate/l=tokens mate/m=tokens mate/p=tokens"
+                        + " opennlp/p=tokens opennlp/s=spans tt/l=tokens"
+                        + " tt/p=tokens tt/s=spans");
 
         assertEquals(fd.getCorpusTitle(), "Bonner Zeitungskorpus");
         assertNull(fd.getCorpusSubTitle());
@@ -705,18 +600,14 @@
         assertNull(fd.getCorpusEditor());
 
         assertEquals(fd.getDocTitle(), "Neues Deutschland");
-        assertEquals(
-            fd.getDocSubTitle(),
-            "Organ des Zentralkomitees der Sozialistischen "+
-            "Einheitspartei Deutschlands");
+        assertEquals(fd.getDocSubTitle(),
+                "Organ des Zentralkomitees der Sozialistischen "
+                        + "Einheitspartei Deutschlands");
         assertNull(fd.getDocEditor());
         assertNull(fd.getDocAuthor());
-        
-        Krill ks = new Krill(
-            new QueryBuilder("tokens").
-            seg("mate/m:case:nom").
-            with("mate/m:number:sg")
-        );
+
+        Krill ks = new Krill(new QueryBuilder("tokens").seg("mate/m:case:nom")
+                .with("mate/m:number:sg"));
         Result kr = ks.apply(ki);
 
         assertEquals(kr.getTotalResults(), 6);
@@ -730,144 +621,98 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        FieldDocument fd = ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-	    );
+        FieldDocument fd = ki.addDoc(1,
+                getClass().getResourceAsStream("/bzk/D59-00089.json.gz"), true);
         ki.commit();
 
-        String json = getString(
-	        getClass().
-            getResource("/queries/bugs/cosmas_boundary.jsonld").
-            getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bugs/cosmas_boundary.jsonld").getFile());
 
         QueryBuilder kq = new QueryBuilder("tokens");
-        Krill ks = new Krill(
-            kq.focus(
-                1,
-                kq.contains(kq.tag("base/s:s"), kq._(1, kq.seg("s:Leben")))
-            )
-        );
+        Krill ks = new Krill(kq.focus(1,
+                kq.contains(kq.tag("base/s:s"), kq._(1, kq.seg("s:Leben")))));
 
         Result kr = ks.apply(ki);
+        assertEquals(kr.getSerialQuery(),
+                "focus(1: spanContain(<tokens:base/s:s />, {1: tokens:s:Leben}))");
         assertEquals(
-            kr.getSerialQuery(),
-            "focus(1: spanContain(<tokens:base/s:s />, {1: tokens:s:Leben}))"
-        );
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "... Initiative\" eine neue politische Gruppierung ins " +
-            "[{1:Leben}] gerufen hatten. Pressemeldungen zufolge haben sich ..."
-        );
+                kr.getMatch(0).getSnippetBrackets(),
+                "... Initiative\" eine neue politische Gruppierung ins "
+                        + "[{1:Leben}] gerufen hatten. Pressemeldungen zufolge haben sich ...");
 
         // Try with high class - don't highlight
-        ks = new Krill(
-            kq.focus(
-                129,
-                kq.contains(kq.tag("base/s:s"), kq._(129, kq.seg("s:Leben")))
-            )
-        );
+        ks = new Krill(kq.focus(129,
+                kq.contains(kq.tag("base/s:s"), kq._(129, kq.seg("s:Leben")))));
 
         kr = ks.apply(ki);
+        assertEquals(kr.getSerialQuery(),
+                "focus(129: spanContain(<tokens:base/s:s />, {129: tokens:s:Leben}))");
         assertEquals(
-            kr.getSerialQuery(),
-            "focus(129: spanContain(<tokens:base/s:s />, {129: tokens:s:Leben}))"
-        );
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "... Initiative\" eine neue politische Gruppierung ins " +
-            "[Leben] gerufen hatten. Pressemeldungen zufolge haben sich ..."
-        );
+                kr.getMatch(0).getSnippetBrackets(),
+                "... Initiative\" eine neue politische Gruppierung ins "
+                        + "[Leben] gerufen hatten. Pressemeldungen zufolge haben sich ...");
 
         ks = new Krill(json);
         kr = ks.apply(ki);
         assertEquals(
-            kr.getSerialQuery(),
-            "focus(129: spanElementDistance({129: tokens:s:Namen}, " +
-            "{129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))"
-        );
+                kr.getSerialQuery(),
+                "focus(129: spanElementDistance({129: tokens:s:Namen}, "
+                        + "{129: tokens:s:Leben}, [(base/s:s[0:1], notOrdered, notExcluded)]))");
         assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "... ihren Austritt erklärt und unter dem [Namen \"Einheitsbewegung " +
-            "der sozialistischen Initiative\" eine neue politische Gruppierung " +
-            "ins Leben] gerufen hatten. Pressemeldungen zufolge haben sich ..."
-        );
+                kr.getMatch(0).getSnippetBrackets(),
+                "... ihren Austritt erklärt und unter dem [Namen \"Einheitsbewegung "
+                        + "der sozialistischen Initiative\" eine neue politische Gruppierung "
+                        + "ins Leben] gerufen hatten. Pressemeldungen zufolge haben sich ...");
         assertEquals(kr.getTotalResults(), 1);
         assertEquals(0, kr.getStartIndex());
     };
 
+
     @Test
     public void searchJSONmultipleClassesBug () throws IOException {
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-        );
-        ki.addDoc(
-            2,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-        );
+        ki.addDoc(1, getClass().getResourceAsStream("/bzk/D59-00089.json.gz"),
+                true);
+        ki.addDoc(2, getClass().getResourceAsStream("/bzk/D59-00089.json.gz"),
+                true);
 
         ki.commit();
 
-        String json = getString(
-            getClass().
-            getResource("/queries/bugs/multiple_classes.jsonld").
-            getFile()
-        );
-	
+        String json = getString(getClass().getResource(
+                "/queries/bugs/multiple_classes.jsonld").getFile());
+
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
+        assertEquals(kr.getSerialQuery(),
+                "{4: spanNext({1: spanNext({2: tokens:s:ins}, "
+                        + "{3: tokens:s:Leben})}, tokens:s:gerufen)}");
         assertEquals(
-            kr.getSerialQuery(),
-            "{4: spanNext({1: spanNext({2: tokens:s:ins}, "+
-            "{3: tokens:s:Leben})}, tokens:s:gerufen)}"
-        );
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "... sozialistischen Initiative\" eine neue politische"+
-            " Gruppierung [{4:{1:{2:ins} {3:Leben}} gerufen}] hatten. " +
-            "Pressemeldungen zufolge haben sich in ..."
-        );
+                kr.getMatch(0).getSnippetBrackets(),
+                "... sozialistischen Initiative\" eine neue politische"
+                        + " Gruppierung [{4:{1:{2:ins} {3:Leben}} gerufen}] hatten. "
+                        + "Pressemeldungen zufolge haben sich in ...");
         assertEquals(kr.getTotalResults(), 2);
         assertEquals(0, kr.getStartIndex());
     };
 
+
     @Test
     public void searchJSONmultipleClassesBugTokenList () throws IOException {
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/goe/AGA-03828.json.gz"),
-            true
-        );
-        ki.addDoc(
-            2,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-        );
+        ki.addDoc(1, getClass().getResourceAsStream("/goe/AGA-03828.json.gz"),
+                true);
+        ki.addDoc(2, getClass().getResourceAsStream("/bzk/D59-00089.json.gz"),
+                true);
 
         ki.commit();
 
-        String json = getString(
-            getClass().
-            getResource("/queries/bugs/multiple_classes.jsonld").
-            getFile()
-        );
-	
+        String json = getString(getClass().getResource(
+                "/queries/bugs/multiple_classes.jsonld").getFile());
+
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
 
@@ -875,10 +720,9 @@
         JsonNode res = mapper.readTree(kr.toTokenListJsonString());
 
         assertEquals(1, res.at("/totalResults").asInt());
-        assertEquals(
-            "{4: spanNext({1: spanNext({2: tokens:s:ins}, " +
-            "{3: tokens:s:Leben})}, tokens:s:gerufen)}",
-            res.at("/serialQuery").asText());
+        assertEquals("{4: spanNext({1: spanNext({2: tokens:s:ins}, "
+                + "{3: tokens:s:Leben})}, tokens:s:gerufen)}",
+                res.at("/serialQuery").asText());
         assertEquals(0, res.at("/startIndex").asInt());
         assertEquals(25, res.at("/itemsPerPage").asInt());
 
@@ -900,24 +744,17 @@
         assertEquals(ki.numberOf("documents"), 0);
 
         // Indexing test files
-        FieldDocument fd = ki.addDoc(
-            1,
-            getClass().
-            getResourceAsStream("/bzk/D59-00089.json.gz"),
-            true
-        );
+        FieldDocument fd = ki.addDoc(1,
+                getClass().getResourceAsStream("/bzk/D59-00089.json.gz"), true);
         ki.commit();
 
         assertEquals(ki.numberOf("documents"), 1);
         assertEquals("BZK", fd.getCorpusSigle());
 
         // [tt/p="A.*"]{0,3}[tt/p="N.*"]
-        String json = getString(
-            getClass().
-            getResource("/queries/bugs/multiterm_rewrite.jsonld").
-            getFile()
-        );
-	
+        String json = getString(getClass().getResource(
+                "/queries/bugs/multiterm_rewrite.jsonld").getFile());
+
         Krill ks = new Krill(json);
         KrillCollection kc = ks.getCollection();
 
@@ -928,50 +765,36 @@
         // Index was set but vc restricted to WPD
         assertEquals(0, kc.numberOf("documents"));
 
-        kc.extend(
-            new CollectionBuilder().or("corpusSigle", "BZK")
-        );
+        kc.extend(new CollectionBuilder().or("corpusSigle", "BZK"));
         ks.setCollection(kc);
         assertEquals(1, kc.numberOf("documents"));
 
         Result kr = ks.apply(ki);
-        
-        assertEquals(
-            kr.getSerialQuery(),
-            "spanOr([SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/), " +
-            "spanNext(spanRepetition(SpanMultiTermQueryWrapper"+
-            "(tokens:/tt/p:A.*/){1,3}), " +
-            "SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/))])"
-        );
+
+        assertEquals(kr.getSerialQuery(),
+                "spanOr([SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/), "
+                        + "spanNext(spanRepetition(SpanMultiTermQueryWrapper"
+                        + "(tokens:/tt/p:A.*/){1,3}), "
+                        + "SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/))])");
 
         assertEquals(kr.getTotalResults(), 58);
         assertEquals(0, kr.getStartIndex());
 
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "[Saragat-Partei] zerfällt Rom (ADN) die von dem"
-        );
-        assertEquals(
-            kr.getMatch(1).getSnippetBrackets(),
-            "[Saragat-Partei] zerfällt Rom (ADN) die von dem"
-        );
-        assertEquals(
-            kr.getMatch(2).getSnippetBrackets(),
-            "Saragat-Partei zerfällt [Rom] (ADN) "+
-            "die von dem Rechtssozialisten Saragat"
-        );
-        assertEquals(
-            kr.getMatch(3).getSnippetBrackets(),
-            "Saragat-Partei zerfällt Rom ([ADN]) "+
-            "die von dem Rechtssozialisten Saragat geführte"
-        );
+        assertEquals(kr.getMatch(0).getSnippetBrackets(),
+                "[Saragat-Partei] zerfällt Rom (ADN) die von dem");
+        assertEquals(kr.getMatch(1).getSnippetBrackets(),
+                "[Saragat-Partei] zerfällt Rom (ADN) die von dem");
+        assertEquals(kr.getMatch(2).getSnippetBrackets(),
+                "Saragat-Partei zerfällt [Rom] (ADN) "
+                        + "die von dem Rechtssozialisten Saragat");
+        assertEquals(kr.getMatch(3).getSnippetBrackets(),
+                "Saragat-Partei zerfällt Rom ([ADN]) "
+                        + "die von dem Rechtssozialisten Saragat geführte");
 
-        assertEquals(
-            kr.getMatch(23).getSnippetBrackets(),
-            "dem Namen \"Einheitsbewegung der sozialistischen "+
-            "Initiative\" [eine neue politische Gruppierung] "+
-            "ins Leben gerufen hatten. Pressemeldungen zufolge"
-        );
+        assertEquals(kr.getMatch(23).getSnippetBrackets(),
+                "dem Namen \"Einheitsbewegung der sozialistischen "
+                        + "Initiative\" [eine neue politische Gruppierung] "
+                        + "ins Leben gerufen hatten. Pressemeldungen zufolge");
     };
 
 
@@ -980,38 +803,25 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().
-                getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
-        String json = getString(
-            getClass().
-            getResource("/queries/metaquery8-nocollection.jsonld").
-            getFile()
-        );
-	
+        String json = getString(getClass().getResource(
+                "/queries/metaquery8-nocollection.jsonld").getFile());
+
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
         assertEquals(kr.getTotalResults(), 276);
         assertEquals(0, kr.getStartIndex());
         assertEquals(10, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().
-            getResource("/queries/metaquery8.jsonld").
-            getFile()
-        );
-	
+        json = getString(getClass().getResource("/queries/metaquery8.jsonld")
+                .getFile());
+
         ks = new Krill(json);
         kr = ks.apply(ki);
 
@@ -1020,12 +830,9 @@
         assertEquals(0, kr.getStartIndex());
         assertEquals(10, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().
-            getResource("/queries/metaquery8-filtered.jsonld").
-            getFile()
-        );
-	
+        json = getString(getClass().getResource(
+                "/queries/metaquery8-filtered.jsonld").getFile());
+
         ks = new Krill(json);
         kr = ks.apply(ki);
 
@@ -1034,32 +841,26 @@
         assertEquals(0, kr.getStartIndex());
         assertEquals(10, kr.getItemsPerPage());
 
-        json = getString(
-            getClass().
-            getResource("/queries/metaquery8-filtered-further.jsonld").
-            getFile()
-        );
-	
+        json = getString(getClass().getResource(
+                "/queries/metaquery8-filtered-further.jsonld").getFile());
+
         ks = new Krill(json);
         kr = ks.apply(ki);
 
         assertEquals(kr.getTotalResults(), 0);
         assertEquals(0, kr.getStartIndex());
         assertEquals(10, kr.getItemsPerPage());
-        
-        json = getString(
-            getClass().
-            getResource("/queries/metaquery8-filtered-nested.jsonld").
-            getFile()
-        );
-	
+
+        json = getString(getClass().getResource(
+                "/queries/metaquery8-filtered-nested.jsonld").getFile());
+
         ks = new Krill(json);
         kr = ks.apply(ki);
 
-        assertEquals("filter with QueryWrapperFilter("+
-                     "+(ID:WPD_AAA.00003 (+tokens:s:die"+
-                     " +tokens:s:Schriftzeichen)))",
-                     ks.getCollection().getFilter(1).toString());
+        assertEquals("filter with QueryWrapperFilter("
+                + "+(ID:WPD_AAA.00003 (+tokens:s:die"
+                + " +tokens:s:Schriftzeichen)))",
+                ks.getCollection().getFilter(1).toString());
 
         assertEquals(kr.getTotalResults(), 119);
         assertEquals(0, kr.getStartIndex());
@@ -1072,66 +873,45 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().
-                getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().
-            getResource("/queries/bsp-context-2.jsonld").
-            getFile()
-        );
-	
+        String json = getString(getClass().getResource(
+                "/queries/bsp-context-2.jsonld").getFile());
+
         Krill ks = new Krill(json);
         ks.getMeta().setCutOff(false);
         SearchContext sc = ks.getMeta().getContext();
         sc.left.setLength((short) 10);
         sc.right.setLength((short) 10);
-        
+
         Result kr = ks.apply(ki);
-        assertEquals(
-            kr.getMatch(1).getSnippetBrackets(),
-            "... dezimalen [Wert] 65 sowohl ..."
-        );
+        assertEquals(kr.getMatch(1).getSnippetBrackets(),
+                "... dezimalen [Wert] 65 sowohl ...");
         assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getStartIndex());
         assertEquals(25, kr.getItemsPerPage());
         assertFalse(kr.getContext().toJsonNode().toString().equals("\"s\""));
 
-        json = getString(
-            getClass().
-            getResource("/queries/bsp-context-sentence.jsonld").
-            getFile()
-        );
+        json = getString(getClass().getResource(
+                "/queries/bsp-context-sentence.jsonld").getFile());
 
         kr = new Krill(json).apply(ki);
-        assertEquals(
-            kr.getMatch(0).getSnippetBrackets(),
-            "steht a für den dezimalen [Wert] 97 sowohl im ASCII-"+
-            " als auch im Unicode-Zeichensatz"
-        );
-        assertEquals(
-            kr.getMatch(1).getSnippetBrackets(),
-            "steht A für den dezimalen [Wert] 65 sowohl im ASCII-"+
-            " als auch im Unicode-Zeichensatz"
-        );
-        assertEquals(
-            kr.getMatch(2).getSnippetBrackets(),
-            "In einem Zahlensystem mit einer Basis größer "+
-            "als 10 steht A oder a häufig für den dezimalen"+
-            " [Wert] 10, siehe auch Hexadezimalsystem."
-        );
+        assertEquals(kr.getMatch(0).getSnippetBrackets(),
+                "steht a für den dezimalen [Wert] 97 sowohl im ASCII-"
+                        + " als auch im Unicode-Zeichensatz");
+        assertEquals(kr.getMatch(1).getSnippetBrackets(),
+                "steht A für den dezimalen [Wert] 65 sowohl im ASCII-"
+                        + " als auch im Unicode-Zeichensatz");
+        assertEquals(kr.getMatch(2).getSnippetBrackets(),
+                "In einem Zahlensystem mit einer Basis größer "
+                        + "als 10 steht A oder a häufig für den dezimalen"
+                        + " [Wert] 10, siehe auch Hexadezimalsystem.");
 
         assertEquals(kr.getContext().toJsonNode().toString(), "\"s\"");
     };
@@ -1142,33 +922,21 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().
-                getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String json = getString(
-            getClass().
-            getResource("/queries/bsp-bug.jsonld").
-            getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-bug.jsonld").getFile());
 
         Result kr = new Krill(json).apply(ki);
 
-        assertEquals(
-            kr.getError(0).getMessage(),
-            "Operation needs operand list"
-        );
+        assertEquals(kr.getError(0).getMessage(),
+                "Operation needs operand list");
     };
 
 
@@ -1177,92 +945,73 @@
      */
     @Test
     public void searchJSONexpansionBug () throws IOException {
-		// Construct index
-		KrillIndex ki = new KrillIndex();
-		// Indexing test files
-		ki.addDoc(
-            getClass().
-            getResourceAsStream("/wiki/00002.json.gz"),
-            true
-        );
-		ki.commit();
-	
-		// Expansion bug
-		// der alte Digraph Aa durch Å
-		String json = getString(
-            getClass().
-            getResource("/queries/bugs/expansion_bug_2.jsonld").
-            getFile()
-        );
-	
-		Result kr = new Krill(json).apply(ki);				
-		assertEquals("... Buchstabe des Alphabetes. In Dänemark ist " +
-                     "[der alte Digraph Aa durch Å] ersetzt worden, " +
-                     "in Eigennamen und Ortsnamen ...",
-                     kr.getMatch(0).getSnippetBrackets());
-		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(kr.getTotalResults(), 1);
-        
-		// der alte Digraph Aa durch []
-		// Works with one document
-		json = getString(
-            getClass().
-            getResource("/queries/bugs/expansion_bug.jsonld").
-            getFile()
-        );
-	
-		kr = new Krill(json).apply(ki);
-		
-		assertEquals("... Buchstabe des Alphabetes. In Dänemark ist " +
-                     "[der alte Digraph Aa durch Å] ersetzt worden, " +
-                     "in Eigennamen und Ortsnamen ...",
-                     kr.getMatch(0).getSnippetBrackets());
-		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(kr.getTotalResults(), 1);
-	
-		// Now try with one file ahead
-		ki = new KrillIndex();
-		for (String i : new String[] {"00001",
-                                      "00002"}) {
-		    ki.addDoc(
-                getClass().
-                getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
-		};
-		ki.commit();
-	
-		// Expansion bug
-		// der alte Digraph Aa durch Å
-		json = getString(
-            getClass().
-            getResource("/queries/bugs/expansion_bug_2.jsonld").
-            getFile()
-        );
-	
-		kr = new Krill(json).apply(ki);
-		
-		assertEquals("... Buchstabe des Alphabetes. In Dänemark ist " +
-                     "[der alte Digraph Aa durch Å] ersetzt worden, " +
-                     "in Eigennamen und Ortsnamen ...",
-                     kr.getMatch(0).getSnippetBrackets());
-		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(kr.getTotalResults(), 1);
-	
-		// der alte Digraph Aa durch []
-		json = getString(
-            getClass().
-            getResource("/queries/bugs/expansion_bug.jsonld").
-            getFile()
-        );
-	
-		kr = new Krill(json).apply(ki);	
-		assertEquals("... Buchstabe des Alphabetes. In Dänemark ist " +
-                     "[der alte Digraph Aa durch Å] ersetzt worden, " +
-                     "in Eigennamen und Ortsnamen ...",
-                     kr.getMatch(0).getSnippetBrackets());
-		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(kr.getTotalResults(), 1);
+        // Construct index
+        KrillIndex ki = new KrillIndex();
+        // Indexing test files
+        ki.addDoc(getClass().getResourceAsStream("/wiki/00002.json.gz"), true);
+        ki.commit();
+
+        // Expansion bug
+        // der alte Digraph Aa durch Å
+        String json = getString(getClass().getResource(
+                "/queries/bugs/expansion_bug_2.jsonld").getFile());
+
+        Result kr = new Krill(json).apply(ki);
+        assertEquals("... Buchstabe des Alphabetes. In Dänemark ist "
+                + "[der alte Digraph Aa durch Å] ersetzt worden, "
+                + "in Eigennamen und Ortsnamen ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
+        assertEquals(kr.getTotalResults(), 1);
+
+        // der alte Digraph Aa durch []
+        // Works with one document
+        json = getString(getClass().getResource(
+                "/queries/bugs/expansion_bug.jsonld").getFile());
+
+        kr = new Krill(json).apply(ki);
+
+        assertEquals("... Buchstabe des Alphabetes. In Dänemark ist "
+                + "[der alte Digraph Aa durch Å] ersetzt worden, "
+                + "in Eigennamen und Ortsnamen ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
+        assertEquals(kr.getTotalResults(), 1);
+
+        // Now try with one file ahead
+        ki = new KrillIndex();
+        for (String i : new String[] { "00001", "00002" }) {
+            ki.addDoc(
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
+        };
+        ki.commit();
+
+        // Expansion bug
+        // der alte Digraph Aa durch Å
+        json = getString(getClass().getResource(
+                "/queries/bugs/expansion_bug_2.jsonld").getFile());
+
+        kr = new Krill(json).apply(ki);
+
+        assertEquals("... Buchstabe des Alphabetes. In Dänemark ist "
+                + "[der alte Digraph Aa durch Å] ersetzt worden, "
+                + "in Eigennamen und Ortsnamen ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
+        assertEquals(kr.getTotalResults(), 1);
+
+        // der alte Digraph Aa durch []
+        json = getString(getClass().getResource(
+                "/queries/bugs/expansion_bug.jsonld").getFile());
+
+        kr = new Krill(json).apply(ki);
+        assertEquals("... Buchstabe des Alphabetes. In Dänemark ist "
+                + "[der alte Digraph Aa durch Å] ersetzt worden, "
+                + "in Eigennamen und Ortsnamen ...", kr.getMatch(0)
+                .getSnippetBrackets());
+        assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
+        assertEquals(kr.getTotalResults(), 1);
     };
 
 
@@ -1274,18 +1023,11 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"}) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
             ki.addDoc(
-                getClass().
-                getResourceAsStream("/wiki/" + i + ".json.gz"),
-                true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
@@ -1293,7 +1035,7 @@
 
         assertEquals(7, kc.numberOf("documents"));
 
-    	HashMap map = kc.getTermRelation("foundries");
+        HashMap map = kc.getTermRelation("foundries");
         assertEquals((long) 7, map.get("-docs"));
         assertEquals((long) 7, map.get("treetagger"));
         assertEquals((long) 6, map.get("opennlp/morpho"));
@@ -1305,50 +1047,35 @@
     @Test
     public void getTextClassDistribution () throws Exception {
         KrillIndex ki = new KrillIndex();
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music entertainment\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music entertainment\"" + "}");
 
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music singing\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music singing\"" + "}");
 
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music entertainment jumping\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music entertainment jumping\"" + "}");
         ki.commit();
 
         KrillCollection kc = new KrillCollection(ki);
         assertEquals(3, kc.numberOf("documents"));
 
-    	HashMap map = kc.getTermRelation("textClass");
+        HashMap map = kc.getTermRelation("textClass");
         assertEquals((long) 1, map.get("singing"));
         assertEquals((long) 1, map.get("jumping"));
         assertEquals((long) 3, map.get("music"));
@@ -1361,7 +1088,7 @@
         assertEquals((long) 1, map.get("#__jumping:###:music"));
         assertEquals((long) 1, map.get("#__music:###:singing"));
         assertEquals(11, map.size());
-        
+
         // System.err.println(kc.getTermRelationJSON("textClass"));
     };
 
@@ -1369,64 +1096,44 @@
     @Test
     public void getTextClassDistribution2 () throws Exception {
         KrillIndex ki = new KrillIndex();
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"\"" + "}");
         ki.commit();
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music entertainment\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music entertainment\"" + "}");
 
         ki.commit();
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music singing\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music singing\"" + "}");
 
-        ki.addDoc(
-"{" +
-"  \"fields\" : [" +
-"    { \"primaryData\" : \"abc\" },{" +
-"      \"name\" : \"tokens\"," +
-"      \"data\" : [" +
-"         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"]," +
-"         [ \"s:b\", \"i:b\", \"_1#1-2\" ]," +
-"         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}]," +
-"  \"textClass\" : \"music entertainment jumping\"" +
-"}"
-        );
+        ki.addDoc("{" + "  \"fields\" : ["
+                + "    { \"primaryData\" : \"abc\" },{"
+                + "      \"name\" : \"tokens\"," + "      \"data\" : ["
+                + "         [ \"s:a\", \"i:a\", \"_0#0-1\", \"-:t$<i>3\"],"
+                + "         [ \"s:b\", \"i:b\", \"_1#1-2\" ],"
+                + "         [ \"s:c\", \"i:c\", \"_2#2-3\" ]]}],"
+                + "  \"textClass\" : \"music entertainment jumping\"" + "}");
         ki.commit();
 
         KrillCollection kc = new KrillCollection(ki);
         assertEquals(4, kc.numberOf("documents"));
 
-    	HashMap map = kc.getTermRelation("textClass");
+        HashMap map = kc.getTermRelation("textClass");
         assertEquals((long) 1, map.get("singing"));
         assertEquals((long) 1, map.get("jumping"));
         assertEquals((long) 3, map.get("music"));
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index 70480b7..490148b 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -35,25 +35,23 @@
         // Construct index
         KrillIndex ki = new KrillIndex();
         // Indexing test files
-        for (String i : new String[] {"00001",
-                                      "00002"}) {
+        for (String i : new String[] { "00001", "00002" }) {
             ki.addDoc(
-                getClass().getResourceAsStream("/wiki/" + i + ".json.gz"), true
-            );
+                    getClass().getResourceAsStream("/wiki/" + i + ".json.gz"),
+                    true);
         };
         ki.commit();
 
-        String jsonString = getString(
-            getClass().getResource("/queries/metas/fields.jsonld").getFile()
-        );
-	
+        String jsonString = getString(getClass().getResource(
+                "/queries/metas/fields.jsonld").getFile());
+
         Krill ks = new Krill(jsonString);
 
         Result kr = ks.apply(ki);
         assertEquals((long) 17, kr.getTotalResults());
         assertEquals(0, kr.getStartIndex());
         assertEquals(9, kr.getItemsPerPage());
-        
+
         ObjectMapper mapper = new ObjectMapper();
         JsonNode res = mapper.readTree(kr.toJsonString());
         assertEquals(0, res.at("/matches/0/UID").asInt());
@@ -71,24 +69,25 @@
         assertEquals("", res.at("/matches/0/layerInfo").asText());
         assertEquals("", res.at("/matches/0/tokenization").asText());
 
-        jsonString = getString(
-            getClass().getResource("/queries/metas/fields_2.jsonld").getFile()
-        );
+        jsonString = getString(getClass().getResource(
+                "/queries/metas/fields_2.jsonld").getFile());
         ks = new Krill(jsonString);
         kr = ks.apply(ki);
         assertEquals((long) 17, kr.getTotalResults());
         assertEquals(0, kr.getStartIndex());
         assertEquals(2, kr.getItemsPerPage());
-        
+
         mapper = new ObjectMapper();
         res = mapper.readTree(kr.toJsonString());
         assertEquals(0, res.at("/matches/0/UID").asInt());
         assertEquals("", res.at("/matches/0/corpusID").asText());
-        assertEquals("Ruru,Jens.Ol,Aglarech", res.at("/matches/0/author").asText());
+        assertEquals("Ruru,Jens.Ol,Aglarech", res.at("/matches/0/author")
+                .asText());
         assertEquals("A", res.at("/matches/0/title").asText());
         assertEquals("WPD_AAA.00001", res.at("/matches/0/docID").asText());
         assertEquals("", res.at("/matches/0/textSigle").asText());
-        assertEquals("match-WPD_AAA.00001-p6-7", res.at("/matches/0/ID").asText());
+        assertEquals("match-WPD_AAA.00001-p6-7", res.at("/matches/0/ID")
+                .asText());
         assertEquals("", res.at("/matches/0/subTitle").asText());
         assertEquals("", res.at("/matches/0/textClass").asText());
         assertEquals("", res.at("/matches/0/pubPlace").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestResult.java b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
index cce192d..dd391e3 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestResult.java
@@ -1,4 +1,3 @@
-
 package de.ids_mannheim.korap.search;
 
 import java.util.*;
@@ -31,35 +30,28 @@
 public class TestResult {
 
     @Test
-    public void checkJSONResult () throws Exception  {
+    public void checkJSONResult () throws Exception {
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addString("UID", "1");
-        fd.addTV("base",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("base", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addString("UID", "2");
-        fd.addTV("base",
-                 "aba",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]");
+        fd.addTV("base", "aba", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]");
         ki.addDoc(fd);
 
         // Commit!
         ki.commit();
 
         QueryBuilder kq = new QueryBuilder("base");
-        SpanQuery q = (SpanQuery) kq.or(
-            kq._(1, kq.seg("s:a"))).or(kq._(2, kq.seg("s:b"))
-        ).toQuery();
+        SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a")))
+                .or(kq._(2, kq.seg("s:b"))).toQuery();
         Result kr = ki.search(q);
         assertEquals((long) 7, kr.getTotalResults());
 
@@ -67,7 +59,7 @@
         JsonNode res = mapper.readTree(kr.toJsonString());
         assertEquals(7, res.at("/totalResults").asInt());
         assertEquals("spanOr([{1: base:s:a}, {2: base:s:b}])",
-                     res.at("/serialQuery").asText());
+                res.at("/serialQuery").asText());
         assertEquals(0, res.at("/startIndex").asInt());
         assertEquals(25, res.at("/itemsPerPage").asInt());
         assertEquals("token", res.at("/context/left/0").asText());
@@ -84,7 +76,9 @@
         assertEquals(1, res.at("/matches/0/UID").asInt());
         assertEquals("doc-1", res.at("/matches/0/docID").asText());
         assertEquals("match-doc-1-p0-1(1)0-0", res.at("/matches/0/ID").asText());
-        assertEquals("<span class=\"context-left\"></span><mark><mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\">bab</span>", res.at("/matches/0/snippet").asText());
+        assertEquals(
+                "<span class=\"context-left\"></span><mark><mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\">bab</span>",
+                res.at("/matches/0/snippet").asText());
 
         assertEquals("base", res.at("/matches/6/field").asText());
         /*
@@ -95,25 +89,26 @@
         assertEquals(2, res.at("/matches/6/UID").asInt());
         assertEquals("doc-2", res.at("/matches/6/docID").asText());
         assertEquals("match-doc-2-p2-3(1)2-2", res.at("/matches/6/ID").asText());
-        assertEquals("<span class=\"context-left\">ab</span><mark><mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\"></span>", res.at("/matches/6/snippet").asText());
+        assertEquals(
+                "<span class=\"context-left\">ab</span><mark><mark class=\"class-1 level-0\">a</mark></mark><span class=\"context-right\"></span>",
+                res.at("/matches/6/snippet").asText());
     };
 
+
     @Test
-    public void checkJSONResultWarningBug () throws Exception  {
+    public void checkJSONResultWarningBug () throws Exception {
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addString("UID", "1");
-        fd.addTV("tokens",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("tokens", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
         ki.commit();
 
-        String json = getString(getClass().getResource("/queries/bugs/optionality_warning.jsonld").getFile());
+        String json = getString(getClass().getResource(
+                "/queries/bugs/optionality_warning.jsonld").getFile());
         Krill ks = new Krill(json);
 
         Result kr = ks.apply(ki);
@@ -124,40 +119,33 @@
 
         // Old:
         // assertEquals("Optionality of query is ignored", res.at("/warning").asText());
-        assertEquals("Optionality of query is ignored",
-                     res.at("/warnings/0/1").asText());
+        assertEquals("Optionality of query is ignored", res.at("/warnings/0/1")
+                .asText());
     };
 
 
     @Test
-    public void checkJSONResultForJSONInput () throws Exception  {
+    public void checkJSONResultForJSONInput () throws Exception {
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addString("UID", "1");
-        fd.addTV("tokens",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("tokens", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addString("UID", "2");
-        fd.addTV("tokens",
-                 "aba",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]");
+        fd.addTV("tokens", "aba", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]");
         ki.addDoc(fd);
-    
+
         // Commit!
         ki.commit();
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-result-check.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-result-check.jsonld").getFile());
         Krill ks = new Krill(json);
         Result kr = ks.apply(ki);
         assertEquals((long) 7, kr.getTotalResults());
@@ -166,7 +154,8 @@
         JsonNode res = mapper.readTree(kr.toJsonString());
 
         assertEquals(7, res.at("/totalResults").asInt());
-        assertEquals("spanOr([tokens:s:a, tokens:s:b])", res.at("/serialQuery").asText());
+        assertEquals("spanOr([tokens:s:a, tokens:s:b])", res.at("/serialQuery")
+                .asText());
         assertEquals(5, res.at("/itemsPerPage").asInt());
         assertEquals(0, res.at("/startIndex").asInt());
         assertEquals(1, res.at("/request/meta/startPage").asInt());
@@ -177,61 +166,69 @@
         assertEquals(6, res.at("/request/meta/context/right/1").asInt());
 
         assertEquals("koral:group", res.at("/request/query/@type").asText());
-        assertEquals("operation:or", res.at("/request/query/operation").asText());
+        assertEquals("operation:or", res.at("/request/query/operation")
+                .asText());
 
-        assertEquals("koral:token", res.at("/request/query/operands/0/@type").asText());
-        assertEquals("koral:term", res.at("/request/query/operands/0/wrap/@type").asText());
-        assertEquals("orth", res.at("/request/query/operands/0/wrap/layer").asText());
+        assertEquals("koral:token", res.at("/request/query/operands/0/@type")
+                .asText());
+        assertEquals("koral:term",
+                res.at("/request/query/operands/0/wrap/@type").asText());
+        assertEquals("orth", res.at("/request/query/operands/0/wrap/layer")
+                .asText());
         assertEquals("a", res.at("/request/query/operands/0/wrap/key").asText());
-        assertEquals("match:eq", res.at("/request/query/operands/0/wrap/match").asText());
+        assertEquals("match:eq", res.at("/request/query/operands/0/wrap/match")
+                .asText());
 
-        assertEquals("koral:token", res.at("/request/query/operands/1/@type").asText());
-        assertEquals("koral:term", res.at("/request/query/operands/1/wrap/@type").asText());
-        assertEquals("orth", res.at("/request/query/operands/1/wrap/layer").asText());
+        assertEquals("koral:token", res.at("/request/query/operands/1/@type")
+                .asText());
+        assertEquals("koral:term",
+                res.at("/request/query/operands/1/wrap/@type").asText());
+        assertEquals("orth", res.at("/request/query/operands/1/wrap/layer")
+                .asText());
         assertEquals("b", res.at("/request/query/operands/1/wrap/key").asText());
-        assertEquals("match:eq", res.at("/request/query/operands/1/wrap/match").asText());
+        assertEquals("match:eq", res.at("/request/query/operands/1/wrap/match")
+                .asText());
 
         assertEquals(1, res.at("/matches/0/UID").asInt());
         assertEquals("doc-1", res.at("/matches/0/docID").asText());
         assertEquals("match-doc-1-p0-1", res.at("/matches/0/ID").asText());
-        assertEquals("<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\">bab</span>", res.at("/matches/0/snippet").asText());
+        assertEquals(
+                "<span class=\"context-left\"></span><mark>a</mark><span class=\"context-right\">bab</span>",
+                res.at("/matches/0/snippet").asText());
     };
 
+
     @Test
-    public void checkJSONTokenResult () throws Exception  {
+    public void checkJSONTokenResult () throws Exception {
         KrillIndex ki = new KrillIndex();
         FieldDocument fd = new FieldDocument();
         fd.addString("ID", "doc-1");
         fd.addString("UID", "1");
-        fd.addTV("base",
-                 "abab",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]" +
-                 "[(3-4)s:b|i:a|_3#3-4]");
+        fd.addTV("base", "abab", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>4]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]"
+                + "[(3-4)s:b|i:a|_3#3-4]");
         ki.addDoc(fd);
         fd = new FieldDocument();
         fd.addString("ID", "doc-2");
         fd.addString("UID", "2");
-        fd.addTV("base",
-                 "aba",
-                 "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]" +
-                 "[(1-2)s:b|i:b|_1#1-2]" +
-                 "[(2-3)s:a|i:c|_2#2-3]");
+        fd.addTV("base", "aba", "[(0-1)s:a|i:a|_0#0-1|-:t$<i>3]"
+                + "[(1-2)s:b|i:b|_1#1-2]" + "[(2-3)s:a|i:c|_2#2-3]");
         ki.addDoc(fd);
-        
+
         // Commit!
         ki.commit();
 
         QueryBuilder kq = new QueryBuilder("base");
-        SpanQuery q = (SpanQuery) kq.seq(kq.seg("s:a")).append(kq.seg("s:b")).toQuery();
+        SpanQuery q = (SpanQuery) kq.seq(kq.seg("s:a")).append(kq.seg("s:b"))
+                .toQuery();
         Result kr = ki.search(q);
 
         assertEquals((long) 3, kr.getTotalResults());
         ObjectMapper mapper = new ObjectMapper();
         JsonNode res = mapper.readTree(kr.toTokenListJsonString());
         assertEquals(3, res.at("/totalResults").asInt());
-        assertEquals("spanNext(base:s:a, base:s:b)", res.at("/serialQuery").asText());
+        assertEquals("spanNext(base:s:a, base:s:b)", res.at("/serialQuery")
+                .asText());
         assertEquals(0, res.at("/startIndex").asInt());
         assertEquals(25, res.at("/itemsPerPage").asInt());
 
@@ -253,7 +250,8 @@
         assertEquals(1, res.at("/matches/2/tokens/1/0").asInt());
         assertEquals(2, res.at("/matches/2/tokens/1/1").asInt());
     };
-    
+
+
     public static String getString (String path) {
         StringBuilder contentBuilder = new StringBuilder();
         try {
@@ -263,7 +261,8 @@
                 contentBuilder.append(str);
             };
             in.close();
-        } catch (IOException e) {
+        }
+        catch (IOException e) {
             fail(e.getMessage());
         }
         return contentBuilder.toString();
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java b/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
index e86e2c1..36dfac2 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestDatabase.java
@@ -23,8 +23,9 @@
     private Connection conn;
     private Statement stat;
 
+
     @Before
-    public void setUp() throws Exception {
+    public void setUp () throws Exception {
         Class.forName("org.sqlite.JDBC");
         conn = DriverManager.getConnection("jdbc:sqlite::memory:");
         this.stat = conn.createStatement();
@@ -32,38 +33,39 @@
         conn.setAutoCommit(false);
     };
 
+
     @Test
     public void TestDatabase () throws Exception {
-	PreparedStatement prep = this.conn.prepareStatement(
-	  "INSERT INTO people VALUES (?, ?);"
-        );
+        PreparedStatement prep = this.conn
+                .prepareStatement("INSERT INTO people VALUES (?, ?);");
 
-	prep.setString(1, "Peter");
-	prep.setString(2, "24");
-	prep.addBatch();
+        prep.setString(1, "Peter");
+        prep.setString(2, "24");
+        prep.addBatch();
 
-	prep.setString(1, "Klaus");
-	prep.setString(2, "31");
-	prep.addBatch();
+        prep.setString(1, "Klaus");
+        prep.setString(2, "31");
+        prep.addBatch();
 
-	prep.executeBatch();
-	conn.setAutoCommit(true);
+        prep.executeBatch();
+        conn.setAutoCommit(true);
 
-	ResultSet rs = stat.executeQuery("SELECT * FROM people;");
+        ResultSet rs = stat.executeQuery("SELECT * FROM people;");
 
-	rs.next();
-	
-	assertEquals(rs.getString("name"), "Peter");
-	assertEquals(rs.getInt("age"), 24);
+        rs.next();
 
-	rs.next();
+        assertEquals(rs.getString("name"), "Peter");
+        assertEquals(rs.getInt("age"), 24);
 
-	assertEquals(rs.getString("name"), "Klaus");
-	assertEquals(rs.getInt("age"), 31);
+        rs.next();
 
-	rs.close();
+        assertEquals(rs.getString("name"), "Klaus");
+        assertEquals(rs.getInt("age"), 31);
+
+        rs.close();
     };
 
+
     /*
      * The following tests don't work well with in-memory dbs and
      * temporary dbs - should be improved
@@ -71,143 +73,142 @@
 
     @Test
     public void TestDatabasePool () throws Exception {
-	ComboPooledDataSource cpds = new ComboPooledDataSource();
-	// Connect to a temporary file instead of a in-memory file
-	cpds.setDriverClass("org.sqlite.JDBC");
-	cpds.setJdbcUrl("jdbc:sqlite:");
-	cpds.setMaxStatements(100);
+        ComboPooledDataSource cpds = new ComboPooledDataSource();
+        // Connect to a temporary file instead of a in-memory file
+        cpds.setDriverClass("org.sqlite.JDBC");
+        cpds.setJdbcUrl("jdbc:sqlite:");
+        cpds.setMaxStatements(100);
 
-	// This is part of the match collector
-	this.conn = cpds.getConnection();
-	conn.setAutoCommit(false);
-	this.stat = conn.createStatement();
-	stat.executeUpdate(
-            "CREATE TABLE IF NOT EXISTS result_a (text_id INTEGER, match_count INTEGER);"
-	);
-	// conn.setAutoCommit(false);
-	PreparedStatement prep = this.conn.prepareStatement(
-	  "INSERT INTO result_a VALUES (?, ?);"
-        );
-	prep.setInt(1, 5);
-	prep.setInt(2, 8000);
-	prep.addBatch();
-	prep.executeBatch();
+        // This is part of the match collector
+        this.conn = cpds.getConnection();
+        conn.setAutoCommit(false);
+        this.stat = conn.createStatement();
+        stat.executeUpdate("CREATE TABLE IF NOT EXISTS result_a (text_id INTEGER, match_count INTEGER);");
+        // conn.setAutoCommit(false);
+        PreparedStatement prep = this.conn
+                .prepareStatement("INSERT INTO result_a VALUES (?, ?);");
+        prep.setInt(1, 5);
+        prep.setInt(2, 8000);
+        prep.addBatch();
+        prep.executeBatch();
 
-	ResultSet rs = stat.executeQuery("SELECT * FROM result_a;");
-	rs.next();
-	assertEquals(rs.getInt("text_id"), 5);
-	assertEquals(rs.getInt("match_count"), 8000);
-	rs.close();
+        ResultSet rs = stat.executeQuery("SELECT * FROM result_a;");
+        rs.next();
+        assertEquals(rs.getInt("text_id"), 5);
+        assertEquals(rs.getInt("match_count"), 8000);
+        rs.close();
 
-	MatchCollectorDB mc = new MatchCollectorDB(2000, "result_a");
-	mc.setDBPool("sqlite", cpds, this.conn);
+        MatchCollectorDB mc = new MatchCollectorDB(2000, "result_a");
+        mc.setDBPool("sqlite", cpds, this.conn);
 
-	mc.add(9, 5000);
-	mc.add(12, 6785);
-	mc.add(39, 56576);
+        mc.add(9, 5000);
+        mc.add(12, 6785);
+        mc.add(39, 56576);
 
-	mc.close(false);
+        mc.close(false);
 
-	rs = stat.executeQuery("SELECT * FROM result_a;");
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 5);
-	assertEquals(rs.getInt("match_count"), 8000);
-	rs.next();
-	assertEquals(rs.getInt("text_id"), 9);
-	assertEquals(rs.getInt("match_count"), 5000);
-	rs.next();
-	assertEquals(rs.getInt("text_id"), 12);
-	assertEquals(rs.getInt("match_count"), 6785);
-	rs.next();
-	assertEquals(rs.getInt("text_id"), 39);
-	assertEquals(rs.getInt("match_count"), 56576);
-	
-	rs.close();
+        rs = stat.executeQuery("SELECT * FROM result_a;");
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 5);
+        assertEquals(rs.getInt("match_count"), 8000);
+        rs.next();
+        assertEquals(rs.getInt("text_id"), 9);
+        assertEquals(rs.getInt("match_count"), 5000);
+        rs.next();
+        assertEquals(rs.getInt("text_id"), 12);
+        assertEquals(rs.getInt("match_count"), 6785);
+        rs.next();
+        assertEquals(rs.getInt("text_id"), 39);
+        assertEquals(rs.getInt("match_count"), 56576);
+
+        rs.close();
     };
 
+
     @Test
     public void TestDatabasePoolCollector () throws Exception {
-	ComboPooledDataSource cpds = new ComboPooledDataSource();
-	// Connect to a temporary file instead of a in-memory file
-	cpds.setDriverClass("org.sqlite.JDBC");
-	cpds.setJdbcUrl("jdbc:sqlite:");
-	cpds.setMaxStatements(100);
+        ComboPooledDataSource cpds = new ComboPooledDataSource();
+        // Connect to a temporary file instead of a in-memory file
+        cpds.setDriverClass("org.sqlite.JDBC");
+        cpds.setJdbcUrl("jdbc:sqlite:");
+        cpds.setMaxStatements(100);
 
-	// This is part of the match collector
-	conn = cpds.getConnection();
-	conn.setAutoCommit(false);
-	Statement stat = conn.createStatement();
-	stat.executeUpdate(
-            "CREATE TABLE IF NOT EXISTS matchXYZ (text_id INTEGER, match_count INTEGER);"
-	);
-	conn.commit();
-	stat.close();
+        // This is part of the match collector
+        conn = cpds.getConnection();
+        conn.setAutoCommit(false);
+        Statement stat = conn.createStatement();
+        stat.executeUpdate("CREATE TABLE IF NOT EXISTS matchXYZ (text_id INTEGER, match_count INTEGER);");
+        conn.commit();
+        stat.close();
 
-	MatchCollectorDB mc = new MatchCollectorDB(3, "matchXYZ");
-	mc.setDBPool("sqlite", cpds, conn);
+        MatchCollectorDB mc = new MatchCollectorDB(3, "matchXYZ");
+        mc.setDBPool("sqlite", cpds, conn);
 
-	mc.add(9, 5000);
-	mc.add(12, 6785);
-	mc.add(39, 56576);
-	// First commit
+        mc.add(9, 5000);
+        mc.add(12, 6785);
+        mc.add(39, 56576);
+        // First commit
 
-	mc.add(45, 5000);
-	mc.add(67, 6785);
-	mc.add(81, 56576);
-	// Second commit
+        mc.add(45, 5000);
+        mc.add(67, 6785);
+        mc.add(81, 56576);
+        // Second commit
 
-	mc.add(94, 456);
-	mc.close(false);
-	// Final commit
+        mc.add(94, 456);
+        mc.close(false);
+        // Final commit
 
-	// conn = cpds.getConnection();
-	stat = conn.createStatement();
-	ResultSet rs = stat.executeQuery("SELECT count('*') AS num FROM matchXYZ;");
+        // conn = cpds.getConnection();
+        stat = conn.createStatement();
+        ResultSet rs = stat
+                .executeQuery("SELECT count('*') AS num FROM matchXYZ;");
 
-	assertEquals(7, rs.getInt("num"));
+        assertEquals(7, rs.getInt("num"));
 
-	rs = stat.executeQuery("SELECT text_id, match_count FROM matchXYZ;");
-	assertTrue(rs.next());
+        rs = stat.executeQuery("SELECT text_id, match_count FROM matchXYZ;");
+        assertTrue(rs.next());
 
-	assertEquals(rs.getInt("text_id"), 9);
-	assertEquals(rs.getInt("match_count"), 5000);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 12);
-	assertEquals(rs.getInt("match_count"), 6785);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 39);
-	assertEquals(rs.getInt("match_count"), 56576);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 45);
-	assertEquals(rs.getInt("match_count"), 5000);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 67);
-	assertEquals(rs.getInt("match_count"), 6785);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 81);
-	assertEquals(rs.getInt("match_count"), 56576);
-	assertTrue(rs.next());
-	assertEquals(rs.getInt("text_id"), 94);
-	assertEquals(rs.getInt("match_count"), 456);
-	assertFalse(rs.next());
+        assertEquals(rs.getInt("text_id"), 9);
+        assertEquals(rs.getInt("match_count"), 5000);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 12);
+        assertEquals(rs.getInt("match_count"), 6785);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 39);
+        assertEquals(rs.getInt("match_count"), 56576);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 45);
+        assertEquals(rs.getInt("match_count"), 5000);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 67);
+        assertEquals(rs.getInt("match_count"), 6785);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 81);
+        assertEquals(rs.getInt("match_count"), 56576);
+        assertTrue(rs.next());
+        assertEquals(rs.getInt("text_id"), 94);
+        assertEquals(rs.getInt("match_count"), 456);
+        assertFalse(rs.next());
 
-	stat.close();
+        stat.close();
     };
 
+
     @Test
     public void TestMatchCollectorDB () throws Exception {
-	MatchCollector mc = new MatchCollectorDB(2000, "matchXYZ");
-	mc.add(5,7);
-	mc.add(8,2);
-	mc.add(9,10);
-	mc.add(16,90);
-	mc.commit();
-	assertEquals(mc.getTotalResults(), 109);
-	assertEquals(mc.getTotalResultDocs(), 4);
+        MatchCollector mc = new MatchCollectorDB(2000, "matchXYZ");
+        mc.add(5, 7);
+        mc.add(8, 2);
+        mc.add(9, 10);
+        mc.add(16, 90);
+        mc.commit();
+        assertEquals(mc.getTotalResults(), 109);
+        assertEquals(mc.getTotalResultDocs(), 4);
     };
 
+
     @After
     public void shutDown () throws Exception {
-	this.conn.close();
+        this.conn.close();
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/server/TestResource.java b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
index 0593b02..b69fb31 100644
--- a/src/test/java/de/ids_mannheim/korap/server/TestResource.java
+++ b/src/test/java/de/ids_mannheim/korap/server/TestResource.java
@@ -34,6 +34,7 @@
     private HttpServer server;
     private WebTarget target;
 
+
     @Before
     public void setUp () throws Exception {
         // start the server
@@ -55,17 +56,20 @@
         ClientConfig clientConfig = new DefaultClientConfig();
         clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
         Client c = Client.create(clientConfig);
-*/
+        */
         target = c.target(Node.BASE_URI);
     };
 
+
     @After
-    public void tearDown() throws Exception {
+    public void tearDown () throws Exception {
         server.stop();
     };
 
+
     /**
-     * Test to see that the message "Gimme 5 minutes, please!" is sent in the response.
+     * Test to see that the message "Gimme 5 minutes, please!" is sent
+     * in the response.
      */
     @Test
     public void testPing () {
@@ -73,29 +77,22 @@
         assertEquals("Gimme 5 minutes, please!", responseMsg);
     };
 
+
     @Ignore
-    public void testResource() throws IOException {
+    public void testResource () throws IOException {
         Response kresp;
 
-        for (String i : new String[] {"00001",
-                                      "00002",
-                                      "00003",
-                                      "00004",
-                                      "00005",
-                                      "00006",
-                                      "02439"
-            }) {
+        for (String i : new String[] { "00001", "00002", "00003", "00004",
+                "00005", "00006", "02439" }) {
 
-            String json = StringfromFile(
-                getClass().getResource("/wiki/" + i + ".json").getFile()
-            );
+            String json = StringfromFile(getClass().getResource(
+                    "/wiki/" + i + ".json").getFile());
 
             Entity jsonE = Entity.json(json);
 
             try {
-                kresp = target.path("/index/" + i).
-                    request("application/json").
-                    put(jsonE, Response.class);
+                kresp = target.path("/index/" + i).request("application/json")
+                        .put(jsonE, Response.class);
 
                 assertEquals(kresp.getNode(), "milena");
                 assertFalse(kresp.hasErrors());
@@ -103,13 +100,13 @@
                 assertFalse(kresp.hasMessages());
             }
             catch (Exception e) {
-                fail("Server response failed " + e.getMessage() + " (Known issue)");
+                fail("Server response failed " + e.getMessage()
+                        + " (Known issue)");
             }
         };
 
-        kresp = target.path("/index").
-            request("application/json").
-            post(Entity.text(""), Response.class);
+        kresp = target.path("/index").request("application/json")
+                .post(Entity.text(""), Response.class);
         assertEquals(kresp.getNode(), "milena");
         assertFalse(kresp.hasErrors());
         assertFalse(kresp.hasWarnings());
@@ -118,19 +115,15 @@
 
 
     @Ignore
-    public void testCollection() throws IOException {
+    public void testCollection () throws IOException {
 
-        String json = getString(
-            getClass().getResource("/queries/bsp-uid-example.jsonld").getFile()
-        );
+        String json = getString(getClass().getResource(
+                "/queries/bsp-uid-example.jsonld").getFile());
 
         try {
-            Response kresp
-                = target.path("/").
-                queryParam("uid", "1").
-                queryParam("uid", "4").
-                request("application/json").
-                post(Entity.json(json), Response.class);
+            Response kresp = target.path("/").queryParam("uid", "1")
+                    .queryParam("uid", "4").request("application/json")
+                    .post(Entity.json(json), Response.class);
 
             assertEquals(2, kresp.getTotalResults());
             assertFalse(kresp.hasErrors());
@@ -143,6 +136,7 @@
 
     };
 
+
     public static String getString (String path) {
         StringBuilder contentBuilder = new StringBuilder();
         try {
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillArray.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillArray.java
index b42774b..f145e07 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillArray.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillArray.java
@@ -17,20 +17,23 @@
 
     @Test
     public void StringJoin1 () {
-        String[] test = new String[]{"a", "bc", "def"};
+        String[] test = new String[] { "a", "bc", "def" };
         assertEquals(join(",", test), "a,bc,def");
     };
 
+
     @Test
     public void StringJoin2 () {
         assertEquals(join(",", "a", "bc", "def"), "a,bc,def");
     };
 
+
     @Test
     public void StringJoin3 () {
         assertEquals(join(',', "a", "bc", "def"), "a,bc,def");
     };
 
+
     @Test
     public void StringJoin4 () {
         assertEquals(join("--", "a", "bc", "def"), "a--bc--def");
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillByte.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillByte.java
index 5cff981..2237964 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillByte.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillByte.java
@@ -13,27 +13,24 @@
 public class TestKrillByte {
 
     @Test
-    public void testConversion() {
+    public void testConversion () {
         assertEquals(4, byte2int(int2byte(4)));
-        assertEquals(
-            byte2int(ByteBuffer.allocate(4).putInt(4).array()),
-            byte2int(int2byte(4))
-        );
+        assertEquals(byte2int(ByteBuffer.allocate(4).putInt(4).array()),
+                byte2int(int2byte(4)));
 
-        assertEquals(
-            byte2int(ByteBuffer.allocate(4).putInt(99999).array()),
-            byte2int(int2byte(99999))
-        );
+        assertEquals(byte2int(ByteBuffer.allocate(4).putInt(99999).array()),
+                byte2int(int2byte(99999)));
 
         assertEquals(128, byte2int(int2byte(128)));
         assertEquals(1024, byte2int(int2byte(1024)));
         assertEquals(66_666, byte2int(int2byte(66_666)));
         assertEquals(66_666, byte2int(int2byte(66_666)), 0);
 
-        byte[] bb = ByteBuffer.allocate(12).putInt(99999).putInt(666).putInt(1234).array();
+        byte[] bb = ByteBuffer.allocate(12).putInt(99999).putInt(666)
+                .putInt(1234).array();
 
-        assertEquals(99999, byte2int(bb,0));
-        assertEquals(666,   byte2int(bb,4));
-        assertEquals(1234,  byte2int(bb,8));
+        assertEquals(99999, byte2int(bb, 0));
+        assertEquals(666, byte2int(bb, 4));
+        assertEquals(1234, byte2int(bb, 8));
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillDate.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillDate.java
index b62e231..f6f4fc3 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillDate.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillDate.java
@@ -12,7 +12,7 @@
 public class TestKrillDate {
 
     @Test
-    public void testByString() {
+    public void testByString () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -46,7 +46,7 @@
 
 
     @Test
-    public void testWithCeil() {
+    public void testWithCeil () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -72,8 +72,9 @@
         assertEquals(99999999, kd.ceil());
     };
 
+
     @Test
-    public void testWithFloor() {
+    public void testWithFloor () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -99,8 +100,9 @@
         assertEquals(0, kd.floor());
     };
 
+
     @Test
-    public void testToString() {
+    public void testToString () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -126,8 +128,9 @@
         assertEquals(null, kd.toString());
     };
 
+
     @Test
-    public void testToCeilString() {
+    public void testToCeilString () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -155,7 +158,7 @@
 
 
     @Test
-    public void testToFloorString() {
+    public void testToFloorString () {
         KrillDate kd = new KrillDate("2005-06-03");
         assertEquals(2005, kd.year);
         assertEquals(6, kd.month);
@@ -181,6 +184,7 @@
         assertEquals("0", kd.toFloorString());
     };
 
+
     @Test
     public void testDisplay () {
         KrillDate kd = new KrillDate("2005-06-03");
diff --git a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
index 14b4b14..3a437c5 100644
--- a/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
+++ b/src/test/java/de/ids_mannheim/korap/util/TestKrillString.java
@@ -12,11 +12,11 @@
 public class TestKrillString {
 
     @Test
-    public void testHTMLescape() {
+    public void testHTMLescape () {
         assertEquals("Der &amp; Die", escapeHTML("Der & Die"));
         assertEquals("Der &amp; Die &amp;", escapeHTML("Der & Die &"));
         assertEquals("&lt;x&gt;Hui&lt;/x&gt;", escapeHTML("<x>Hui</x>"));
         assertEquals("Er sagte: &quot;Das ist ja toll!&quot;",
-                     escapeHTML("Er sagte: \"Das ist ja toll!\""));
+                escapeHTML("Er sagte: \"Das ist ja toll!\""));
     };
 };