autoformat
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;