diff --git a/Changes b/Changes
index 1b2dba8..c6d33fa 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,10 @@
-0.49.3 2014-02-03
+0.49.4 2015-02-04
+        - [documentation] Improved documentation for API classes (diewald)
+   	- [performance] Updated Lucene dependency from 4.5.1 to 4.10.3,
+	  Updated Jackson dependency from 2.4.0 to 2.4.4,
+   	  Updated Jersey dependency from 2.4.1 to 2.15 (diewald)
+
+0.49.3 2015-02-03
         - [documentation] Improved documentation for API classes (diewald)
 	- [documentation] Improved documentation for various queries (margaretha)
 	- [feature] Added deserialization of SpanSubSpanQueries (margaretha,diewald)
diff --git a/pom.xml b/pom.xml
index bbcfb33..cdbbbd6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
 
   <groupId>KorAP-modules</groupId>
   <artifactId>KorAP-lucene-index</artifactId>
-  <version>0.49.3</version>
+  <version>0.49.4</version>
   <packaging>jar</packaging>
 
   <name>KorAP-lucene-index</name>
@@ -47,7 +47,7 @@
   </developers>
 
   <properties>
-    <jersey.version>2.4.1</jersey.version>
+    <jersey.version>2.15</jersey.version>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
 
@@ -103,7 +103,7 @@
       <artifactId>lucene-core</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.5.1</version>
+      <version>4.10.3</version>
     </dependency>
 
     <!-- Lucene queryparser dependency -->
@@ -111,7 +111,7 @@
       <artifactId>lucene-queryparser</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.5.1</version>
+      <version>4.10.3</version>
     </dependency>
 
     <!-- Lucene analyzers dependency -->
@@ -119,7 +119,7 @@
       <artifactId>lucene-analyzers-common</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.3.1</version>
+      <version>4.10.3</version>
     </dependency>
 
     <dependency>
@@ -159,17 +159,17 @@
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-databind</artifactId>
-      <version>2.4.0</version>
+      <version>2.4.4</version>
     </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-annotations</artifactId>
-      <version>2.4.0</version>
+      <version>2.4.4</version>
     </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
       <artifactId>jackson-core</artifactId>
-      <version>2.4.0</version>
+      <version>2.4.4</version>
     </dependency>
 <!--
     Temporarily disable @Experimental annotation
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java b/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java
index f9ff3d6..1f72e8d 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java
+++ b/src/main/java/de/ids_mannheim/korap/analysis/MultiTerm.java
@@ -5,12 +5,35 @@
 import java.nio.ByteBuffer;
 import java.util.*;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * @author Nils Diewald
- * @version 0.3
+ * A MultiTerm represents a single term (e.g. a word, an annotation, a relation)
+ * that can be part of a MultiTermToken.
  *
- * MultiTerm represents a term in a MultiTermToken.
+ * A MultiTerm consists of a term representation string, optional character offset
+ * information that matches the term to the character stream of the input text,
+ * and an arbitrary payload.
+ *
+ * There is a simple string representation of MultiTerms supported:
+ * The string is the first sequence of characters.
+ * Offsets are written as an appended and dash separated pair of integers.
+ * Payloads are written following a dollar sign.
+ * Payload segments can be typed as being a short (s), an integer (i), or a long (l)
+ * value in leading angular brackets.
+ * All other (untyped) payloads are treated as being UTF-8 characer sequences.
+ *
+ * <blockquote><pre>
+ *   MultiTerm test1 = new MultiTerm("test");
+ *   MultiTerm test2 = new MultiTerm("test#0-4");
+ *   MultiTerm test3 = new MultiTerm("test#0-4$Example");
+ *   MultiTerm test4 = new MultiTerm("test#0-4$&lt;i&gt;1278");
+ * </pre></blockquote>
+ *
+ * <strong>Warning</strong>: Strings that are malformed fail silently!
+ *
+ * @author diewald
  */
 public class MultiTerm {
     public int start, end = 0;
@@ -24,141 +47,71 @@
 
     private static short i, l;
 
+    // This advices the java compiler to ignore all loggings
+    public static final boolean DEBUG = false;
+    private final Logger log = LoggerFactory.getLogger(MultiTermTokenStream.class);
+
 
     /**
-     * The constructor.
-     *
-     * @param term The term surface.
-              Offsets can be written as an appended and dash separated pair of integers,
-	      payloads can be written following a dollar sign.
-	      payloads can be typed as being a short (s), an integer (i), or a long (l)
-	      in leading angular brackets. All other payloads are treated as being UTF-8
-	      characer sequences.
-	      
-	      Examples:
-	      MultiTerm test = new MultiTerm("test");
-	      MultiTerm test = new MultiTerm("test#0-4");
-	      MultiTerm test = new MultiTerm("test#0-4$Example");
-	      MultiTerm test = new MultiTerm("test#0-4$&lt;i&gt;1278");
-
-	      Strings that are malformed fail silently.
-     */
-    public MultiTerm (String term) {
-	_fromString(term);
-    };
-
-    
-    /**
-     * The constructor with a separated prefix.
-     * new MultiTerm('a', "bcd") is equivalent to
-     * new MultiTerm("a:bcd");
-     *
-     * @param prefix A special prefix for the term.
-     * @param term The term surface.
-     *
-     * @see #MultiTerm(String)
-     */
-    public MultiTerm (char prefix, String term) {
-	StringBuilder sb = new StringBuilder();
-	_fromString(sb.append(prefix).append(':').append(term).toString());
-    };
-    
-    /**
-     * The empty constructor.
+     * Construct a new MultiTerm object.
      */
     public MultiTerm () {
-	this.term = "";
+        this.term = "";
+    };
+
+
+    /**
+     * Construct a new MultiTerm object.
+     *
+     * @param term The term surface (see synopsis).
+     */
+    public MultiTerm (String term) {
+        _fromString(term);
     };
 
     
     /**
-     * Sets the term value.
+     * Construct a new MultiTerm object.
      *
-     * @param term The term as a string
+     * In addition to the normal surface representation,
+     * this supports a prefix notation.
+     * The following expressions are equal:
+     *
+     * <blockquote><pre>
+     *   MultiTerm test1 = new MultiTerm('a', "bcd");
+     *   MultiTerm test2 = new MultiTerm("a:bcd");
+     * </pre></blockquote>
+     *
+     * @param prefix A special prefix for the term.
+     * @param term The term surface (see synopsis).
      */
-    public void setTerm (String term) {
-	this.term = term;
+    public MultiTerm (char prefix, String term) {
+        StringBuilder sb = new StringBuilder();
+        _fromString(sb.append(prefix).append(':').append(term).toString());
     };
 
 
     /**
-     * Returns the term value.
+     * Get the term value of the MultiTerm.
      *
-     * @return The term value.
+     * @return The term as a string.
      */
     public String getTerm () {
-	return this.term;
+        return this.term;
     };
-
+    
     
     /**
-     * Set the payload as a byte value.
+     * Set the term value of the MultiTerm.
      *
-     * @param pl The payload.
+     * @param term The term as a string.
+     * @return The {@link MultIterm} object for chaining.
      */
-    public void setPayload (Byte pl) {
-	this.payload = new BytesRef( ByteBuffer.allocate(1).put(pl).array());
+    public MultiTerm setTerm (String term) {
+        this.term = term;
+        return this;
     };
 
-    
-    /**
-     * Set the payload as a short value.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (short pl) {
-	this.payload = new BytesRef( ByteBuffer.allocate(2).putShort(pl).array());
-    };
-
-
-    /**
-     * Set the payload as an integer value.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (int pl) {
-	this.payload = new BytesRef( ByteBuffer.allocate(4).putInt(pl).array());
-    };
-
-    
-    /**
-     * Set the payload as a long value.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (long pl) {
-	this.payload = new BytesRef( ByteBuffer.allocate(8).putLong(pl).array());
-    };
-
-
-    /**
-     * Set the payload as a string value.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (String pl) {
-	this.payload = new BytesRef(pl);
-    };
-
-
-    /**
-     * Set the payload as a byte array.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (byte[] pl) {
-	this.payload = new BytesRef(pl);
-    };
-
-
-    /**
-     * Set the payload as a BytesRef.
-     *
-     * @param pl The payload.
-     */
-    public void setPayload (BytesRef pl) {
-	this.payload = pl;
-    };
 
     /**
      * Get the payload.
@@ -166,17 +119,91 @@
      * @return The payload as a BytesRef.
      */
     public BytesRef getPayload () {
-	return this.payload;
+        return this.payload;
+    };
+
+    
+    /**
+     * Set the payload as a {@link Byte} value.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (Byte pl) {
+        this.payload = new BytesRef( ByteBuffer.allocate(1).put(pl).array());
+        return this;
+    };
+
+    
+    /**
+     * Set the payload as a short value.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (short pl) {
+        this.payload = new BytesRef( ByteBuffer.allocate(2).putShort(pl).array());
+        return this;
     };
 
 
     /**
-     * Set the start position of the term.
+     * Set the payload as an integer value.
      *
-     * @param The start position.
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
      */
-    public void setStart (int value) {
-	this.start = value;
+    public MultiTerm setPayload (int pl) {
+        this.payload = new BytesRef( ByteBuffer.allocate(4).putInt(pl).array());
+        return this;
+    };
+
+    
+    /**
+     * Set the payload as a long value.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (long pl) {
+        this.payload = new BytesRef( ByteBuffer.allocate(8).putLong(pl).array());
+        return this;
+    };
+
+
+    /**
+     * Set the payload as a string value.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (String pl) {
+        this.payload = new BytesRef(pl);
+        return this;
+    };
+
+
+    /**
+     * Set the payload as a byte array.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (byte[] pl) {
+        this.payload = new BytesRef(pl);
+        return this;
+    };
+
+
+    /**
+     * Set the payload as a {@link BytesRef} object.
+     *
+     * @param pl The payload.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm setPayload (BytesRef pl) {
+        this.payload = pl;
+        return this;
     };
 
 
@@ -186,17 +213,19 @@
      * @return The start position.
      */
     public int getStart () {
-	return this.start;
+        return this.start;
     };
 
 
     /**
-     * Set the end position of the term.
+     * Set the start position.
      *
-     * @param The end position.
+     * @param start The start position.
+     * @return The {@link MultiTerm} object for chaining.
      */
-    public void setEnd (int value) {
-	this.end = value;
+    public MultiTerm setStart (int start) {
+        this.start = start;
+        return this;
     };
 
 
@@ -206,18 +235,19 @@
      * @return The end position.
      */
     public int getEnd () {
-	return this.end;
+        return this.end;
     };
 
 
     /**
-     * Set the flag for stored offsets.
+     * Set the end position.
      *
-     * @param value Boolean value indicating that the term
-     *        contains stored offsets.
+     * @param end The end position.
+     * @return The {@link MultiTerm} object for chaining.
      */
-    public void hasStoredOffsets (boolean value) {
-	this.storeOffsets = value;
+    public MultiTerm setEnd (int end) {
+        this.end = end;
+        return this;
     };
 
 
@@ -228,98 +258,25 @@
      *         contains stored offsets.
      */
     public boolean hasStoredOffsets () {
-	return this.storeOffsets;
-    };
-
-
-    private void _fromString (String term) {
-	String[] termSurface = term.split("\\$", 2);
-
-	// Payload is given
-	if (termSurface.length == 2) {
-	    String payloadStr = termSurface[1];
-
-	    // Payload has a type
-	    if (payloadStr.charAt(0) == '<' && payloadStr.charAt(2) == '>') {
-
-		// Rewind bytebuffer
-		bb.rewind();
-
-		// Split payload at type marker boundaries
-		String[] pls = payloadStr.split("(?=<)|(?<=>)");
-
-		l = 0; // Bytearray length
-
-		try {
-		    for (i = 1; i < pls.length;) {
-
-			// Resize the bytebuffer
-			if ((bb.capacity() - l) < 8) {
-			    bb = ByteBuffer.allocate(bb.capacity() + 8)
-				.put(bb.array());
-			    bb.position(l);
-			};
-
-			switch (pls[i]) {
-			case "<b>": // byte
-			    bb.put(Byte.parseByte(pls[i+1]));
-			    l++;
-			    break;
-			case "<s>": // short
-			    bb.putShort(Short.parseShort(pls[i+1]));
-			    l+=2;
-			    break;
-			case "<i>": // integer
-			    bb.putInt(Integer.parseInt(pls[i+1]));
-			    l+=4;
-			    break;
-			case "<l>": // long
-			    bb.putLong(Long.parseLong(pls[i+1]));
-			    l+=8;
-			    break;
-			};
-			i+=2;
-		    };
-		
-		    byte[] bytes = new byte[l];
-		    System.arraycopy(bb.array(), 0, bytes, 0, l);
-		    this.payload = new BytesRef(bytes);
-		}
-		catch (Exception e) {
-		};
-	    }
-
-	    // Payload is a string
-	    else {
-		this.payload = new BytesRef(payloadStr);
-	    };
-	};
-	
-	// Parse offset information
-	stringOffset = termSurface[0].split("\\#", 2);
-
-	if (stringOffset.length == 2) {
-
-	    // Split start and end position of the offset
-	    String[] offset = stringOffset[1].split("\\-", 2);
-   
-	    // Start and end is given
-	    if (offset.length == 2 && offset[0].length() > 0) {
-		try {
-		    this.start = Integer.parseInt(offset[0]);
-		    this.end   = Integer.parseInt(offset[1]);
-
-		}
-		catch (NumberFormatException e) {
-		};
-	    };
-	};
-	this.term = stringOffset[0];
+        return this.storeOffsets;
     };
 
 
     /**
-     * Represent the MultiTerm as a string.
+     * Set the flag for stored offsets, in case they are relevant.
+     *
+     * @param value Boolean value indicating that the term
+     *        contains stored offsets.
+     * @return The {@link MultiTerm} object for chaining.
+     */
+    public MultiTerm hasStoredOffsets (boolean value) {
+        this.storeOffsets = value;
+        return this;
+    };
+
+
+    /**
+     * Represent the MultiTerm as a string (see synopsis).
      * Offsets are attached following a hash sign,
      * payloads are attached following a dollar sign.
      * All payloads are written as UTF-8 character sequences.
@@ -327,50 +284,144 @@
      * @see #toStringShort().
      */
     public String toString () {
+        StringBuilder sb = new StringBuilder(this.term);
+        if (this.start != this.end) {
+            sb.append('#')
+                .append(this.start)
+                .append('-')
+                .append(this.end);
+        };
 
-	StringBuilder sb = new StringBuilder(this.term);
+        if (this.payload != null) {
+            sb.append('$');
+            try {
+                sb.append(this.payload.utf8ToString());
+            }
+            catch (AssertionError e) {
+                sb.append("<?>")
+                    .append(this.payload.toString().replace(' ', ','));
+            };
+        };
 
-	if (this.start != this.end) {
-	    sb.append('#')
-	      .append(this.start)
-	      .append('-')
-	      .append(this.end);
-	};
-
-	if (this.payload != null) {
-	    sb.append('$');
-	    try {
-		sb.append(this.payload.utf8ToString());
-	    }
-	    catch (AssertionError e) {
-		sb.append("<?>")
-	          .append(this.payload.toString().replace(' ', ','));
-	    };
-	};
-
-	return sb.toString();
+        return sb.toString();
     };
 
+
     /**
      * Represent the MultiTerm as a string.
      * Payloads are attached following a dollar sign.
      * All payloads are written as UTF-8 character sequences.
      * Offsets are neglected.
+     *
+     * Offsets are ignored.
      * 
      * @see #toString().
      */
     public String toStringShort () {
-	StringBuilder sb = new StringBuilder(this.term);
-	if (this.payload != null) {
-	    sb.append('$');
-	    try {
-		sb.append(this.payload.utf8ToString());
-	    }
-	    catch (AssertionError e) {
-		sb.append("<?>")
-		.append(this.payload.toString().replace(' ', ','));
-	    };
-	};
-	return sb.toString();
+        StringBuilder sb = new StringBuilder(this.term);
+        if (this.payload != null) {
+            sb.append('$');
+            try {
+                sb.append(this.payload.utf8ToString());
+            }
+            catch (AssertionError e) {
+                sb.append("<?>")
+                    .append(this.payload.toString().replace(' ', ','));
+            };
+        };
+        return sb.toString();
+    };
+
+
+    /*
+     * Deserialize MultiTerm from string representation.
+     */
+    private void _fromString (String term) {
+        String[] termSurface = term.split("\\$", 2);
+
+        // Payload is given
+        if (termSurface.length == 2) {
+            String payloadStr = termSurface[1];
+
+            // Payload has a type
+            if (payloadStr.charAt(0) == '<' && payloadStr.charAt(2) == '>') {
+
+                // Rewind bytebuffer
+                bb.rewind();
+
+                // Split payload at type marker boundaries
+                String[] pls = payloadStr.split("(?=<)|(?<=>)");
+
+                l = 0; // Bytearray length
+
+                try {
+                    for (i = 1; i < pls.length;) {
+
+                        // Resize the bytebuffer
+                        if ((bb.capacity() - l) < 8) {
+                            bb = ByteBuffer.allocate(bb.capacity() + 8).
+                                put(bb.array());
+                            bb.position(l);
+                        };
+
+                        switch (pls[i]) {
+                        case "<b>": // byte
+                            bb.put(Byte.parseByte(pls[i+1]));
+                            l++;
+                            break;
+                        case "<s>": // short
+                            bb.putShort(Short.parseShort(pls[i+1]));
+                            l+=2;
+                            break;
+                        case "<i>": // integer
+                            bb.putInt(Integer.parseInt(pls[i+1]));
+                            l+=4;
+                            break;
+                        case "<l>": // long
+                            bb.putLong(Long.parseLong(pls[i+1]));
+                            l+=8;
+                            break;
+                        };
+                        i+=2;
+                    };
+		
+                    byte[] bytes = new byte[l];
+                    System.arraycopy(bb.array(), 0, bytes, 0, l);
+                    this.payload = new BytesRef(bytes);
+                }
+                catch (Exception e) {
+                    if (DEBUG)
+                        log.warn(e.getMessage());
+                };
+            }
+
+            // Payload is a string
+            else {
+                this.payload = new BytesRef(payloadStr);
+            };
+        };
+	
+        // Parse offset information
+        stringOffset = termSurface[0].split("\\#", 2);
+
+        if (stringOffset.length == 2) {
+
+            // Split start and end position of the offset
+            String[] offset = stringOffset[1].split("\\-", 2);
+   
+            // Start and end is given
+            if (offset.length == 2 && offset[0].length() > 0) {
+                try {
+                    this.start = Integer.parseInt(offset[0]);
+                    this.end   = Integer.parseInt(offset[1]);
+                    
+                }
+                catch (NumberFormatException e) {
+                    if (DEBUG)
+                        log.warn("Offset not a number: {}", term);
+                };
+            };
+        };
+        this.term = stringOffset[0];
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java b/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java
index 9af4156..5332090 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java
+++ b/src/main/java/de/ids_mannheim/korap/analysis/MultiTermToken.java
@@ -5,171 +5,207 @@
 
 
 /**
- * @author Nils Diewald
  *
- * MultiTermToken represents a segment in a MultiTermTokenStream.
+ * A MultiTermToken represents a set of {@link MultiTerm MultiTerms}
+ * starting at the same position, i.e. represents a segment
+ * in a {@link MultiTermTokenStream}.
+ *
+ * <blockquote><pre>
+ *  MultiTermToken mtt = new MultiTermToken("t:test", "a:abbruch");
+ *  mtt.add("b:banane");
+ *  System.err.println(mtt.toString());
+ *  // [t:test|a:abbruch|b:banane]
+ * </pre></blockquote>
+ *
+ * @author diewald
  */
 public class MultiTermToken {
     public int start, end = 0;
     public List<MultiTerm> terms;
-
     private static short i = 0;
 
+
     /**
-     * The constructor.
+     * Construct a new MultiTermToken by passing a stream of
+     * {@link MultiTerm MultiTerms}.
      *
-     * @param terms Take at least one MultiTerm object for a token.
+     * @param terms Take at least one {@link MultiTerm} object for a token.
      */
-    public MultiTermToken (MultiTerm term, MultiTerm ... moreTerms) {
-	this.terms = new ArrayList<MultiTerm>(16);
+    public MultiTermToken (MultiTerm terms, MultiTerm ... moreTerms) {
+        this.terms = new ArrayList<MultiTerm>(16);
+        
+        // Start position is not equal to end position
+        if (terms.start != terms.end) {
+            this.start = terms.start;
+            this.end   = terms.end;
+        };
 
-	if (term.start != term.end) {
-	    this.start = term.start;
-	    this.end = term.end;
-	};
+        terms.posIncr = 1;
+        this.terms.add( terms );
 
-	term.posIncr = 1;
-	terms.add( term );
-
-	// Further elements on same position
-	for (i = 0; i < moreTerms.length; i++) {
-	    term = moreTerms[i];
-	    term.posIncr = 0;
-	    terms.add(term);
-	};
+        // Further elements on same position
+        for (i = 0; i < moreTerms.length; i++) {
+            moreTerms[i].posIncr = 0;
+            this.terms.add(moreTerms[i]);
+        };
     };
 
 
     /**
-     * The constructor.
+     * Construct a new MultiTermToken by passing a {@link MultiTerm}
+     * represented as a prefixed string.
      *
-     * @param prefix A term prefix.
-     * @param surface A surface string.
+     * @param prefix The term prefix.
+     * @param surface The term surface.
+     * @see MultiTerm
      */
     public MultiTermToken (char prefix, String surface) {
-	this.terms = new ArrayList<MultiTerm>(16);
+        this.terms = new ArrayList<MultiTerm>(16);
 
-	MultiTerm term = new MultiTerm(prefix, surface);
+        // Create a new MultiTerm
+        MultiTerm term = new MultiTerm(prefix, surface);
 
-	this.setOffset(term.start, term.end);
-
-	// First word element
-	term.posIncr = 1;
-	terms.add( term );
+        this.setOffset(term.start, term.end);
+        
+        // First word element
+        term.posIncr = 1;
+        terms.add( term );
     };
     
 
     /**
-     * The constructor.
+     * Construct a new MultiTermToken by passing a stream of
+     * {@link MultiTerm MultiTerms} represented as strings.
      *
-     * @param prefix At least one term surface string.
+     * @param terms Take at least one {@link MultiTerm} string for a token.
      */
-    public MultiTermToken (String surface, String ... moreTerms) {
-	this.terms = new ArrayList<MultiTerm>(16);
+    public MultiTermToken (String terms, String ... moreTerms) {
+        this.terms = new ArrayList<MultiTerm>(16);
 
-	MultiTerm term = new MultiTerm(surface);
+        MultiTerm term = new MultiTerm(terms);
+        this.setOffset(term.start, term.end);
 
-	this.setOffset(term.start, term.end);
+        // First word element
+        term.posIncr = 1;
+        this.terms.add( term );
 
-	// First word element
-	term.posIncr = 1;
-	terms.add( term );
-
-	// Further elements on same position
-	for (i = 0; i < moreTerms.length; i++) {
-	    term = new MultiTerm( moreTerms[i] );
-	    this.setOffset(term.start, term.end);
-	    term.posIncr = 0;
-	    terms.add(term);
-	};
+        // Further elements on same position
+        for (i = 0; i < moreTerms.length; i++) {
+            term = new MultiTerm( moreTerms[i] );
+            this.setOffset(term.start, term.end);
+            term.posIncr = 0;
+            this.terms.add(term);
+        };
     };
 
     
     /**
-     * Add a new term to the MultiTermToken.
+     * Add a new {@link MultiTerm} to the MultiTermToken.
      *
-     * @param mt A MultiTerm.
+     * @param term A {@link MultiTerm} object.
+     * @return The {@link MultiTermToken} object for chaining.
      */
-    public void add (MultiTerm mt) {
-	mt.posIncr = 0;
-	this.setOffset(mt.start, mt.end);
-	terms.add(mt);
+    public MultiTermToken add (MultiTerm term) {
+        term.posIncr = 0;
+        this.setOffset(term.start, term.end);
+        terms.add(term);
+        return this;
     };
 
 
     /**
-     * Add a new term to the MultiTermToken.
+     * Add a new {@link MultiTerm} to the MultiTermToken.
      *
-     * @param term A surface string.
+     * @param term A MultiTerm represented as a surface string.
+     * @return The {@link MultiTermToken} object for chaining.
      */
-    public void add (String term) {
-	if (term.length() == 0)
-	    return;
-	MultiTerm mt = new MultiTerm(term);
-	this.setOffset(mt.start, mt.end);
-	mt.posIncr = 0;
-	terms.add(mt);
-    };
-
-    /**
-     * Add a new term to the MultiTermToken.
-     *
-     * @param prefix A prefix character for the surface string.
-     * @param term A surface string.
-     */
-    public void add (char prefix, String term) {
-	if (term.length() == 0)
-	    return;
-	MultiTerm mt = new MultiTerm(prefix, term);
-	this.setOffset(mt.start, mt.end);
-	mt.posIncr = 0;
-	terms.add(mt);
+    public MultiTermToken add (String term) {
+        if (term.length() == 0)
+            return this;
+        MultiTerm mt = new MultiTerm(term);
+        this.setOffset(mt.start, mt.end);
+        mt.posIncr = 0;
+        terms.add(mt);
+        return this;
     };
 
 
     /**
-     * Sets the offset information of the MultiTermToken.
+     * Add a new {@link MultiTerm} to the MultiTermToken.
+     *
+     * @param prefix A MultiTerm prefix.
+     * @param term A MultiTerm represented as a surface string.
+     * @return The {@link MultiTermToken} object for chaining.
+     */
+    public MultiTermToken add (char prefix, String term) {
+        if (term.length() == 0)
+            return this;
+        MultiTerm mt = new MultiTerm(prefix, term);
+        this.setOffset(mt.start, mt.end);
+        mt.posIncr = 0;
+        terms.add(mt);
+        return this;
+    };
+
+
+    /**
+     * Set the start and end character offset information
+     * of the MultiTermToken.
      *
      * @param start The character position of the token start.
      * @param end The character position of the token end.
+     * @return The {@link MultiTermToken} object for chaining.
      */
-    public void setOffset (int start, int end) {
-	if (start != end) {
-	    this.start = (this.start == 0 || start < this.start) ? start : this.start;
-	    this.end   = end > this.end ? end : this.end;
-	};
+    public MultiTermToken setOffset (int start, int end) {
+
+        // No value to set - offsets indicating a null string
+        if (start != end) {
+            this.start =
+                (this.start == 0 || start < this.start) ?
+                start : this.start;
+
+            this.end = end > this.end ? end : this.end;
+        };
+
+        return this;
     };
 
+
+    /**
+     * Get the number of {@link MultiTerm MultiTerms}
+     * in the MultiTermToken.
+     *
+     * @return The number of {@link MultiTerm MultiTerms}
+     *         in the MultiTermToken.
+     */
+    public int getSize () {
+        return this.terms.size();
+    };
+
+
+
     /**
      * Serialize the MultiTermToken to a string.
      *
-     * @return A string representation of the token, with leading offset information.
+     * @return A string representation of the MultiTermToken,
+     *         with leading offset information.
      */
     public String toString () {
-	StringBuffer sb = new StringBuffer();
+        StringBuffer sb = new StringBuffer();
+        sb.append('[');
+        if (this.start != this.end) {
+            sb.append('(')
+                .append(this.start)
+                .append('-')
+                .append(this.end)
+                .append(')');
+        };
 
-	sb.append('[');
-	if (this.start != this.end) {
-	    sb.append('(')
-	      .append(this.start)
-	      .append('-')
-	      .append(this.end)
-	      .append(')');
-	};
-
-	i = 0;
-	for (; i < this.terms.size() - 1; i++) {
-	    sb.append(this.terms.get(i).toString()).append('|');
-	};
-	sb.append(this.terms.get(i).toString()).append(']');
-
-	return sb.toString();
-    };
-
-    /**
-     * Return the number of MultiTerms in the MultiTermToken.
-     */
-    public int size () {
-	return this.terms.size();
+        for (i = 0; i < this.terms.size() - 1; i++) {
+            sb.append(this.terms.get(i).toString()).append('|');
+        };
+        sb.append(this.terms.get(i).toString()).append(']');
+        
+        return sb.toString();
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java b/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java
index c869c0a..8a7f3a7 100644
--- a/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java
+++ b/src/main/java/de/ids_mannheim/korap/analysis/MultiTermTokenStream.java
@@ -9,9 +9,7 @@
 import java.util.regex.*;
 
 import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.analysis.tokenattributes.*;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -20,298 +18,368 @@
 import java.io.IOException;
 
 /*
-  Todo:
-   - !Payload is [4ByteStartOffset][14BitEndOffset-startOffset][1BitBooleanIfSpan][1BitBooleanIfOpen]
-   - Payload is [4ByteOffsetStart][4ByteOffsetStart]
-*/
+ * Todo:
+ * - !Payload is
+ *   [4ByteStartOffset][14BitEndOffset-startOffset]
+ *   [1BitBooleanIfSpan][1BitBooleanIfOpen]
+ * - Payload is
+ *   [4ByteOffsetStart][4ByteOffsetStart]
+ */
 
 /**
- * @author Nils Diewald
- * @version 0.3
+ * MultiTermTokenStream extends Lucenes {@link TokenStream}
+ * to work with {@link MultiTermToken MultiTermTokens}.
  *
- * MultiTermTokenStream extends Lucenes TokenStream class to work with MultiTermTokens.
+ * <blockquote><pre>
+ *   MultiTermTokenStream mtts = new MultiTermTokenStream(
+ *       "[s:den#0-3|i:den|p:DET|l:der|m:c:acc|m:n:sg|m:masc]"
+ *   );
+ * </pre></blockquote>
  *
- * @see org.apache.lucene.analysis.TokenStream
+ * @author diewald
+ * @see TokenStream
  */
 public class MultiTermTokenStream extends TokenStream {
     private CharTermAttribute charTermAttr;
     private PositionIncrementAttribute posIncrAttr;
     private PayloadAttribute payloadAttr;
 
-
-    /*
-      TODO: Update to new Tokeanstream API
-      http://www.hankcs.com/program/java/lucene-4-6-1-java-lang-illegalstateexception-tokenstream-contract-violation.html
-     */
-
-    private static final Pattern pattern = Pattern.compile("\\[(?:\\([0-9]+-[0-9]+\\))?([^\\]]+?)\\]");
+    private static final Pattern pattern =
+        Pattern.compile("\\[(?:\\([0-9]+-[0-9]+\\))?([^\\]]+?)\\]");
 
     // This advices the java compiler to ignore all loggings
     public static final boolean DEBUG = false;
     private final Logger log = LoggerFactory.getLogger(MultiTermTokenStream.class);
 
     private List<MultiTermToken> multiTermTokens;
-    private int mttIndex = 0, mtIndex  = 0;
+    private int mttIndex   = 0,
+                mtIndex    = 0;
     private static short i = 0;
 
-
     /**
-     * The empty Constructor.
+     * Construct a new MultiTermTokenStream object.
      */
     public MultiTermTokenStream () {
         this.charTermAttr    = this.addAttribute(CharTermAttribute.class);
         this.posIncrAttr     = this.addAttribute(PositionIncrementAttribute.class);
-	this.payloadAttr     = this.addAttribute(PayloadAttribute.class);
-	this.multiTermTokens = new ArrayList<MultiTermToken>(100);
+        this.payloadAttr     = this.addAttribute(PayloadAttribute.class);
+        this.multiTermTokens = new ArrayList<MultiTermToken>(100);
     };
 
 
     /**
-     * The Constructor.
+     * Construct a new MultiTermTokenStream object
      *
-     * @param stream The MultiTermTokenStream as a string representation.
+     * @param stream The stream as a string representation.
      */
     public MultiTermTokenStream (String stream) {
-	this();
-	this._fromString(stream);
-    };  
+        this();
+        this._fromString(stream);
+    };
+
 
     /**
-     * The Constructor.
+     * Construct a new MultiTermTokenStream object
      *
-     * @param stream The MultiTermTokenStream as a reader object.
+     * @param stream The stream as a {@link Reader} object.
+     * @throws IOException
      */
     public MultiTermTokenStream (Reader stream) throws IOException {
-	this();
+        this();
 	
-	StringBuilder sb = new StringBuilder(4096);
-	char[] buf = new char[128];
-	int i;
-	while ((i = stream.read(buf)) > 0) {
-	    sb.append(buf, 0, i);
-	};
-	this._fromString(sb.toString());
+        StringBuilder sb = new StringBuilder(4096);
+        char[] buf = new char[128];
+
+        int j;
+        while ((j = stream.read(buf)) > 0)
+            sb.append(buf, 0, j);
+
+        this._fromString(sb.toString());
     };
 
 
     /**
-     * Add a MultiTermToken to the end of the MultiTermTokenStream.
+     * Append a {@link MultiTermToken} to the MultiTermTokenStream.
      *
-     * @param mtt A MultiTermToken.
+     * @param mtt A {@link MultiTermToken}.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMultiTermToken (MultiTermToken mtt) {
-	this.multiTermTokens.add(mtt);
+    public MultiTermTokenStream addMultiTermToken (MultiTermToken mtt) {
+        this.multiTermTokens.add(mtt);
+        return this;
     };
 
 
     /**
-     * Add a MultiTermToken by means of MultiTerms to the end of
-     * the MultiTermTokenStream.
+     * Append a {@link MultiTermToken} to the MultiTermTokenStream
+     * by means of a set of {@link MultiTerm MultiTerms}.
      *
-     * @param term At least one MultiTerm.
+     * @param mts A list of {@link MultiTerm} objects.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMultiTermToken (MultiTerm term, MultiTerm ... moreTerms) {
-	this.addMultiTermToken(new MultiTermToken(term, moreTerms));
+    public MultiTermTokenStream addMultiTermToken
+        (MultiTerm mts, MultiTerm ... moreTerms) {
+        this.addMultiTermToken(new MultiTermToken(mts, moreTerms));
+        return this;
     };
 
 
     /**
-     * Add a MultiTermToken by means of a single MultiTerm to the end of
-     * the MultiTermTokenStream.
+     * Append a {@link MultiTermToken} to the MultiTermTokenStream
+     * by means of a single {@link MultiTerm} as a prefixed term.
      *
-     * @param prefix A prefix character of a surface form of a MultiTerm.
-     * @param surface A surface string of a MultiTerm.
+     * @param prefix A prefix character of a surface form of a {@link MultiTerm}.
+     * @param surface A surface string of a {@link MultiTerm}.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMultiTermToken (char prefix, String surface) {
-	this.addMultiTermToken(new MultiTermToken(prefix, surface));
+    public MultiTermTokenStream addMultiTermToken
+        (char prefix, String surface) {
+        this.addMultiTermToken(new MultiTermToken(prefix, surface));
+        return this;
     };
 
 
     /**
-     * Add a MultiTermToken by means of a a series of surface strings
-     * to the end of the MultiTermTokenStream.
+     * Append a {@link MultiTermToken} to the MultiTermTokenStream
+     * by means of {@link MultiTerm MultiTerm} represented as a set
+     * of terms represented as strings.
      *
-     * @param surface At least one surface string of a MultiTerm.
+     * @param surface At least one surface string of a {@link MultiTerm}.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMultiTermToken (String surface, String ... moreTerms) {
-	this.addMultiTermToken(new MultiTermToken(surface, moreTerms));
+    public MultiTermTokenStream addMultiTermToken
+        (String surface, String ... moreTerms) {
+        this.addMultiTermToken(new MultiTermToken(surface, moreTerms));
+        return this;
     };
 
 
     /**
      * Add meta information to the MultiTermTokenStream.
      *
+     * <strong>This is experimental!</strong>
+     *
      * @param key A string for denoting the meta information.
      * @param value The value of the meta key as a string.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMeta (String key, String value) {
-	MultiTerm mt = new MultiTerm('-', key);
-	mt.setPayload(value);
-	this.multiTermTokens.get(0).add(mt);
+    public MultiTermTokenStream addMeta (String key, String value) {
+        MultiTerm mt = new MultiTerm('-', key);
+        mt.setPayload(value);
+        this.multiTermTokens.get(0).add(mt);
+        return this;
     };
 
 
     /**
      * Add meta information to the MultiTermTokenStream.
      *
+     * <strong>This is experimental!</strong>
+     *
      * @param key A string for denoting the meta information.
      * @param value The value of the meta key as a byte array.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMeta (String key, byte[] value) {
-	MultiTerm mt = new MultiTerm('-', key);
-	mt.setPayload(value);
-	this.multiTermTokens.get(0).add(mt);
+    public MultiTermTokenStream addMeta (String key, byte[] value) {
+        MultiTerm mt = new MultiTerm('-', key);
+        mt.setPayload(value);
+        this.multiTermTokens.get(0).add(mt);
+        return this;
     };
 
 
     /**
      * Add meta information to the MultiTermTokenStream.
      *
+     * <strong>This is experimental!</strong>
+     *
      * @param key A string for denoting the meta information.
      * @param value The value of the meta key as a short value.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMeta (String key, short value) {
-	MultiTerm mt = new MultiTerm('-', key);
-	mt.setPayload(value);
-	this.multiTermTokens.get(0).add(mt);
+    public MultiTermTokenStream addMeta (String key, short value) {
+        MultiTerm mt = new MultiTerm('-', key);
+        mt.setPayload(value);
+        this.multiTermTokens.get(0).add(mt);
+        return this;
     };
 
 
     /**
      * Add meta information to the MultiTermTokenStream.
      *
+     * <strong>This is experimental!</strong>
+     *
      * @param key A string for denoting the meta information.
      * @param value The value of the meta key as a long value.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMeta (String key, long value) {
-	MultiTerm mt = new MultiTerm('-', key);
-	mt.setPayload(value);
-	this.multiTermTokens.get(0).add(mt);
+    public MultiTermTokenStream addMeta (String key, long value) {
+        MultiTerm mt = new MultiTerm('-', key);
+        mt.setPayload(value);
+        this.multiTermTokens.get(0).add(mt);
+        return this;
     };
 
 
     /**
      * Add meta information to the MultiTermTokenStream.
      *
+     * <strong>This is experimental!</strong>
+     *
      * @param key A string for denoting the meta information.
      * @param value The value of the meta key as a integer value.
+     * @return The {@link MultiTermTokenStream} object for chaining.
      */
-    public void addMeta (String key, int value) {
-	MultiTerm mt = new MultiTerm('-', key);
-	mt.setPayload(value);
-	this.multiTermTokens.get(0).add(mt);
+    public MultiTermTokenStream addMeta (String key, int value) {
+        MultiTerm mt = new MultiTerm('-', key);
+        mt.setPayload(value);
+        this.multiTermTokens.get(0).add(mt);
+        return this;
     };
 
 
     /**
+     * Get a {@link MultiTermToken} by index.
+     *
+     * @param index The index position of a {@link MultiTermToken}
+     *        in the {@link MultiTermTokenStream}.
+     * @return A {@link MultiTermToken}.
+     */
+    public MultiTermToken get (int index) {
+        return this.multiTermTokens.get(index);
+    };
+
+
+    /**
+     * Get the number of {@link MultiTermToken MultiTermTokens}
+     * in the stream.
+     *
+     * @return The number of {@link MultiTermToken MultiTermTokens}
+     *         in the stream.
+     */
+    public int getSize () {
+        return this.multiTermTokens.size();
+    };
+
+
+    /**
+     * Serialize the MultiTermTokenStream to a string.
+     *
+     * @return The MultiTermTokenStream as a string.
+     */
+    public String toString () {
+        StringBuffer sb = new StringBuffer();
+        for (MultiTermToken mtt : this.multiTermTokens) {
+            sb.append( mtt.toString() );
+        };
+        return sb.toString();
+    };
+
+
+    // Deserialize a string
+    private void _fromString (String stream) {
+        Matcher matcher = pattern.matcher(stream);
+
+        while (matcher.find()) {
+            String[] seg = matcher.group(1).split("\\|");
+            MultiTermToken mtt = new MultiTermToken( seg[0] );
+
+            for (i = 1; i < seg.length; i++)
+                mtt.add(seg[i]);
+            
+            this.addMultiTermToken(mtt);
+        };
+    };
+
+
+    /*
      * Increment the token in the MultiTermTokenStream.
      * This overrides the function in Lucene's TokenStream.
      */
     @Override
     public final boolean incrementToken() throws IOException {
-	this.payloadAttr.setPayload(null);
+        this.payloadAttr.setPayload(null);
 
-	// Last token reached
-	if (this.multiTermTokens.size() == this.mttIndex) {
-	    reset();
-	    return false;
-	};
+        // Last token reached
+        if (this.multiTermTokens.size() == this.mttIndex) {
+            reset();
+            return false;
+        };
 
-	// Get current token
-	MultiTermToken mtt = this.multiTermTokens.get( this.mttIndex );
+        // Get current token
+        MultiTermToken mtt = this.multiTermTokens.get( this.mttIndex );
 
-	// Last term reached
-	if (mtt.terms.size() == this.mtIndex) {
-	    this.mtIndex = 0;
-	    this.mttIndex++;
+        // Last term reached
+        if (mtt.terms.size() == this.mtIndex) {
+            this.mtIndex = 0;
+            this.mttIndex++;
 
-	    // Last term of last token reached
-	    if (this.multiTermTokens.size() == this.mttIndex) {
-		reset();
-		return false;
-	    }
+            // Last term of last token reached
+            if (this.multiTermTokens.size() == this.mttIndex) {
+                reset();
+                return false;
+            }
 
-	    // Get last token
-	    else {
-		mtt = this.multiTermTokens.get( this.mttIndex );
-	    };
-	};
+            // Get last token
+            else {
+                mtt = this.multiTermTokens.get( this.mttIndex );
+            };
+        };
 
-	// Get current term
-	MultiTerm mt = mtt.terms.get(this.mtIndex);
+        // Get current term
+        MultiTerm mt = mtt.terms.get(this.mtIndex);
 
-	// Set the relative position to the former term
+        // Set the relative position to the former term
         posIncrAttr.setPositionIncrement( mt.posIncr );
         charTermAttr.setEmpty();
-	charTermAttr.append( mt.term );
+        charTermAttr.append( mt.term );
 
-	BytesRef payload = new BytesRef();
+        BytesRef payload = new BytesRef();
 
-	// There is offset information
-	if (mt.start != mt.end) {
-	    if (DEBUG)
-		log.trace("MultiTerm with payload offset: {}-{}", mt.start, mt.end);
+        // There is offset information
+        if (mt.start != mt.end) {
+            if (DEBUG)
+                log.trace("MultiTerm with payload offset: {}-{}", mt.start, mt.end);
 
-	    // Add offsets to BytesRef payload
-	    payload.append(new BytesRef(int2byte(mt.start)));
-	    payload.append(new BytesRef(int2byte(mt.end)));
-	};
+            // Add offsets to BytesRef payload
+            payload.append(new BytesRef(int2byte(mt.start)));
+            payload.append(new BytesRef(int2byte(mt.end)));
+        };
 
-	// There is payload in the MultiTerm
-	if (mt.payload != null) {
-	    payload.append(mt.payload);
-	    if (DEBUG)
-		log.trace("Create payload[1] {}", payload.toString());
-	};
+        // There is payload in the MultiTerm
+        if (mt.payload != null) {
+            payload.append(mt.payload);
+            if (DEBUG)
+                log.trace("Create payload[1] {}", payload.toString());
+        };
+        
+        // There is payload in the current token to index
+        if (payload.length > 0) {
+            payloadAttr.setPayload(payload);
+            if (DEBUG)
+                log.trace("Set payload[2] {}", payload.toString());
+        };
 
-	// There is payload in the current token to index
-	if (payload.length > 0) {
-	    payloadAttr.setPayload(payload);
-	    if (DEBUG)
-		log.trace("Set payload[2] {}", payload.toString());
-	};
+        // Some debug loggings
+        if (DEBUG) {
+            StringBuilder sb = new StringBuilder("Index: [");
+            sb.append(mt.term);
+            if (payload.length > 0)
+                sb.append('$').append(payload.toString());
+            sb.append(']');
+            sb.append(" with increment ").append(mt.posIncr);
+            
+            log.trace(sb.toString());
+        };
 
-	if (DEBUG) {
-	    StringBuilder sb = new StringBuilder("Index: [");
-	    sb.append(mt.term);
-	    if (payload.length > 0)
-		sb.append('$').append(payload.toString());
-	    sb.append(']');
-	    sb.append(" with increment ").append(mt.posIncr);
-
-	    log.trace(sb.toString());
-	};
-
-	this.mtIndex++;
-
+        this.mtIndex++;
         return true;
     };
 
-    public String toString () {
-	StringBuffer sb = new StringBuffer();
-	for (MultiTermToken mtt : this.multiTermTokens) {
-	    sb.append( mtt.toString() );
-	};
-	return sb.toString();
-    };
-
-    private void _fromString (String stream) {
-	Matcher matcher = pattern.matcher(stream);
-
-	while (matcher.find()) {
-	    String[] seg = matcher.group(1).split("\\|");
-	    MultiTermToken mtt = new MultiTermToken( seg[0] );
-
-	    for (i = 1; i < seg.length; i++)
-		mtt.add(seg[i]);
-	    
-	    this.addMultiTermToken(mtt);
-	};
-    };
-
     @Override
     public void reset() {
-	this.mttIndex = 0;
-	this.mtIndex = 0;
+        this.mttIndex = 0;
+        this.mtIndex = 0;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
index 78309e2..1e3f5f6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
@@ -17,21 +17,21 @@
 
 /**
  * SpanElementQuery retrieves {@link ElementSpans} which are special
- * {@link Term Terms} with prefix "<>". Unlike {@link TermSpans} consisting of
- * only one term, ElementSpans may contains more than one term comprising a
+ * {@link Term Terms} with prefix &quot;&lt;&gt;&quot;.
+ * Unlike {@link TermSpans} ElementSpans may span multiple tokens comprising a
  * phrase, a clause, a sentence and so on. <br/>
  * <br/>
  * Examples of {@link ElementSpans} are
  * 
  * <ul>
- * <li>sentences indexed as <>:s
+ * <li>sentences indexed as &lt;&gt;:s
  * 
  * <pre>
  * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;, &quot;s&quot;);
  * </pre>
  * 
  * </li>
- * <li>paragraphs indexed as <>:p
+ * <li>paragraphs indexed as &lt;&gt;:p
  * 
  * <pre>
  * SpanElementQuery seq = new SpanElementQuery(&quot;tokens&quot;, &quot;p&quot;);
@@ -45,7 +45,6 @@
  * @author margaretha
  */
 public class SpanElementQuery extends SpanWithIdQuery {
-    // private SpanTermQuery termQuery;
     private static Term elementTerm;
     private String elementStr;
 
@@ -57,18 +56,18 @@
      */
     public SpanElementQuery(String field, String term) {
         super(new SpanTermQuery((elementTerm = new Term(field, "<>:" + term))),
-                true);
+              true);
         this.elementStr = term;
-        // this.termQuery = (SpanTermQuery) this.getFirstClause();
-        // this.elementTerm = termQuery.getTerm();
     };
 
+
     @Override
     public Spans getSpans(final AtomicReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new ElementSpans(this, context, acceptDocs, termContexts);
     };
 
+
     /**
      * Returns the element name or string, for instance "s" for sentence
      * elements.
@@ -79,6 +78,7 @@
         return elementStr;
     };
 
+
     /**
      * Sets the element name or string, for instance "s" for sentence elements.
      * 
@@ -88,19 +88,24 @@
         this.elementStr = elementStr;
     }
 
+
     @Override
     public SimpleSpanQuery clone() {
-        SpanElementQuery sq = new SpanElementQuery(this.getField(),
-                this.getElementStr());
+        SpanElementQuery sq = new SpanElementQuery(
+            this.getField(),
+            this.getElementStr()
+        );
         sq.setBoost(this.getBoost());
         return sq;
     };
 
+
     @Override
     public void extractTerms(Set<Term> terms) {
         terms.add(elementTerm);
     };
 
+
     @Override
     public String toString(String field) {
         StringBuilder buffer = new StringBuilder("<");
@@ -109,6 +114,7 @@
         return buffer.append(" />").toString();
     };
 
+
     @Override
     public int hashCode() {
         final int prime = 37; // Instead of 31
@@ -118,6 +124,7 @@
         return result;
     };
 
+
     @Override
     public boolean equals(Object obj) {
         if (this == obj)
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 c0d32cc..532d2d4 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
@@ -21,14 +21,11 @@
 /**
  * SpanWithinQuery is DEPRECATED and will
  * be replaced by SpanPositionQuery in the near future
+ *
+ * TODO: Support exclusivity
+ * TODO: Use the term "queue" and implement it similar to SpanOrQuery
  */
 
-/*
-  TODO: Use the flag in KorapQuery!
-  TODO: Support exclusivity
-  TODO: Use the term queue and implement it similar to SpanOrQuery
-*/
-
 /**
  * Compare two spans and check how they relate positionally.
  *
@@ -68,21 +65,19 @@
 
     /*
       Supported flags are currently:
-      ov  -> 0  | overlap:      A & B != empty
-      rov -> 2  | real overlap: A & B != empty and
-                                ((A | B) != A or
+      ov  -> 0  | overlap:       A & B != empty
+      rov -> 2  | real overlap:  A & B != empty and
+                                 ((A | B) != A or
                                  (A | B) != B)
-      in  -> 4  | within:       A | B = A
-      rin -> 6  | real within:  A | B = A and
-                                A & B != A
-      ew  -> 8  | endswith:     A | B = A and
-                                A.start = B.start
-      sw  -> 10 | startswith:   A | B = A and
-                                A.end = B.end
-      m   -> 12 |               A = B
-
-      This may change in case the system switches to 16bit vector
-     */
+      in  -> 4  | within:        A | B = A
+      rin -> 6  | real within:   A | B = A and
+                                 A & B != A
+      ew  -> 8  | endswith:      A | B = A and
+                                 A.start = B.start
+      sw  -> 10 | startswith:    A | B = A and
+                                 A.end = B.end
+      m   -> 12 |                A = B
+    */
     public static final byte
         OVERLAP      = (byte) 0,
         REAL_OVERLAP = (byte) 2,
@@ -97,9 +92,14 @@
     // Contains the query
     private SpanWithinQuery query;
 
-    // Contains the spans
-    private final Spans embeddedSpans, wrapSpans;
+    // Representing the first operand
+    private final Spans wrapSpans;
 
+    // Representing the second operand
+    private final Spans embeddedSpans;
+
+    // Check flag if the current constellation
+    // was checked yet
     private boolean tryMatch = true;
 
     private LinkedList<KorapLongSpan>
diff --git a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java b/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java
index f88b194..138c031 100644
--- a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java
+++ b/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermToken.java
@@ -11,7 +11,9 @@
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
-
+/**
+ * @author diewald
+ */
 @RunWith(JUnit4.class)
 public class TestMultiTermToken {
 
@@ -22,14 +24,17 @@
         mtt.add("b:banane");
         assertEquals("[t:test|a:abbruch|b:banane]", mtt.toString());
         mtt.add("c:chaos#21-26");
-        assertEquals("[(21-26)t:test|a:abbruch|b:banane|c:chaos#21-26]",
-                     mtt.toString());
+        assertEquals(
+            "[(21-26)t:test|a:abbruch|b:banane|c:chaos#21-26]",
+            mtt.toString()
+        );
         mtt.add("d:dadaismus#21-28$vergleich");
         assertEquals(
             "[(21-28)t:test|a:abbruch|b:banane|c:chaos#21-26|" +
             "d:dadaismus#21-28$vergleich]",
             mtt.toString()
         );
+        assertEquals(5, mtt.getSize());
     };
 
     @Test
@@ -43,5 +48,6 @@
                      "c:cannonball#34-45$tatsache]", mtt.toString());
         assertEquals(23, mtt.start);
         assertEquals(45, mtt.end);
+        assertEquals(3, mtt.getSize());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java b/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java
index ff20192..04f08b6 100644
--- a/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java
+++ b/src/test/java/de/ids_mannheim/korap/analysis/TestMultiTermTokenStream.java
Binary files differ
