autoformat
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();
         };
     };
 };