Update to Lucene 5 (first step)

Change-Id: I220db9271d411e00f6c894238a1024a56c58aa2d
diff --git a/pom.xml b/pom.xml
index 1a056a9..e27e37d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -110,7 +110,7 @@
       <artifactId>lucene-core</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.10.3</version>
+      <version>5.0.0</version>
     </dependency>
 
     <!-- Lucene queryparser dependency -->
@@ -118,7 +118,7 @@
       <artifactId>lucene-queryparser</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.10.3</version>
+      <version>5.0.0</version>
     </dependency>
 
     <!-- Lucene analyzers dependency -->
@@ -126,7 +126,7 @@
       <artifactId>lucene-analyzers-common</artifactId>
       <groupId>org.apache.lucene</groupId>
       <type>jar</type>
-      <version>4.10.3</version>
+      <version>5.0.0</version>
     </dependency>
 
     <dependency>
diff --git a/src/main/java/de/ids_mannheim/korap/KrillCollection.java b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
index d0789e3..032b817 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillCollection.java
@@ -13,9 +13,8 @@
 import org.apache.lucene.index.*;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.FixedBitSet;
+import org.apache.lucene.util.BitDocIdSet;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.OpenBitSet;
-import org.apache.lucene.util.DocIdBitSet;
 import org.apache.lucene.search.BitsFilteredDocIdSet;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -415,13 +414,13 @@
      * This will respect deleted documents.
      * 
      * @param The
-     *            {@link AtomicReaderContext} to search in.
+     *            {@link LeafReaderContext} to search in.
      * @return A bit vector representing the live documents of the
      *         virtual collection.
      * @throws IOException
      */
-    public FixedBitSet bits (AtomicReaderContext atomic) throws IOException {
-        AtomicReader r = atomic.reader();
+    public FixedBitSet bits (LeafReaderContext atomic) throws IOException {
+        LeafReader r = atomic.reader();
         FixedBitSet bitset = new FixedBitSet(r.maxDoc());
         DocIdSet docids = this.getDocIdSet(atomic, (Bits) r.getLiveDocs());
 
@@ -446,12 +445,12 @@
      * This will respect deleted documents.
      * 
      * @param atomic
-     *            The {@link AtomicReaderContext} to search in.
+     *            The {@link LeafReaderContext} to search in.
      * @param accepted
      *            {@link Bits} vector of accepted documents.
      * @throws IOException
      */
-    public DocIdSet getDocIdSet (AtomicReaderContext atomic, Bits acceptDocs)
+    public DocIdSet getDocIdSet (LeafReaderContext atomic, Bits acceptDocs)
             throws IOException {
 
         int maxDoc = atomic.reader().maxDoc();
@@ -493,7 +492,7 @@
         };
 
         // Remove deleted docs
-        return (DocIdSet) BitsFilteredDocIdSet.wrap((DocIdSet) bitset,
+        return (DocIdSet) BitsFilteredDocIdSet.wrap((DocIdSet) new BitDocIdSet(bitset),
                 acceptDocs);
     };
 
@@ -550,7 +549,7 @@
         long occurrences = 0;
         try {
             // Iterate over all atomic readers and collect occurrences
-            for (AtomicReaderContext atomic : this.index.reader().leaves()) {
+            for (LeafReaderContext atomic : this.index.reader().leaves()) {
                 Bits bits = this.bits(atomic);
 
                 if (DEBUG)
@@ -575,7 +574,7 @@
     // Search for meta information in term vectors
     // This will create the sum of all numerical payloads
     // of the term in the document vector
-    private long _numberOfAtomic (Bits docvec, AtomicReaderContext atomic,
+    private long _numberOfAtomic (Bits docvec, LeafReaderContext atomic,
             Term term) throws IOException {
 
         // This reimplements docsAndPositionsEnum with payloads
@@ -659,7 +658,7 @@
         long docCount = 0;
         try {
             FixedBitSet bitset;
-            for (AtomicReaderContext atomic : this.index.reader().leaves()) {
+            for (LeafReaderContext atomic : this.index.reader().leaves()) {
                 if ((bitset = this.bits(atomic)) != null)
                     docCount += bitset.cardinality();
             };
@@ -702,7 +701,7 @@
                 checkNumber = (long) this.reader().numDocs();
             };
 
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
                 HashMap<String, FixedBitSet> termVector = new HashMap<>(20);
 
                 FixedBitSet docvec = kc.bits(atomic);
diff --git a/src/main/java/de/ids_mannheim/korap/KrillIndex.java b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
index 8a052b0..1b6fd26 100644
--- a/src/main/java/de/ids_mannheim/korap/KrillIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KrillIndex.java
@@ -205,7 +205,7 @@
                 new TextAnalyzer(), analyzerPerField);
 
         // Create configuration with base analyzer
-        this.config = new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer);
+        this.config = new IndexWriterConfig(analyzer);
     };
 
 
@@ -612,7 +612,7 @@
             long docCount = 0;
             // int i = 1;
             try {
-                for (AtomicReaderContext atomic : this.reader().leaves()) {
+                for (LeafReaderContext atomic : this.reader().leaves()) {
                     docCount += collection.bits(atomic).cardinality();
                     // i++;
                 };
@@ -630,7 +630,7 @@
         long occurrences = 0;
         try {
             // Iterate over all atomic readers and collect occurrences
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
                 occurrences += this._numberOfAtomic(collection.bits(atomic),
                         atomic, term);
             };
@@ -699,12 +699,13 @@
      * @return The number of the occurrences.
      * @throws IOException
      */
+        /*
     @Deprecated
     public long numberOf (Bits docvec, String field, String type)
             throws IOException {
         // Shortcut for documents
         if (type.equals("documents")) {
-            OpenBitSet os = (OpenBitSet) docvec;
+            FixedBitSet os = (FixedBitSet) docvec;
             return os.cardinality();
         };
 
@@ -712,7 +713,7 @@
 
         int occurrences = 0;
         try {
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
                 occurrences += this._numberOfAtomic(docvec, atomic, term);
             };
         }
@@ -722,14 +723,14 @@
 
         return occurrences;
     };
-
+*/
 
 
     // Search for meta information in term vectors
     // This will create the sum of all numerical payloads
     // of the term in the document vector
     @Deprecated
-    private long _numberOfAtomic (Bits docvec, AtomicReaderContext atomic,
+    private long _numberOfAtomic (Bits docvec, LeafReaderContext atomic,
             Term term) throws IOException {
 
         // This reimplements docsAndPositionsEnum with payloads
@@ -962,7 +963,7 @@
 
         try {
             // Iterate over all atomic indices and find the matching document
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
 
                 // Retrieve the single document of interest
                 DocIdSet filterSet = filter.getDocIdSet(atomic, atomic.reader()
@@ -1263,13 +1264,13 @@
 
 
             // Todo: run this in a separated thread
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
 
                 int oldLocalDocID = -1;
 
                 /*
                  * Todo: There may be a way to know early if the bitset is emty
-                 * by using OpenBitSet - but this may not be as fast as I think.
+                 * by using LongBitSet - but this may not be as fast as I think.
                  */
                 final Bits bitset = collection.bits(atomic);
                 final PositionsToOffset pto = new PositionsToOffset(atomic,
@@ -1486,12 +1487,12 @@
             int uniqueDocID = -1;
 
             // start thread:
-            for (AtomicReaderContext atomic : this.reader().leaves()) {
+            for (LeafReaderContext atomic : this.reader().leaves()) {
 
                 int previousDocID = -1;
                 int oldLocalDocID = -1;
 
-                // Use OpenBitSet;
+                // Use LongBitSet;
                 Bits bitset = collection.bits(atomic);
 
                 // PositionsToOffset pto = new PositionsToOffset(atomic, field);
diff --git a/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java b/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
index 53b0b66..b1cad93 100644
--- a/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
+++ b/src/main/java/de/ids_mannheim/korap/collection/BooleanGroupFilter.java
@@ -8,8 +8,8 @@
 import org.apache.lucene.search.DocIdSet;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.BitsFilteredDocIdSet;
-import org.apache.lucene.index.AtomicReaderContext;
-import org.apache.lucene.index.AtomicReader;
+import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.index.LeafReader;
 import org.apache.lucene.util.Bits;
 
 import de.ids_mannheim.korap.KrillCollection;
@@ -122,9 +122,9 @@
 
 
     @Override
-    public DocIdSet getDocIdSet (AtomicReaderContext context, Bits acceptDocs)
+    public DocIdSet getDocIdSet (LeafReaderContext context, Bits acceptDocs)
             throws IOException {
-        final AtomicReader reader = context.reader();
+        final LeafReader reader = context.reader();
         int maxDoc = reader.maxDoc();
         FixedBitSet bitset = new FixedBitSet(maxDoc);
         FixedBitSet combinator = new FixedBitSet(maxDoc);
diff --git a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
index f1a4e12..a0c1994 100644
--- a/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
+++ b/src/main/java/de/ids_mannheim/korap/index/FieldDocument.java
@@ -18,7 +18,7 @@
 import org.apache.lucene.document.IntField;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
-import org.apache.lucene.index.FieldInfo.IndexOptions;
+import org.apache.lucene.index.IndexOptions;
 
 import java.util.*;
 
@@ -60,7 +60,7 @@
         keywords.setStoreTermVectorPositions(false);
         keywords.setStoreTermVectorPayloads(false);
         keywords.setStoreTermVectorOffsets(false);
-        keywords.setIndexOptions(IndexOptions.DOCS_ONLY);
+        keywords.setIndexOptions(IndexOptions.DOCS);
     };
 
 
diff --git a/src/main/java/de/ids_mannheim/korap/index/KeywordAnalyzer.java b/src/main/java/de/ids_mannheim/korap/index/KeywordAnalyzer.java
index 0725778..e16abae 100644
--- a/src/main/java/de/ids_mannheim/korap/index/KeywordAnalyzer.java
+++ b/src/main/java/de/ids_mannheim/korap/index/KeywordAnalyzer.java
@@ -11,9 +11,8 @@
 public class KeywordAnalyzer extends Analyzer {
 
     @Override
-    protected TokenStreamComponents createComponents (final String fieldName,
-            final Reader reader) {
-        final Tokenizer source = new WhitespaceTokenizer(reader);
+    protected TokenStreamComponents createComponents (final String fieldName) {
+        final Tokenizer source = new WhitespaceTokenizer();
         TokenStream sink = new LowerCaseFilter(source);
         return new TokenStreamComponents(source, sink);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java b/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
index de974c3..13bc89f 100644
--- a/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
+++ b/src/main/java/de/ids_mannheim/korap/index/MultiTermTokenStream.java
@@ -3,6 +3,7 @@
 import static de.ids_mannheim.korap.util.KrillByte.*;
 import de.ids_mannheim.korap.util.CorpusDataException;
 import org.apache.lucene.util.BytesRef;
+import java.nio.ByteBuffer;
 
 import java.util.*;
 import java.util.regex.*;
@@ -398,7 +399,7 @@
         charTermAttr.setEmpty();
         charTermAttr.append(mt.term);
 
-        BytesRef payload = new BytesRef();
+        ByteBuffer payload = ByteBuffer.allocateDirect(16);
 
         // There is offset information
         if (mt.start != mt.end) {
@@ -407,20 +408,20 @@
                         mt.end);
 
             // Add offsets to BytesRef payload
-            payload.append(new BytesRef(int2byte(mt.start)));
-            payload.append(new BytesRef(int2byte(mt.end)));
+            payload.put(int2byte(mt.start));
+            payload.put(int2byte(mt.end));
         };
 
         // There is payload in the MultiTerm
         if (mt.payload != null) {
-            payload.append(mt.payload);
+            payload.put(mt.payload.bytes);
             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 (payload.position() > 0) {
+            payloadAttr.setPayload(new BytesRef(payload.array()));
             if (DEBUG)
                 log.trace("Set payload[2] {}", payload.toString());
         };
@@ -429,7 +430,7 @@
         if (DEBUG) {
             StringBuilder sb = new StringBuilder("Index: [");
             sb.append(mt.term);
-            if (payload.length > 0)
+            if (payload.position() > 0)
                 sb.append('$').append(payload.toString());
             sb.append(']');
             sb.append(" with increment ").append(this.mtIndex == 0 ? 1 : 0);
diff --git a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
index 0440286..bd84972 100644
--- a/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
+++ b/src/main/java/de/ids_mannheim/korap/index/PositionsToOffset.java
@@ -6,7 +6,7 @@
 import java.nio.ByteBuffer;
 
 import org.apache.lucene.index.DocsAndPositionsEnum;
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermsEnum;
@@ -17,7 +17,7 @@
 
 public class PositionsToOffset {
     private String field;
-    private AtomicReaderContext atomic;
+    private LeafReaderContext atomic;
     private boolean processed = false;
     private Integer[] pair;
     private static ByteBuffer bbOffset = ByteBuffer.allocate(8);
@@ -59,7 +59,7 @@
     };
 
 
-    public PositionsToOffset (AtomicReaderContext atomic, String field) {
+    public PositionsToOffset (LeafReaderContext atomic, String field) {
         this.field = field;
         this.atomic = atomic;
         this.positions = new HashSet<>(64);
@@ -252,7 +252,7 @@
     };
 
 
-    public AtomicReaderContext getAtomicReader () {
+    public LeafReaderContext getLeafReader () {
         return this.atomic;
     };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/index/TextAnalyzer.java b/src/main/java/de/ids_mannheim/korap/index/TextAnalyzer.java
index 771c6c1..205b201 100644
--- a/src/main/java/de/ids_mannheim/korap/index/TextAnalyzer.java
+++ b/src/main/java/de/ids_mannheim/korap/index/TextAnalyzer.java
@@ -11,9 +11,8 @@
 public class TextAnalyzer extends Analyzer {
 
     @Override
-    protected TokenStreamComponents createComponents (final String fieldName,
-            final Reader reader) {
-        final Tokenizer source = new StandardTokenizer(reader);
+    protected TokenStreamComponents createComponents (final String fieldName) {
+        final Tokenizer source = new StandardTokenizer();
         TokenStream sink = new LowerCaseFilter(source);
         return new TokenStreamComponents(source, sink);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
index a4194b1..265d2de 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanAttributeQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -109,7 +109,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new AttributeSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanClassFilterQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanClassFilterQuery.java
index 799c87e..b5a8653 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanClassFilterQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanClassFilterQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -40,7 +40,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new ClassFilteredSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
index 8de7faf..0b2df96 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanClassQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
@@ -45,7 +45,7 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new ClassSpans(this.firstClause, context, acceptDocs,
                 termContexts, number);
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
index c77bf71..da53af7 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanDistanceQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -205,7 +205,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         if (this.elementQuery != null) {
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 937e9bc..bf7d51f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanElementQuery.java
@@ -4,7 +4,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanTermQuery;
@@ -69,7 +69,7 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new ElementSpans(this, context, acceptDocs, termContexts);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
index 2fb8e84..d7130e1 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanExpansionQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -265,7 +265,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         //	      Temporary:
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
index ab29d0f..ace6183 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanFocusQuery.java
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
@@ -105,7 +105,7 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new FocusSpans(this, context, acceptDocs, termContexts);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
index b8553d9..51ba29b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanMultipleDistanceQuery.java
@@ -4,7 +4,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -167,7 +167,7 @@
      * @return only the span matches meeting all the constraints.
      * */
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         SpanDistanceQuery sdq, sdq2;
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
index 6a0c679..8d2021e 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanNextQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
@@ -88,7 +88,7 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new NextSpans(this, context, acceptDocs, termContexts);
     };
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanReferenceQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanReferenceQuery.java
index 3b23a18..241b6ce 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanReferenceQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanReferenceQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -32,7 +32,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         // TODO Auto-generated method stub
         return new ReferenceSpans(this, context, acceptDocs, termContexts);
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationMatchQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationMatchQuery.java
index 0fac2a3..e0b8dd6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationMatchQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationMatchQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -119,7 +119,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         return new FocusSpans((SpanFocusQuery) firstClause, context,
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
index 65b8786..d62216b 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRelationQuery.java
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -105,7 +105,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new RelationSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
index 7e95bf6..92c6c94 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanRepetitionQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -88,7 +88,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new RepetitionSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
index 29189e2..508c7ca 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanSegmentQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -70,7 +70,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new SegmentSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
index 010d077..84f589d 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanSubspanQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -79,7 +79,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new SubSpans(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
index 87de370..324d560 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanTermWithIdQuery.java
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanTermQuery;
@@ -57,7 +57,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return new TermSpansWithId(this, context, acceptDocs, termContexts);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
index 2ea519a..ce08c62 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithAttributeQuery.java
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -185,7 +185,7 @@
 
 
     @Override
-    public Spans getSpans (AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         if (type.equals("spanWithAttribute")) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java b/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
index ee79869..e658046 100644
--- a/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/SpanWithinQuery.java
@@ -9,11 +9,11 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.Spans;
@@ -160,7 +160,7 @@
 
 
     @Override
-    public Spans getSpans (final AtomicReaderContext context, Bits acceptDocs,
+    public Spans getSpans (final LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
         return (Spans) new WithinSpans(this, context, acceptDocs, termContexts,
                 this.flag);
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 cf70cb9..91b85bf 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
@@ -7,7 +7,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -65,7 +65,7 @@
      * @throws IOException
      */
     public AttributeSpans (SpanAttributeQuery spanAttributeQuery,
-                           AtomicReaderContext context, Bits acceptDocs,
+                           LeafReaderContext context, Bits acceptDocs,
                            Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanAttributeQuery, context, acceptDocs, termContexts);
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ClassFilteredSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ClassFilteredSpans.java
index 28459cf..57d3d81 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ClassFilteredSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ClassFilteredSpans.java
@@ -6,7 +6,7 @@
 import java.util.BitSet;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -22,7 +22,7 @@
 
 
     public ClassFilteredSpans (SpanClassFilterQuery query,
-                               AtomicReaderContext context, Bits acceptDocs,
+                               LeafReaderContext context, Bits acceptDocs,
                                Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 09cc05b..37036b4 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
@@ -7,7 +7,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.index.TermState;
@@ -47,7 +47,7 @@
      * @param operand
      *            An arbitrary nested {@link SpanQuery}.
      * @param context
-     *            The {@link AtomicReaderContext}.
+     *            The {@link LeafReaderContext}.
      * @param acceptDocs
      *            Bit vector representing the documents
      *            to be searched in.
@@ -56,7 +56,7 @@
      * @param number
      *            The identifying class number.
      */
-    public ClassSpans (SpanQuery operand, AtomicReaderContext context,
+    public ClassSpans (SpanQuery operand, LeafReaderContext context,
                        Bits acceptDocs, Map<Term, TermContext> termContexts,
                        byte number) throws IOException {
         spans = operand.getSpans(context, acceptDocs, termContexts);
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 517e8f8..d3b9f6f 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
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -42,7 +42,7 @@
      * @throws IOException
      */
     public DistanceExclusionSpans (SpanDistanceQuery query,
-                                   AtomicReaderContext context,
+                                   LeafReaderContext context,
                                    Bits acceptDocs,
                                    Map<Term, TermContext> termContexts)
             throws IOException {
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 b6b6f9f..7bc9136 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
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -48,7 +48,7 @@
      * @param termContexts
      * @throws IOException
      */
-    public DistanceSpans (SpanDistanceQuery query, AtomicReaderContext context,
+    public DistanceSpans (SpanDistanceQuery query, LeafReaderContext context,
                           Bits acceptDocs, Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
@@ -68,7 +68,7 @@
      * @throws IOException
      */
     public DistanceSpans (SpanMultipleDistanceQuery query,
-                          AtomicReaderContext context, Bits acceptDocs,
+                          LeafReaderContext context, Bits acceptDocs,
                           Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 f5fc8cb..78c0e76 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
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -63,7 +63,7 @@
      * @throws IOException
      */
     public ElementDistanceExclusionSpans (SpanDistanceQuery query,
-                                          AtomicReaderContext context,
+                                          LeafReaderContext context,
                                           Bits acceptDocs,
                                           Map<Term, TermContext> termContexts)
             throws IOException {
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 ac8fe24..5f3ded5 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
@@ -4,7 +4,7 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -45,7 +45,7 @@
      * @throws IOException
      */
     public ElementDistanceSpans (SpanDistanceQuery query,
-                                 AtomicReaderContext context, Bits acceptDocs,
+                                 LeafReaderContext context, Bits acceptDocs,
                                  Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 0e4768d..9616ba3 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
@@ -8,7 +8,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.index.TermState;
@@ -44,7 +44,7 @@
      * @param spanElementQuery
      *            A {@link SpanElementQuery}.
      * @param context
-     *            The {@link AtomicReaderContext}.
+     *            The {@link LeafReaderContext}.
      * @param acceptDocs
      *            Bit vector representing the documents
      *            to be searched in.
@@ -53,7 +53,7 @@
      * @throws IOException
      */
     public ElementSpans (SpanElementQuery spanElementQuery,
-                         AtomicReaderContext context, Bits acceptDocs,
+                         LeafReaderContext context, Bits acceptDocs,
                          Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanElementQuery, context, acceptDocs, termContexts);
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 19f7e7f..6b6fee0 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
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -62,7 +62,7 @@
      * @throws IOException
      */
     public ExpandedExclusionSpans (SpanExpansionQuery spanExpansionQuery,
-                                   AtomicReaderContext context,
+                                   LeafReaderContext context,
                                    Bits acceptDocs,
                                    Map<Term, TermContext> termContexts)
             throws IOException {
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 b378d43..29e8900 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
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -49,7 +49,7 @@
      * @throws IOException
      */
     public ExpandedSpans (SpanExpansionQuery spanExpansionQuery,
-                          AtomicReaderContext context, Bits acceptDocs,
+                          LeafReaderContext context, Bits acceptDocs,
                           Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanExpansionQuery, context, acceptDocs, termContexts);
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 9598ac0..10d740c 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
@@ -8,7 +8,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.index.TermState;
@@ -64,7 +64,7 @@
      * @param query
      *            A {@link SpanQuery}.
      * @param context
-     *            The {@link AtomicReaderContext}.
+     *            The {@link LeafReaderContext}.
      * @param acceptDocs
      *            Bit vector representing the documents
      *            to be searched in.
@@ -74,7 +74,7 @@
      *            The class number to focus on.
      * @throws IOException
      */
-    public FocusSpans (SpanFocusQuery query, AtomicReaderContext context,
+    public FocusSpans (SpanFocusQuery query, LeafReaderContext context,
                        Bits acceptDocs, Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 63d355f..f1b7973 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
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -61,7 +61,7 @@
      * @throws IOException
      */
     public MultipleDistanceSpans (SpanMultipleDistanceQuery query,
-                                  AtomicReaderContext context, Bits acceptDocs,
+                                  LeafReaderContext context, Bits acceptDocs,
                                   Map<Term, TermContext> termContexts,
                                   Spans firstSpans, Spans secondSpans,
                                   boolean isOrdered, boolean exclusion)
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 9c8fa28..34045fb 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
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -46,7 +46,7 @@
      * @param termContexts
      * @throws IOException
      */
-    public NextSpans (SpanNextQuery spanNextQuery, AtomicReaderContext context,
+    public NextSpans (SpanNextQuery spanNextQuery, LeafReaderContext context,
                       Bits acceptDocs, Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanNextQuery, context, acceptDocs, termContexts);
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 d7f41da..07d1526 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
@@ -4,7 +4,7 @@
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -38,7 +38,7 @@
      * @throws IOException
      */
     public NonPartialOverlappingSpans (SimpleSpanQuery simpleSpanQuery,
-                                       AtomicReaderContext context,
+                                       LeafReaderContext context,
                                        Bits acceptDocs,
                                        Map<Term, TermContext> termContexts)
             throws IOException {
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 88d5bc3..64507ab 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
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -39,7 +39,7 @@
      * @throws IOException
      */
     public OrderedDistanceSpans (SpanDistanceQuery query,
-                                 AtomicReaderContext context, Bits acceptDocs,
+                                 LeafReaderContext context, Bits acceptDocs,
                                  Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
diff --git a/src/main/java/de/ids_mannheim/korap/query/spans/ReferenceSpans.java b/src/main/java/de/ids_mannheim/korap/query/spans/ReferenceSpans.java
index cae4c5a..7d855e0 100644
--- a/src/main/java/de/ids_mannheim/korap/query/spans/ReferenceSpans.java
+++ b/src/main/java/de/ids_mannheim/korap/query/spans/ReferenceSpans.java
@@ -5,7 +5,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -18,7 +18,7 @@
 
 
     public ReferenceSpans (SpanReferenceQuery query,
-                           AtomicReaderContext context, Bits acceptDocs,
+                           LeafReaderContext context, Bits acceptDocs,
                            Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 d8299ef..b00dc43 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
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -50,7 +50,7 @@
      * @throws IOException
      */
     public RelationBaseSpans (SimpleSpanQuery spanWithIdQuery,
-                              AtomicReaderContext context, Bits acceptDocs,
+                              LeafReaderContext context, Bits acceptDocs,
                               Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanWithIdQuery, context, acceptDocs, termContexts);
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 979b359..fcc8645 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
@@ -7,7 +7,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -74,7 +74,7 @@
      * @throws IOException
      */
     public RelationSpans (SpanRelationQuery relationSpanQuery,
-                          AtomicReaderContext context, Bits acceptDocs,
+                          LeafReaderContext context, Bits acceptDocs,
                           Map<Term, TermContext> termContexts)
             throws IOException {
         super(relationSpanQuery, context, acceptDocs, termContexts);
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 1809309..6764c9d 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
@@ -7,7 +7,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -40,7 +40,7 @@
      * @throws IOException
      */
     public RepetitionSpans (SpanRepetitionQuery query,
-                            AtomicReaderContext context, Bits acceptDocs,
+                            LeafReaderContext context, Bits acceptDocs,
                             Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 9d40d31..46e4b28 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
@@ -4,7 +4,7 @@
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -34,7 +34,7 @@
      * @throws IOException
      */
     public SegmentSpans (SpanSegmentQuery spanSegmentQuery,
-                         AtomicReaderContext context, Bits acceptDocs,
+                         LeafReaderContext context, Bits acceptDocs,
                          Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanSegmentQuery, context, acceptDocs, termContexts);
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 d82b8fa..76a1cec 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
@@ -5,7 +5,7 @@
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -48,7 +48,7 @@
 
 
     public SimpleSpans (SimpleSpanQuery simpleSpanQuery,
-                        AtomicReaderContext context, Bits acceptDocs,
+                        LeafReaderContext context, Bits acceptDocs,
                         Map<Term, TermContext> termContexts) throws IOException {
         this();
         query = simpleSpanQuery;
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 8f0e0b9..c38b332 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
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.SpanQuery;
@@ -57,7 +57,7 @@
      */
     public SpansWithAttribute (SpanWithAttributeQuery spanWithAttributeQuery,
                                SimpleSpans referentSpans,
-                               AtomicReaderContext context, Bits acceptDocs,
+                               LeafReaderContext context, Bits acceptDocs,
                                Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanWithAttributeQuery, context, acceptDocs, termContexts);
@@ -75,7 +75,7 @@
     // if there is no (positive) attributes, but there are *not attributes*
     // hasmorespan = true
     public SpansWithAttribute (SpanWithAttributeQuery spanWithAttributeQuery,
-                               AtomicReaderContext context, Bits acceptDocs,
+                               LeafReaderContext context, Bits acceptDocs,
                                Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanWithAttributeQuery, context, acceptDocs, termContexts);
@@ -94,7 +94,7 @@
 
 
     public void setAttributeList (SpanWithAttributeQuery swaq,
-            AtomicReaderContext context, Bits acceptDocs,
+            LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         attributeList = new ArrayList<AttributeSpans>();
@@ -141,7 +141,7 @@
      * @throws IOException
      */
     private void addAttributes (SpanAttributeQuery sq,
-            AtomicReaderContext context, Bits acceptDocs,
+            LeafReaderContext context, Bits acceptDocs,
             Map<Term, TermContext> termContexts) throws IOException {
 
         AttributeSpans as = (AttributeSpans) sq.getSpans(context, acceptDocs,
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 6abec55..1bcfc40 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
@@ -3,7 +3,7 @@
 import java.io.IOException;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -36,7 +36,7 @@
      * @throws IOException
      */
     public SubSpans (SpanSubspanQuery subspanQuery,
-                     AtomicReaderContext context, Bits acceptDocs,
+                     LeafReaderContext context, Bits acceptDocs,
                      Map<Term, TermContext> termContexts) throws IOException {
         super(subspanQuery, context, acceptDocs, termContexts);
         this.startOffset = subspanQuery.getStartOffset();
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 431b839..0135fca 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
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.TermSpans;
@@ -40,7 +40,7 @@
      * @throws IOException
      */
     public TermSpansWithId (SpanTermWithIdQuery spanTermWithIdQuery,
-                            AtomicReaderContext context, Bits acceptDocs,
+                            LeafReaderContext context, Bits acceptDocs,
                             Map<Term, TermContext> termContexts)
             throws IOException {
         super(spanTermWithIdQuery, context, acceptDocs, termContexts);
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 9044c5e..7eb0dfc 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
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.util.Bits;
@@ -38,7 +38,7 @@
      * @throws IOException
      */
     public TokenDistanceSpans (SpanDistanceQuery query,
-                               AtomicReaderContext context, Bits acceptDocs,
+                               LeafReaderContext context, Bits acceptDocs,
                                Map<Term, TermContext> termContexts)
             throws IOException {
         super(query, context, acceptDocs, termContexts);
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 60e2a8a..705450d 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
@@ -7,7 +7,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -47,7 +47,7 @@
      * @throws IOException
      */
     public UnorderedDistanceSpans (SpanDistanceQuery query,
-                                   AtomicReaderContext context,
+                                   LeafReaderContext context,
                                    Bits acceptDocs,
                                    Map<Term, TermContext> termContexts)
             throws IOException {
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 8489970..0fec0af 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
@@ -6,7 +6,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -50,7 +50,7 @@
      * @throws IOException
      */
     public UnorderedElementDistanceSpans (SpanDistanceQuery query,
-                                          AtomicReaderContext context,
+                                          LeafReaderContext context,
                                           Bits acceptDocs,
                                           Map<Term, TermContext> termContexts)
             throws IOException {
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 0b8b055..a8013bb 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
@@ -5,7 +5,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -36,7 +36,7 @@
      * @throws IOException
      */
     public UnorderedTokenDistanceSpans (SpanDistanceQuery query,
-                                        AtomicReaderContext context,
+                                        LeafReaderContext context,
                                         Bits acceptDocs,
                                         Map<Term, TermContext> termContexts)
             throws IOException {
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 4358f45..2afcc42 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
@@ -6,7 +6,7 @@
 import java.util.LinkedList;
 import java.util.Map;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.DocIdSetIterator;
@@ -100,7 +100,7 @@
      * @param spanWithinQuery
      *            The parental {@link SpanWithinQuery}.
      * @param context
-     *            The {@link AtomicReaderContext}.
+     *            The {@link LeafReaderContext}.
      * @param acceptDocs
      *            Bit vector representing the documents
      *            to be searched in.
@@ -111,7 +111,7 @@
      *            the sub spans.
      */
     public WithinSpans (SpanWithinQuery spanWithinQuery,
-                        AtomicReaderContext context, Bits acceptDocs,
+                        LeafReaderContext context, Bits acceptDocs,
                         Map<Term, TermContext> termContexts, byte flag)
             throws IOException {
 
diff --git a/src/main/java/de/ids_mannheim/korap/response/Match.java b/src/main/java/de/ids_mannheim/korap/response/Match.java
index 617f07a..f5e3e63 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Match.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Match.java
@@ -5,7 +5,7 @@
 import java.util.*;
 
 import org.apache.lucene.document.Document;
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.TermContext;
 import org.apache.lucene.search.spans.Spans;
@@ -763,7 +763,7 @@
 
         if (this.positionsToOffset != null)
             return this.expandContextToSpan(
-                    this.positionsToOffset.getAtomicReader(), (Bits) null,
+                    this.positionsToOffset.getLeafReader(), (Bits) null,
                     "tokens", element);
         return new int[] { 0, 0, 0, 0 };
     };
@@ -771,7 +771,7 @@
 
     // Expand the context to a span
     // THIS IS NOT VERY CLEVER - MAKE IT MORE CLEVER!
-    public int[] expandContextToSpan (AtomicReaderContext atomic, Bits bitset,
+    public int[] expandContextToSpan (LeafReaderContext atomic, Bits bitset,
             String field, String element) {
 
         try {
@@ -1307,7 +1307,7 @@
             this.endMore = false;
 
             int[] spanContext = this.expandContextToSpan(
-                    this.positionsToOffset.getAtomicReader(), (Bits) null,
+                    this.positionsToOffset.getLeafReader(), (Bits) null,
                     "tokens", this.context.getSpanContext());
             startOffset = spanContext[0];
             endOffset = spanContext[1];
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index abda3c8..9a42ab8 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -130,7 +130,7 @@
         Map<Term, TermContext> termContexts = new HashMap<>();
         List<String> spanArray = new ArrayList<>();
 
-        for (AtomicReaderContext atomic : reader.leaves()) {
+        for (LeafReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             // Spans spans = NearSpansOrdered();
             Spans spans = query.getSpans(atomic, bitset, termContexts);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
index aac981e..b6119b4 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestIndex.java
@@ -28,7 +28,7 @@
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 
 import org.apache.lucene.queryparser.classic.ParseException;
 import org.apache.lucene.queryparser.classic.QueryParser;
@@ -512,7 +512,7 @@
 
         StringBuilder payloadString = new StringBuilder();
         Map<Term, TermContext> termContexts = new HashMap<>();
-        for (AtomicReaderContext atomic : reader.leaves()) {
+        for (LeafReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             //	    Spans spans = NearSpansOrdered();
             Spans spans = snquery.getSpans(atomic, bitset, termContexts);
@@ -547,7 +547,7 @@
 
         payloadString = new StringBuilder();
         termContexts = new HashMap<>();
-        for (AtomicReaderContext atomic : reader.leaves()) {
+        for (LeafReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             //	    Spans spans = NearSpansOrdered();
             Spans spans = snquery.getSpans(atomic, bitset, termContexts);
@@ -576,7 +576,7 @@
 
         payloadString = new StringBuilder();
         termContexts = new HashMap<>();
-        for (AtomicReaderContext atomic : reader.leaves()) {
+        for (LeafReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             // Spans spans = NearSpansOrdered();
             Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
@@ -601,7 +601,7 @@
 
         payloadString = new StringBuilder();
         termContexts = new HashMap<>();
-        for (AtomicReaderContext atomic : reader.leaves()) {
+        for (LeafReaderContext atomic : reader.leaves()) {
             Bits bitset = atomic.reader().getLiveDocs();
             // Spans spans = NearSpansOrdered();
             Spans spans = ssequery.toQuery().getSpans(atomic, bitset, termContexts);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
index c31fa1f..23f8bac 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestPosToOffset.java
@@ -20,7 +20,7 @@
 import de.ids_mannheim.korap.index.MultiTermTokenStream;
 import de.ids_mannheim.korap.index.PositionsToOffset;
 
-import org.apache.lucene.index.AtomicReaderContext;
+import org.apache.lucene.index.LeafReaderContext;
 import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.index.TermContext;
@@ -51,7 +51,7 @@
         ki.commit();
 
         String field = "base";
-        for (AtomicReaderContext atomic : ki.reader().leaves()) {
+        for (LeafReaderContext atomic : ki.reader().leaves()) {
             PositionsToOffset pto = new PositionsToOffset(atomic, field);
 
             pto.add(0, 1);