Lots of cleanups
diff --git a/CHANGES b/CHANGES
index 781a854..e91ea65 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
 0.49.1 2014-11-25
         - [cleanup] Major refactoring for new response messages (diewald)
 	- [cleanup] Removed deprecated error messaging (diewald)
+        - [cleanup] Removed long-term deprecated methods in KorapResult (diewald)
+	- [cleanup] Renamed toJSON->toJsonString (diewald)
+	- [cleanup] Renamed toJSONnode->toJsonNode (diewald)
+	- [cleanup] Renamed fromJSON->fromJson (diewald)
 	- [documentation] Improved documentation for notifications (diewald)
 
 0.49 2014-11-14
@@ -206,6 +210,7 @@
 
 0.25.3 2014-01-10
         - Updated Lucene to 4.3.1.
+	- Eliza Margaretha has joined the team.
 
 0.25.2 2013-12-29
         - Fixed highlight bug with empty reopened tags.
diff --git a/src/main/java/de/ids_mannheim/korap/KorapIndex.java b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
index a51eabd..a529a73 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapIndex.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapIndex.java
@@ -1082,7 +1082,7 @@
 	int i                       = 0,
   	    startIndex              = kr.getStartIndex(),
 	    count                   = kr.getItemsPerPage(),
-	    hits                    = kr.itemsPerPage() + startIndex,
+	    hits                    = kr.getItemsPerPage() + startIndex,
 	    limit                   = ks.getLimit(),
 	    itemsPerResourceCounter = 0;
 	boolean cutoff              = ks.doCutOff();
@@ -1099,7 +1099,7 @@
 	};
 
 	// Collect matches from atomic readers
-	ArrayList<KorapMatch> atomicMatches = new ArrayList<KorapMatch>(kr.itemsPerPage());
+	ArrayList<KorapMatch> atomicMatches = new ArrayList<KorapMatch>(kr.getItemsPerPage());
 
 	// Start time out thread
 	TimeOutThread tthread = new TimeOutThread();
@@ -1261,7 +1261,7 @@
 	    if (itemsPerResource > 0)
 		kr.setItemsPerResource(itemsPerResource);
 
-	    kr.setTotalResults(cutoff ? -1 : i);
+	    kr.setTotalResults(cutoff ? (long) -1 : (long) i);
 	}
 	catch (IOException e) {
 	    kr.addError(
diff --git a/src/main/java/de/ids_mannheim/korap/KorapMatch.java b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
index 98811db..74a62bc 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapMatch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapMatch.java
@@ -1339,7 +1339,7 @@
     
 
     // Identical to KorapResult!
-    public String toJSON () {
+    public String toJsonString () {
 	ObjectNode json = (ObjectNode) mapper.valueToTree(this);
 
 	// Match was no match
@@ -1347,7 +1347,7 @@
 	    return "{}";
 
 	if (this.context != null)
-	    json.put("context", this.getContext().toJSON());
+	    json.put("context", this.getContext().toJsonNode());
 
 	if (this.version != null)
 	    json.put("version", this.getVersion());
diff --git a/src/main/java/de/ids_mannheim/korap/KorapQuery.java b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
index d7962e8..96bd4ac 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapQuery.java
@@ -100,7 +100,7 @@
 	};
     };
 
-    public SpanQueryWrapper fromJSON (String jsonString) throws QueryException {
+    public SpanQueryWrapper fromJson (String jsonString) throws QueryException {
 	JsonNode json;
 	try {
 	    json = this.json.readValue(jsonString, JsonNode.class);
@@ -114,7 +114,7 @@
 	if (!json.has("@type") && json.has("query"))
 	    json = json.get("query");
 
-	return this.fromJSON(json);
+	return this.fromJson(json);
     };
 
     // http://fasterxml.github.io/jackson-databind/javadoc/2.2.0/com/fasterxml/jackson/databind/JsonNode.html
@@ -122,7 +122,7 @@
     // TODO: Use the shortcuts implemented in this class instead of the wrapper constructors
     // TODO: Check for isArray()
     // TODO: Rename this span context!
-    public SpanQueryWrapper fromJSON (JsonNode json) throws QueryException {
+    public SpanQueryWrapper fromJson (JsonNode json) throws QueryException {
 
 	int number = 0;
 
@@ -161,7 +161,7 @@
 	    case "operation:or":
 		SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
 		for (JsonNode operand : operands) {
-		    ssaq.or(this.fromJSON(operand));
+		    ssaq.or(this.fromJson(operand));
 		};
 		return ssaq;
 
@@ -226,8 +226,8 @@
 		    );
 
 		return new SpanWithinQueryWrapper(
-		    this.fromJSON(operands.get(0)),
-		    this.fromJSON(operands.get(1)),
+		    this.fromJson(operands.get(0)),
+		    this.fromJson(operands.get(1)),
 		    flag
 		);
 
@@ -254,14 +254,14 @@
 		};
 
 		return new SpanMatchModifyQueryWrapper(
-		    this.fromJSON(operands.get(0)), number
+		    this.fromJson(operands.get(0)), number
                 );
 
 	    case "operation:sequence":
 
 		// Sequence with only one operand
 		if (operands.size() == 1)
-		    return this.fromJSON(operands.get(0));
+		    return this.fromJson(operands.get(0));
 
 		SpanSequenceQueryWrapper sseqqw = this.seq();
 
@@ -364,7 +364,7 @@
 
 		// Add segments to sequence
 		for (JsonNode operand : operands) {
-		    sseqqw.append(this.fromJSON(operand));
+		    sseqqw.append(this.fromJson(operand));
 		};
 
 		// inOrder was set to false without a distance constraint
@@ -413,7 +413,7 @@
                         );
 		    };
 
-		    SpanQueryWrapper sqw = this.fromJSON(operands.get(0));
+		    SpanQueryWrapper sqw = this.fromJson(operands.get(0));
 
 		    // Problematic
 		    if (sqw.maybeExtension())
@@ -469,7 +469,7 @@
 		if (min > max)
 		    max = max;
 
-		SpanQueryWrapper sqw = this.fromJSON(operands.get(0));
+		SpanQueryWrapper sqw = this.fromJson(operands.get(0));
 
 		if (sqw.maybeExtension())
 		    return sqw.setMin(min).setMax(max);
@@ -530,7 +530,7 @@
 		log.trace("Wrap class reference {}", number);
 
 	    return new SpanMatchModifyQueryWrapper(
-	        this.fromJSON(operands.get(0)), number
+	        this.fromJson(operands.get(0)), number
 	    );
 
 	case "korap:token":
@@ -539,17 +539,17 @@
 	    if (!json.has("wrap"))
 		return new SpanRepetitionQueryWrapper();
 
-	    return this._segFromJSON(json.get("wrap"));
+	    return this._segFromJson(json.get("wrap"));
 
 	case "korap:span":
-	    return this._termFromJSON(json);
+	    return this._termFromJson(json);
 	};
 	throw new QueryException(713, "Query type is not supported");
     };
 
 
 
-    private SpanQueryWrapper _segFromJSON (JsonNode json) throws QueryException {
+    private SpanQueryWrapper _segFromJson (JsonNode json) throws QueryException {
 
 	if (!json.has("@type"))
 	    throw new QueryException(701, "JSON-LD group has no @type attribute");
@@ -571,11 +571,11 @@
 		if (DEBUG)
 		    log.trace("Term is negated");
 		SpanSegmentQueryWrapper ssqw =
-		    (SpanSegmentQueryWrapper) this._termFromJSON(json);
+		    (SpanSegmentQueryWrapper) this._termFromJson(json);
 		ssqw.makeNegative();
 		return this.seg().without(ssqw);
 	    case "match:eq":
-		return this._termFromJSON(json);
+		return this._termFromJson(json);
 	    };
 
 	    throw new QueryException(741, "Match relation unknown");
@@ -597,7 +597,7 @@
 	    case "relation:and":
 
 		for (JsonNode operand : operands) {
-		    SpanQueryWrapper part = this._segFromJSON(operand);
+		    SpanQueryWrapper part = this._segFromJson(operand);
 		    if (part instanceof SpanAlterQueryWrapper) {
 			ssegqw.with((SpanAlterQueryWrapper) part);			
 		    }
@@ -619,7 +619,7 @@
 
 		SpanAlterQueryWrapper ssaq = new SpanAlterQueryWrapper(this.field);
 		for (JsonNode operand : operands) {
-		    ssaq.or(this._segFromJSON(operand));
+		    ssaq.or(this._segFromJson(operand));
 		};
 		return ssaq;
 	    };
@@ -628,7 +628,7 @@
     };
 
 
-    private SpanQueryWrapper _termFromJSON (JsonNode json) throws QueryException {
+    private SpanQueryWrapper _termFromJson (JsonNode json) throws QueryException {
 	if (!json.has("key") || json.get("key").asText().length() < 1)
 	    throw new QueryException(740, "Key definition is missing in term or span");
 	    
diff --git a/src/main/java/de/ids_mannheim/korap/KorapResult.java b/src/main/java/de/ids_mannheim/korap/KorapResult.java
index 9ac2aef..6b5516e 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapResult.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapResult.java
@@ -30,23 +30,18 @@
     @JsonIgnore
     public static final short ITEMS_PER_PAGE = 25;
 
-    private int totalResults;
-    private long totalTexts;
+    private int startIndex = 0;
+    private long totalTexts, totalResults;
 
     private String query;
 
     private List<KorapMatch> matches;
 
-    private int startIndex = 0;
 
     private SearchContext context;
 
-    private short itemsPerPage = ITEMS_PER_PAGE;
-    private short itemsPerResource = 0;
-
-    private String benchmarkSearchResults,
-            benchmarkHitCounter;
-    private String error = null;
+    private short itemsPerPage = ITEMS_PER_PAGE,
+	          itemsPerResource = 0;
 
     private JsonNode request;
 
@@ -95,20 +90,10 @@
         return km;
     };
 
-    @Deprecated
-    public int totalResults() {
-        return this.getTotalResults();
-    };
-
     public short getItemsPerPage() {
         return this.itemsPerPage;
     };
 
-    @Deprecated
-    public short itemsPerPage() {
-        return this.itemsPerPage;
-    };
-
     public void setRequest(JsonNode request) {
         this.request = request;
     };
@@ -117,24 +102,6 @@
         return this.request;
     };
 
-    /*
-    @JsonIgnore
-    public void setBenchmarkHitCounter(long t1, long t2) {
-        this.benchmarkHitCounter =
-                (t2 - t1) < 100_000_000 ? (((double) (t2 - t1) * 1e-6) + " ms") :
-                        (((double) (t2 - t1) / 1000000000.0) + " s");
-    };
-
-    public void setBenchmarkHitCounter(String bm) {
-	this.benchmarkHitCounter = bm;
-    };
-
-    public String getBenchmarkHitCounter() {
-        return this.benchmarkHitCounter;
-    };
-
-    */
-
     // Make this working in a KorapResult class
     // that is independent from search and collection
     public KorapResult setTotalTexts (long i) {
@@ -142,11 +109,17 @@
 	return this;
     };
 
+    public KorapResult incrTotalTexts (int i) {
+        this.totalTexts += i;
+	return this;
+    };
+
     public long getTotalTexts() {
         return this.totalTexts;
     };
 
-    public KorapResult setTotalResults (int i) {
+
+    public KorapResult setTotalResults (long i) {
         this.totalResults = i;
 	return this;
     };
@@ -156,7 +129,7 @@
 	return this;
     };
 
-    public int getTotalResults() {
+    public long getTotalResults() {
         return this.totalResults;
     };
 
@@ -189,16 +162,10 @@
         return this.matches;
     };
 
-    @Deprecated
-    public KorapMatch match (int index) {
-        return this.matches.get(index);
-    };
-
     public int getStartIndex () {
         return startIndex;
     };
 
-
     @JsonIgnore
     public KorapResult setContext(SearchContext context) {
         this.context = context;
@@ -211,11 +178,12 @@
         return this.context;
     }
 
-    public JsonNode toJSONnode () {
-	ObjectNode json = (ObjectNode) mapper.valueToTree(super.toJSONnode());
+
+    public JsonNode toJsonNode () {
+	ObjectNode json = (ObjectNode) mapper.valueToTree(super.toJsonNode());
 
 	if (this.context != null)
-	    json.put("context", this.getContext().toJSON());
+	    json.put("context", this.getContext().toJsonNode());
 
 	if (this.itemsPerResource > 0)
 	    json.put("itemsPerResource",
@@ -247,7 +215,7 @@
 
 
     // For Collocation Analysis API
-    public String toTokenListJSON () {
+    public String toTokenListJsonString () {
         ObjectNode json = (ObjectNode) mapper.valueToTree(this);
 
 	ArrayNode array = json.putArray("matches");
diff --git a/src/main/java/de/ids_mannheim/korap/KorapSearch.java b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
index d145856..bc5d205 100644
--- a/src/main/java/de/ids_mannheim/korap/KorapSearch.java
+++ b/src/main/java/de/ids_mannheim/korap/KorapSearch.java
@@ -85,7 +85,7 @@
 	    if (this.request.has("query")) {
 		try {
 		    KorapQuery kq = new KorapQuery("tokens");
-		    SpanQueryWrapper qw = kq.fromJSON(this.request.get("query"));
+		    SpanQueryWrapper qw = kq.fromJson(this.request.get("query"));
 
 		    if (qw.isEmpty()) {
 
@@ -160,7 +160,7 @@
 
 		    // Defined contexts
 		    if (meta.has("context"))
-			this.context.fromJSON(meta.get("context"));
+			this.context.fromJson(meta.get("context"));
 
 		    // Defined resource count
 		    if (meta.has("timeout"))
diff --git a/src/main/java/de/ids_mannheim/korap/index/SearchContext.java b/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
index 9074512..37fda27 100644
--- a/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
+++ b/src/main/java/de/ids_mannheim/korap/index/SearchContext.java
@@ -106,7 +106,7 @@
 	    return this.setLength((short) value);
 	};
 
-	public void fromJSON (JsonNode json) {
+	public void fromJson (JsonNode json) {
 	    String type = json.get(0).asText();
 	    if (type.equals("token")) {
 		this.setToken(true);
@@ -119,20 +119,20 @@
     };
 
 
-    public void fromJSON (JsonNode context) {
+    public void fromJson (JsonNode context) {
 	if (context.isContainerNode()) {
 	    if (context.has("left"))
-		this.left.fromJSON(context.get("left"));
+		this.left.fromJson(context.get("left"));
 	    
 	    if (context.has("right"))
-		this.right.fromJSON(context.get("right"));
+		this.right.fromJson(context.get("right"));
 	}
 	else if (context.isValueNode()) {
 	    this.setSpanContext(context.asText());
 	};
     };
 
-    public JsonNode toJSON () {
+    public JsonNode toJsonNode () {
 
 	if (this.isSpanDefined())
 	    return new TextNode(this.spanContext);
diff --git a/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java b/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java
index 40a75aa..46d4028 100644
--- a/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java
+++ b/src/main/java/de/ids_mannheim/korap/response/KorapResponse.java
@@ -16,7 +16,7 @@
  * <blockquote><pre>
  *   KorapResponse km = new KorapResponse();
  *   System.out.println(
- *     km.toJSON()
+ *     km.toJsonString()
  *   );
  * </pre></blockquote>
  *
@@ -26,8 +26,6 @@
 public class KorapResponse extends Notifications {
     ObjectMapper mapper = new ObjectMapper();
 
-    // TODO: Add timeout!!!
-
     private String version, name, node, listener;
     private String benchmark;
     private boolean timeExceeded = false;
@@ -40,17 +38,6 @@
      */
     public KorapResponse () {};
 
-    /**
-     * Get string representation of the backend's version.
-     *
-     * @return String representation of the backend's version
-     */
-    @JsonIgnore
-    public String getVersion () {
-	if (this.version == null)
-	    return null;
-	return this.version;
-    };
 
     /**
      * Set the string representation of the backend's version.
@@ -64,19 +51,18 @@
 	return this;
     };
 
+
     /**
-     * Get string representation of the backend's name.
-     * All nodes in a cluster should have the same backend name.
+     * Get string representation of the backend's version.
      *
-     * @return String representation of the backend's name
+     * @return String representation of the backend's version
      */
     @JsonIgnore
-    public String getName () {
-	if (this.name == null)
-	    return null;
-	return this.name;
+    public String getVersion () {
+	return this.version;
     };
 
+
     /**
      * Set the string representation of the backend's name.
      * All nodes in a cluster should have the same backend name.
@@ -90,17 +76,19 @@
 	return this;
     };
 
+
     /**
-     * Get string representation of the node's name.
-     * Each node in a cluster has a unique name.
+     * Get string representation of the backend's name.
+     * All nodes in a cluster should have the same backend name.
      *
-     * @return String representation of the node's name
+     * @return String representation of the backend's name
      */
     @JsonIgnore
-    public String getNode () {
-	return this.node;
+    public String getName () {
+	return this.name;
     };
 
+
     /**
      * Set the string representation of the node's name.
      * Each node in a cluster has a unique name.
@@ -115,79 +103,154 @@
     };
 
 
+    /**
+     * Get string representation of the node's name.
+     * Each node in a cluster has a unique name.
+     *
+     * @return String representation of the node's name
+     */
     @JsonIgnore
-    public void setTimeExceeded (boolean timeout) {
-	if (timeout)
-	    this.addWarning(682, "Search time exceeded");
-	this.timeExceeded = timeout;
+    public String getNode () {
+	return this.node;
     };
 
 
+    /**
+     * Set to <tt>true</tt> if time is exceeded
+     * based on a timeout.
+     *
+     * <p>
+     * Will add a warning (682) to the output.
+     *
+     * @param timeout Either <tt>true</tt> or <tt>false</tt>, in case the response
+     *        timed out
+     * @return KorapResponse object for chaining
+     */
+    @JsonIgnore
+    public KorapResponse setTimeExceeded (boolean timeout) {
+	if (timeout)
+	    this.addWarning(682, "Response time exceeded");
+	this.timeExceeded = timeout;
+	return this;
+    };
+
+
+    /**
+     * Check if the response time was exceeded.
+     *
+     * @return <tt>true</tt> in case the response had a timeout,
+     *         otherwise <tt>false</tt>
+     */
     @JsonIgnore
     public boolean getTimeExceeded () {
 	return this.timeExceeded;
     };
 
 
+    /**
+     * Set the benchmark as timestamp differences.
+     *
+     * @param ts1 Starting time of the benchmark
+     * @param ts2 Ending time of the benchmark
+     * @return KorapResponse object for chaining
+     */
     @JsonIgnore
-    public KorapResponse setBenchmark (long t1, long t2) {
+    public KorapResponse setBenchmark (long ts1, long ts2) {
         this.benchmark =
-                (t2 - t1) < 100_000_000 ?
+	    (ts2 - ts1) < 100_000_000 ?
 	    // Store as miliseconds
-	    (((double) (t2 - t1) * 1e-6) + " ms") :
+	    (((double) (ts2 - ts1) * 1e-6) + " ms") :
 	    // Store as seconds
-	    (((double) (t2 - t1) / 1000000000.0) + " s");
+	    (((double) (ts2 - ts1) / 1000000000.0) + " s");
 	return this;
     };
 
+
+    /**
+     * Set the benchmark as a string representation.
+     *
+     * @param bm String representation of a benchmark
+     *           (including trailing time unit)
+     * @return KorapResponse for chaining
+     */
     @JsonIgnore
     public KorapResponse setBenchmark (String bm) {
 	this.benchmark = bm;
 	return this;
     };
 
+
+    /**
+     * Get the benchmark time as a string.
+     *
+     * @return String representation of the benchmark
+     *         (including trailing time unit)
+     */
     @JsonIgnore
     public String getBenchmark () {
         return this.benchmark;
     };
 
+
+    /**
+     * Set the listener URI as a String. This is probably the localhost
+     * with an arbitrary port, like
+     *
+     * <p>
+     * <blockquote><pre>
+     *   http://localhost:8080/
+     * </pre></blockquote>
+     *
+     * @param listener String representation of the listener URI
+     * @return KorapResponse object for chaining
+     */
     @JsonIgnore
     public KorapResponse setListener (String listener) {
 	this.listener = listener;
 	return this;
     };
 
+
+    /**
+     * Get the listener URI as a string.
+     *
+     * @return The listener URI as a string representation
+     */
     @JsonIgnore
     public String getListener () {
 	return this.listener;
-    }
+    };
+
 
     /**
-     * Serialize response to JSON node.
+     * Serialize response as a JsonNode.
+     *
+     * @return JsonNode representation of the response
      */
     @Override
-    public JsonNode toJSONnode () {
+    public JsonNode toJsonNode () {
 
 	// Get notifications json response
-	ObjectNode json = (ObjectNode) super.toJSONnode();
+	ObjectNode json = (ObjectNode) super.toJsonNode();
 
 	StringBuilder sb = new StringBuilder();
         if (this.getName() != null) {
 	    sb.append(this.getName());
 
 	    if (this.getVersion() != null)
-		sb.append("-").append(this.getVersion());
-	}
-        else if (this.getVersion() != null) {
-	    sb.append(this.getVersion());
+		sb.append("-");
 	};
 
-	if (this.timeExceeded)
-	    json.put("timeExceeded", true);
+	// No name but version is given
+	if (this.getVersion() != null)
+	    sb.append(this.getVersion());
 
 	if (sb.length() > 0)
 	    json.put("version", sb.toString());
 
+	if (this.timeExceeded)
+	    json.put("timeExceeded", true);
+
         if (this.getNode() != null)
             json.put("node", this.getNode());
 
@@ -199,4 +262,43 @@
 
 	return (JsonNode) json;
     };
+
+    /**
+     * Serialize response as a JSON string.
+     * <p>
+     * <blockquote><pre>
+     * {
+     *   "version" : "Lucene-Backend-0.49.1",
+     *   "timeExceeded" : true,
+     *   "node" : "Tanja",
+     *   "listener" : "http://localhost:8080/",
+     *   "benchmark" : "12.3s",
+     *   "errors": [
+     *     [123, "You are not allowed to serialize these messages"],
+     *     [124, "Your request was invalid"]
+     *   ],
+     *   "messages" : [
+     *     [125, "Class is deprecated", "Notifications"]
+     *   ]
+     * }
+     * </pre></blockquote>
+     *
+     * @return String representation of the response
+     */
+    public String toJsonString () {
+	String msg = "";
+	try {
+	    return mapper.writeValueAsString(this.toJsonNode());
+	}
+	catch (Exception e) {
+	    // Bad in case the message contains quotes!
+	    msg = ", \"" + e.getLocalizedMessage() + "\"";
+	};
+
+	return
+	    "{\"errors\":["+
+	    "[620, " +
+	    "\"Unable to generate JSON\"" + msg + "]" +
+	    "]}";
+    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/response/Message.java b/src/main/java/de/ids_mannheim/korap/response/Message.java
index 1fb1709..9a0c91b 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Message.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Message.java
@@ -136,7 +136,7 @@
      *
      * @return JsonNode representation of the message
      */
-    public JsonNode toJSONnode () {
+    public JsonNode toJsonNode () {
 	ArrayNode message = mapper.createArrayNode();
 
 	if (this.code != 0)
@@ -159,10 +159,10 @@
      *
      * @return String representation of the message
      */
-    public String toJSON () {
+    public String toJsonString () {
 	String msg = "";
 	try {
-	    return mapper.writeValueAsString(this.toJSONnode());
+	    return mapper.writeValueAsString(this.toJsonNode());
 	}
 	catch (Exception e) {
 	    // Bad in case the message contains quotes!
diff --git a/src/main/java/de/ids_mannheim/korap/response/Messages.java b/src/main/java/de/ids_mannheim/korap/response/Messages.java
index 2239842..c78e6aa 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Messages.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Messages.java
@@ -228,10 +228,10 @@
      *
      * @return JsonNode representation of all messages
      */
-    public JsonNode toJSONnode () {
+    public JsonNode toJsonNode () {
 	ArrayNode messageArray = mapper.createArrayNode();
 	for (Message msg : this.messages)
-	    messageArray.add(msg.toJSONnode());
+	    messageArray.add(msg.toJsonNode());
 	return (JsonNode) messageArray;
     };
 
@@ -248,10 +248,10 @@
      *
      * @return String representation of all messages
      */
-    public String toJSON () {
+    public String toJsonString () {
 	String msg = "";
 	try {
-	    return mapper.writeValueAsString(this.toJSONnode());
+	    return mapper.writeValueAsString(this.toJsonNode());
 	}
 	catch (Exception e) {
 	    // Bad in case the message contains quotes!
diff --git a/src/main/java/de/ids_mannheim/korap/response/Notifications.java b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
index 4b985f7..9074828 100644
--- a/src/main/java/de/ids_mannheim/korap/response/Notifications.java
+++ b/src/main/java/de/ids_mannheim/korap/response/Notifications.java
@@ -28,7 +28,7 @@
  *     for (Message msg : n.getWarnings())
  *       System.err.out(msg.getCode() + ": " + msg.getMessage());
  *   };
- *   System.err.println(n.toJSON());
+ *   System.err.println(n.toJsonString());
  * </pre></blockquote>
  *
  * @author Nils Diewald
@@ -361,20 +361,36 @@
 
 
     /**
+     * Clear all notifications.
+     *
+     * @return Notification object for chaining
+     */
+    public Notifications clearNotifications () {
+	if (this.warnings != null)
+	    this.warnings.clear();
+	if (this.messages != null)
+	    this.messages.clear();
+	if (this.errors != null)
+	    this.errors.clear();
+	return this;
+    };
+
+
+    /**
      * Serialize Notifications as a JsonNode.
      *
      * @return JsonNode representation of all warnings, errors, and messages
      */
-    public JsonNode toJSONnode () {
+    public JsonNode toJsonNode () {
 	ObjectNode json =  mapper.createObjectNode();
 
 	// Add messages
 	if (this.hasWarnings())
-	    json.put("warnings", this.getWarnings().toJSONnode());
+	    json.put("warnings", this.getWarnings().toJsonNode());
 	if (this.hasErrors())
-	    json.put("errors", this.getErrors().toJSONnode());
+	    json.put("errors", this.getErrors().toJsonNode());
 	if (this.hasMessages())
-	    json.put("messages", this.getMessages().toJSONnode());
+	    json.put("messages", this.getMessages().toJsonNode());
 
 	return (JsonNode) json;
     };
@@ -396,10 +412,10 @@
      *
      * @return String representation of all warnings, errors, and messages
      */
-    public String toJSON () {
+    public String toJsonString () {
 	String msg = "";
 	try {
-	    JsonNode node = this.toJSONnode();
+	    JsonNode node = this.toJsonNode();
 	    if (node == null)
 		return "{}";
 	    return mapper.writeValueAsString(node);
@@ -415,19 +431,4 @@
 	    "\"Unable to generate JSON\"" + msg + "]" +
 	    "]}";
     };
-
-    /**
-     * Clear all notifications.
-     *
-     * @return Notification object for chaining
-     */
-    public Notifications clearNotifications () {
-	if (this.warnings != null)
-	    this.warnings.clear();
-	if (this.messages != null)
-	    this.messages.clear();
-	if (this.errors != null)
-	    this.errors.clear();
-	return this;
-    };
 };
diff --git a/src/main/java/de/ids_mannheim/korap/server/Resource.java b/src/main/java/de/ids_mannheim/korap/server/Resource.java
index 6a663ae..f27b14a 100644
--- a/src/main/java/de/ids_mannheim/korap/server/Resource.java
+++ b/src/main/java/de/ids_mannheim/korap/server/Resource.java
@@ -101,7 +101,7 @@
 	);
 	*/
 	kresp.addMessage(680, "Server is up and running!");
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
     
 
@@ -137,7 +137,7 @@
 
 	if (index == null) {
 	    kresp.addError(601, "Unable to find index");
-	    return kresp.toJSON();
+	    return kresp.toJsonString();
 	};
 
 	kresp.setVersion(index.getVersion());
@@ -152,12 +152,12 @@
 	// TODO: This may be a field error!
 	catch (IOException e) {
 	    kresp.addError(602, "Unable to add document to index");
-	    return kresp.toJSON();
+	    return kresp.toJsonString();
 	};
 
 	// Set HTTP to 200
 	kresp.addMessage(681, "Document was added successfully", ID);
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
 
 
@@ -177,7 +177,7 @@
 
 	if (index == null) {
 	    kresp.addError(601, "Unable to find index");
-	    return kresp.toJSON();
+	    return kresp.toJsonString();
 	};
 
 	kresp.setVersion(index.getVersion());
@@ -190,11 +190,11 @@
 	catch (IOException e) {
 	    // Set HTTP to ???
 	    kresp.addError(603, "Unable to commit staged data to index");
-	    return kresp.toJSON();
+	    return kresp.toJsonString();
 	};
 
 	// Set HTTP to ???
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
 
 
@@ -234,12 +234,12 @@
 		// Only return the first match per text
 		ks.setItemsPerResource(1);
 
-		return ks.run(index).toJSON();
+		return ks.run(index).toJsonString();
 	    };
 	    KorapResult kr = new KorapResult();
 	    kr.setNode(KorapNode.getName());
 	    kr.addError(610, "Missing request parameters", "No unique IDs were given");
-	    return kr.toJSON();
+	    return kr.toJsonString();
 	};
 
 	KorapResponse kresp = new KorapResponse();
@@ -249,7 +249,7 @@
 
 	kresp.addError(601, "Unable to find index");
 	
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
 
 
@@ -274,7 +274,7 @@
 	    KorapResponse kresp = new KorapResponse();
 	    kresp.setNode(KorapNode.getName());
 	    kresp.addError(601, "Unable to find index");
-  	    return kresp.toJSON();
+  	    return kresp.toJsonString();
 	};
 
 	// Get the database
@@ -289,7 +289,7 @@
 	    MatchCollector result = index.collect(ks, mc);
 
 	    result.setNode(KorapNode.getName());
-	    return result.toJSON();
+	    return result.toJsonString();
 	}
 	catch (SQLException e) {
 	    log.error(e.getLocalizedMessage());
@@ -301,7 +301,7 @@
 	kresp.setVersion(index.getVersion());
 
 	kresp.addError(604, "Unable to connect to database");
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
 
 
@@ -331,7 +331,7 @@
         if (index != null) {
             KorapResult kr = new KorapSearch(json).run(index);
 	    kr.setNode(KorapNode.getName());
-	    return kr.toJSON();
+	    return kr.toJsonString();
 	};
 
 	KorapResponse kresp = new KorapResponse();
@@ -340,7 +340,7 @@
 	kresp.setVersion(index.getVersion());
 
 	kresp.addError(601, "Unable to find index");
-	return kresp.toJSON();
+	return kresp.toJsonString();
     };
 
     @GET
@@ -396,7 +396,7 @@
 		    includeSpans,
 		    includeHighlights,
 		    extendToSentence
-		).toJSON();
+		).toJsonString();
             }
 
 	    // Nothing found
@@ -404,14 +404,14 @@
 		// Todo: Make KorapMatch rely on KorapResponse!
                 KorapMatch km = new KorapMatch();
                 km.addError(qe.getErrorCode(), qe.getMessage());
-                return km.toJSON();
+                return km.toJsonString();
             }
 	};
 
 	// Response with error message
         KorapMatch km = new KorapMatch();
         km.addError(601, "Unable to find index");
-        return km.toJSON();
+        return km.toJsonString();
     };
 
     /*
diff --git a/src/test/java/de/ids_mannheim/korap/TestSimple.java b/src/test/java/de/ids_mannheim/korap/TestSimple.java
index a86e537..ecea801 100644
--- a/src/test/java/de/ids_mannheim/korap/TestSimple.java
+++ b/src/test/java/de/ids_mannheim/korap/TestSimple.java
@@ -89,7 +89,7 @@
 	
 	try {
 	    String json = getString(jsonFile);
-	    sqwi = new KorapQuery("tokens").fromJSON(json);
+	    sqwi = new KorapQuery("tokens").fromJson(json);
 	}
 	catch (QueryException e) {
 	    fail(e.getMessage());
diff --git a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
index 78e3909..6e85f27 100644
--- a/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
+++ b/src/test/java/de/ids_mannheim/korap/benchmark/TestBenchmarkSpans.java
@@ -52,7 +52,7 @@
 	t2 = System.nanoTime();
 
 	// assertEquals("TotalResults", 30751, kr.getTotalResults());
-	assertEquals("TotalResults",  4803739, kr.getTotalResults());
+	assertEquals("TotalResults",  kr.getTotalResults(), 4803739);
 
 	// System.err.println(kr.toJSON());
 
@@ -105,7 +105,7 @@
 	double length = 0;
 	for (int i = 1; i <= rounds; i++) {
 	    kr = new KorapSearch(json).run(ki);
-	    length += kr.toJSON().length();
+	    length += kr.toJsonString().length();
 	};
 	t2 = System.nanoTime();
 
@@ -152,7 +152,7 @@
 
 	// System.err.println(kr.getMatch(0).toJSON());
 
-	assertEquals("TotalResults1", 4116282, kr.getTotalResults());
+	assertEquals("TotalResults1", kr.getTotalResults(), 4116282);
 	assertEquals("TotalResults2", kr.getTotalResults(), ki.numberOf("sentences"));
 
 	double seconds = (double)(t2-t1) / 1000000000.0;
@@ -227,7 +227,7 @@
 
 	/** HERE IS A BUG! */
 
-	System.err.println(kr.toJSON());
+	System.err.println(kr.toJsonString());
 
 
 
@@ -337,7 +337,7 @@
 	};
 	t2 = System.nanoTime();
 
-	assertEquals("TotalResults", 70229, kr.getTotalResults());
+	assertEquals("TotalResults", kr.getTotalResults(), 70229);
 
 	// System.err.println(kr.toJSON());
 
@@ -371,7 +371,7 @@
 	
 	try {
 	    String json = getString(jsonFile);
-	    sqwi = new KorapQuery("tokens").fromJSON(json);
+	    sqwi = new KorapQuery("tokens").fromJson(json);
 	}
 	catch (QueryException e) {
 	    fail(e.getMessage());
diff --git a/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionLegacy.java b/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionLegacy.java
index 4a54d61..a169a8f 100644
--- a/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionLegacy.java
+++ b/src/test/java/de/ids_mannheim/korap/collection/TestKorapCollectionLegacy.java
@@ -83,7 +83,7 @@
 	SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
 
 	KorapResult kr = kc.search(query);
-	assertEquals(70, kr.totalResults());
+	assertEquals(kr.getTotalResults(), 70);
 
 	kc.extend( kf.and("textClass", "uninteresting") );
 	assertEquals("Documents", 1, kc.numberOf("documents"));
@@ -160,7 +160,7 @@
 	SpanQuery query = kq.seg("opennlp/p:NN").with("tt/p:NN").toQuery();
 
 	KorapResult kr = kc.search(query);
-	assertEquals(70, kr.totalResults());
+	assertEquals(kr.getTotalResults(), 70);
 
 	kc.extend( kf.and("textClass", "uninteresting") );
 	assertEquals("Documents", 1, kc.numberOf("documents"));
@@ -214,7 +214,7 @@
 
 	KorapResult kr = kc.search(query);
 
-	assertEquals(369, kr.totalResults());
+	assertEquals(kr.getTotalResults(), 369);
 
 	kc.filter( kf.and("corpusID", "QQQ") );
 
@@ -267,6 +267,6 @@
 	assertEquals("Tokens",   1229, kc.numberOf("tokens"));
 
 	kr = kc.search(sq);
-        assertEquals(39,kr.getTotalResults());
+        assertEquals((long) 39, kr.getTotalResults());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
index 8f59345..b3b5736 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestClass.java
@@ -30,7 +30,7 @@
 		
 		String jsonPath = getClass().getResource("/queries/poly1.json").getFile();
 		String jsonQuery = readFile(jsonPath);
-		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON(
+		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJson(
 				jsonQuery
 		);
 		
@@ -63,7 +63,7 @@
 		
 		String jsonPath = getClass().getResource("/queries/poly4.json").getFile();
 		String jsonQuery = readFile(jsonPath);
-		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON(
+		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJson(
 				jsonQuery
 		);
 		SpanQuery sq = sqwi.toQuery();
@@ -85,7 +85,7 @@
 			);
 		}
 		*/
-		assertEquals(495, kr.getTotalResults());
+		assertEquals((long) 495, kr.getTotalResults());
 		assertEquals(3, kr.getMatch(0).getStartPos());
 		assertEquals(5, kr.getMatch(0).getEndPos());
 		
diff --git a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
index 3e5bbf3..5542e44 100644
--- a/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
+++ b/src/test/java/de/ids_mannheim/korap/highlight/TestHighlight.java
@@ -191,7 +191,7 @@
 	KorapQuery kq = new KorapQuery("base");
 	SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a"))).or(kq._(2, kq.seg("s:b"))).toQuery();
 	KorapResult kr = ki.search(q);
-	assertEquals(14, kr.getTotalResults());
+	assertEquals((long) 14, kr.getTotalResults());
 	assertEquals("[{1:a}]bab", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("a[{2:b}]ab", kr.getMatch(1).getSnippetBrackets());
 	assertEquals("ab[{1:a}]b", kr.getMatch(2).getSnippetBrackets());
@@ -217,7 +217,7 @@
 	qs.getContext().left.setToken(true).setLength((short) 1);
 	qs.getContext().right.setToken(true).setLength((short) 1);
 	kr = ki.search(qs);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals((long) 10, kr.getTotalResults());
 
 	assertEquals("[{1:a}]b ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... b[{2:a}]b", kr.getMatch(1).getSnippetBrackets());
@@ -233,7 +233,7 @@
 	qs.getContext().left.setToken(true).setLength((short) 0);
 	qs.getContext().right.setToken(true).setLength((short) 0);
 	kr = ki.search(qs);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals((long) 10, kr.getTotalResults());
 
 	assertEquals("[{1:a}] ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... [{2:a}] ...", kr.getMatch(1).getSnippetBrackets());
@@ -251,7 +251,7 @@
 	qs.getContext().left.setToken(true).setLength((short) 0);
 	qs.getContext().right.setToken(true).setLength((short) 0);
 	kr = ki.search(qs);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals((long) 10, kr.getTotalResults());
 
 	assertEquals("[{3:{1:a}}] ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... [{3:{2:a}}] ...", kr.getMatch(1).getSnippetBrackets());
@@ -285,7 +285,7 @@
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
 	assertEquals(kr.getQuery(),"{15: tokens:s:Alphabet}");
-	assertEquals(kr.totalResults(),7);
+	assertEquals(kr.getTotalResults(),7);
 	assertEquals(kr.getStartIndex(),0);
 	assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{15:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
 	assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><em class=\"class-15 level-0\">Alphabet</em></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
@@ -297,7 +297,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 	assertEquals(kr.getQuery(),"{16: tokens:s:Alphabet}");
-	assertEquals(kr.totalResults(),7);
+	assertEquals(kr.getTotalResults(),7);
 	assertEquals(kr.getStartIndex(),0);
 	assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{16:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
 	assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><em class=\"class-16 level-0\">Alphabet</em></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
@@ -308,7 +308,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 	assertEquals(kr.getQuery(),"{127: tokens:s:Alphabet}");
-	assertEquals(kr.totalResults(),7);
+	assertEquals(kr.getTotalResults(),7);
 	assertEquals(kr.getStartIndex(),0);
 	assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [{127:Alphabet}] stammende Urform des Buchstaben ist wahrscheinlich ...");
 	assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\"><em class=\"class-127 level-0\">Alphabet</em></span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
@@ -319,7 +319,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 	assertEquals(kr.getQuery(),"{255: tokens:s:Alphabet}");
-	assertEquals(kr.totalResults(),7);
+	assertEquals(kr.getTotalResults(),7);
 	assertEquals(kr.getStartIndex(),0);
 	assertEquals(kr.getMatch(0).getSnippetBrackets(),"... 2. Herkunft Die aus dem proto-semitischen [Alphabet] stammende Urform des Buchstaben ist wahrscheinlich ...");
 	assertEquals(kr.getMatch(0).getSnippetHTML(),"<span class=\"context-left\"><span class=\"more\"></span>2. Herkunft Die aus dem proto-semitischen </span><span class=\"match\">Alphabet</span><span class=\"context-right\"> stammende Urform des Buchstaben ist wahrscheinlich<span class=\"more\"></span></span>");
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
index cdf5be1..293286b 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestAttributeIndex.java
@@ -99,7 +99,7 @@
 		
 		kr = ki.search(sq, (short) 10);
 		
-		assertEquals(4, kr.getTotalResults());
+		assertEquals((long) 4, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(0,kr.getMatch(1).getStartPos());
@@ -132,7 +132,7 @@
 		
 		kr = ki.search(sq, (short) 10);
 				
-		assertEquals(4, kr.getTotalResults());
+		assertEquals((long) 4, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(3,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
@@ -154,7 +154,7 @@
 		
 		kr = ki.search(sq, (short) 10);
 		
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(6,kr.getMatch(1).getStartPos());
@@ -172,7 +172,7 @@
 				sql, true);
 		
 		kr = ki.search(sq, (short) 10);
-		assertEquals(1, kr.getTotalResults());
+		assertEquals((long) 1, kr.getTotalResults());
 		assertEquals(5,kr.getMatch(0).getStartPos());
 		assertEquals(6,kr.getMatch(0).getEndPos());
 	}	
@@ -197,7 +197,7 @@
 		
 		kr = ki.search(sq, (short) 10);
 		
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(5,kr.getMatch(1).getStartPos());
@@ -226,7 +226,7 @@
 				sql, true);
 		
 		kr = ki.search(sq, (short) 10);
-		assertEquals(6,kr.getTotalResults());
+		assertEquals((long) 6,kr.getTotalResults());
 		
 		SpanNextQuery snq = new SpanNextQuery(
 				new SpanTermQuery(new Term("base", "s:e"))
@@ -234,7 +234,7 @@
 		
 		kr = ki.search(snq, (short) 10);
 		
-		assertEquals(1,kr.getTotalResults());
+		assertEquals((long) 1,kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getLocalDocID());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(5,kr.getMatch(0).getEndPos());		
@@ -254,7 +254,7 @@
 				new SpanTermQuery(new Term("base","@:class=book")), 
 				true);
 		kr = ki.search(saq, (short) 10);
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		
 		/*for (int i=0; i< kr.getTotalResults(); i++){
 			System.out.println(
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
index 7368843..2397e82 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestClassIndex.java
@@ -63,52 +63,52 @@
         );
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("StartPos (0)", 7, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... bcabca[ba]c", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "... bcabca[ba]c", kr.getMatch(0).snippetBrackets());
 	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\">" +
 			"</span>bcabca</span><span class=\"match\">ba</span><span class=\"context-right" +
-			"\">c</span>", kr.match(0).snippetHTML());
+			"\">c</span>", kr.getMatch(0).snippetHTML());
 
 	sq = new SpanTermQuery(new Term("base", "s:b"));
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "a[b]cabcab ...", kr.getMatch(0).snippetBrackets());
 
 
 	assertEquals("SnippetHTML (0)", "<span class=\"context-left\">a</span><span class=\"match\">" +
 			"b</span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", 
-			kr.match(0).snippetHTML());
+			kr.getMatch(0).snippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[b]cabac", kr.match(1).snippetBrackets());
-	assertEquals("StartPos (2)", 7, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
-	assertEquals("SnippetBrackets (2)", "... bcabca[b]ac", kr.match(2).snippetBrackets());
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abca[b]cabac", kr.getMatch(1).snippetBrackets());
+	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+	assertEquals("SnippetBrackets (2)", "... bcabca[b]ac", kr.getMatch(2).snippetBrackets());
 
 	sq = new SpanClassQuery(new SpanTermQuery(new Term("base", "s:b")));
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("snippetBrackets (0)", "a[{1:b}]cabcab ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("snippetBrackets (0)", "a[{1:b}]cabcab ...", kr.getMatch(0).snippetBrackets());
 	assertEquals("snippetHTML (0)", "<span class=\"context-left\">a</span><span class=\"match\">" +
 			"<em class=\"class-1 level-0\">b</em></span><span class=\"context-right\">cabcab<span " +
-			"class=\"more\"></span></span>", kr.match(0).snippetHTML());
+			"class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("snippetBrackets (1)", "abca[{1:b}]cabac", kr.match(1).snippetBrackets());
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("snippetBrackets (1)", "abca[{1:b}]cabac", kr.getMatch(1).snippetBrackets());
 	
-	assertEquals("StartPos (2)", 7, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
-	assertEquals("snippetBrackets (2)", "... bcabca[{1:b}]ac", kr.match(2).snippetBrackets());
+	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+	assertEquals("snippetBrackets (2)", "... bcabca[{1:b}]ac", kr.getMatch(2).snippetBrackets());
 
 
 	sq = new SpanNextQuery(
@@ -118,19 +118,19 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "[a{1:b}]cabcab ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "[a{1:b}]cabcab ...", kr.getMatch(0).snippetBrackets());
 
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a<em class=\"class-1 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
+	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a<em class=\"class-1 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
 
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abc[a{1:b}]cabac", kr.match(1).snippetBrackets());
-	assertEquals("StartPos (2)", 6, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
-	assertEquals("SnippetBrackets (2)", "abcabc[a{1:b}]ac", kr.match(2).snippetBrackets());
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abc[a{1:b}]cabac", kr.getMatch(1).snippetBrackets());
+	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+	assertEquals("SnippetBrackets (2)", "abcabc[a{1:b}]ac", kr.getMatch(2).snippetBrackets());
 
 
 	// abcabcabac
@@ -141,16 +141,16 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "[{2:a}{3:b}]cabcab ...", kr.match(0).snippetBrackets());
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abc[{2:a}{3:b}]cabac", kr.match(1).snippetBrackets());
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "[{2:a}{3:b}]cabcab ...", kr.getMatch(0).snippetBrackets());
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abc[{2:a}{3:b}]cabac", kr.getMatch(1).snippetBrackets());
 
-	assertEquals("StartPos (2)", 6, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
-	assertEquals("SnippetBrackets (2)", "abcabc[{2:a}{3:b}]ac", kr.match(2).snippetBrackets());
+	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+	assertEquals("SnippetBrackets (2)", "abcabc[{2:a}{3:b}]ac", kr.getMatch(2).snippetBrackets());
 
 	// abcabcabac
 	sq = new SpanNextQuery(
@@ -164,23 +164,21 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	// System.err.println(kr.toJSON());
-
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "abcabc[a{2:b{1:a}}]c", kr.match(0).snippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\">abcabc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "abcabc[a{2:b{1:a}}]c", kr.getMatch(0).snippetBrackets());
+	assertEquals("SnippetHTML (0)", "<span class=\"context-left\">abcabc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.getMatch(0).snippetHTML());
 
 	// Offset tokens
 	kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.match(0).snippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.getMatch(0).snippetBrackets());
+	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.getMatch(0).snippetHTML());
 
 	// Offset Characters
 	kr = ki.search(sq, 0, (short) 10, false, (short) 2, false, (short) 2);
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.match(0).snippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... bc[a{2:b{1:a}}]c", kr.getMatch(0).snippetBrackets());
+	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"><span class=\"more\"></span>bc</span><span class=\"match\">a<em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.getMatch(0).snippetHTML());
 
 
 	// System.err.println(kr.toJSON());
@@ -192,11 +190,11 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
 
 	assertEquals("Document count", 1, ki.numberOf("base", "documents"));
 	assertEquals("Token count", 10, ki.numberOf("base", "t"));
@@ -214,11 +212,11 @@
 
 	kr = ki.search(sq, (short) 2);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
 
 	assertEquals(1, ki.numberOf("base", "documents"));
 	assertEquals(10, ki.numberOf("base", "t"));
@@ -257,7 +255,7 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals("ab[cabca]bac", kr.match(0).getSnippetBrackets());
+	assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
 	System.err.println();
 	*/
 
@@ -268,7 +266,7 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals("abc[abcab}ac]", kr.match(0).getSnippetBrackets());
+	assertEquals("abc[abcab}ac]", kr.getMatch(0).getSnippetBrackets());
 	System.err.println();
 
 	*/
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
index 8d480c0..7e6413e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestDistanceExclusionIndex.java
@@ -32,18 +32,18 @@
         //ordered distance 0 to 1
         sq = createQuery("s:c","s:e",0,1,true);                
         kr = ki.search(sq, (short) 10);        
-        assertEquals(3, kr.getTotalResults());	    
-	    assertEquals(2, kr.match(0).getStartPos());
-	    assertEquals(3, kr.match(0).getEndPos());
-	    assertEquals(3, kr.match(1).getStartPos());
-	    assertEquals(4, kr.match(1).getEndPos());
-	    assertEquals(5, kr.match(2).getStartPos());
-	    assertEquals(6, kr.match(2).getEndPos());
+        assertEquals((long) 3, kr.getTotalResults());	    
+	    assertEquals(2, kr.getMatch(0).getStartPos());
+	    assertEquals(3, kr.getMatch(0).getEndPos());
+	    assertEquals(3, kr.getMatch(1).getStartPos());
+	    assertEquals(4, kr.getMatch(1).getEndPos());
+	    assertEquals(5, kr.getMatch(2).getStartPos());
+	    assertEquals(6, kr.getMatch(2).getEndPos());
         
         // Unordered
         sq = createQuery("s:c","s:e",0,1,false);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(2, kr.getTotalResults());
+        assertEquals((long) 2, kr.getTotalResults());
     }
 	
 	/** Multiple docs, unordered
@@ -59,8 +59,8 @@
         // ---- Distance 0 to 1
         sq = createQuery("s:c","s:e",0,1,false);                
         kr = ki.search(sq, (short) 10);        
-        assertEquals(5, kr.getTotalResults());	    
-	    assertEquals(1, kr.match(3).getLocalDocID());
+        assertEquals((long) 5, kr.getTotalResults());	    
+	    assertEquals(1, kr.getMatch(3).getLocalDocID());
 	}
 	
 	/** Secondspans' document number is bigger than firstspans' 
@@ -77,7 +77,7 @@
         // Unordered
         sq = createQuery("s:c","s:e",2,2,false);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(5, kr.getTotalResults());
+        assertEquals((long) 5, kr.getTotalResults());
 	}
 	
 	/** Unordered: firstspan in on the right side of the secondspan, 
@@ -93,9 +93,9 @@
         // Unordered
         sq = createQuery("s:b","s:c",2,2,false);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(1, kr.getTotalResults());
-        assertEquals(1, kr.match(0).getStartPos());
-	    assertEquals(2, kr.match(0).getEndPos());
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals(1, kr.getMatch(0).getStartPos());
+	    assertEquals(2, kr.getMatch(0).getEndPos());
     }
 	
 	/**	Element queries
@@ -114,9 +114,9 @@
         		true);        
         
         kr = ki.search(sq, (short) 10);
-        assertEquals(1, kr.getTotalResults());
-        assertEquals(9, kr.match(0).getStartPos());
-	    assertEquals(10, kr.match(0).getEndPos());
+        assertEquals((long) 1, kr.getTotalResults());
+        assertEquals(9, kr.getMatch(0).getStartPos());
+	    assertEquals(10, kr.getMatch(0).getEndPos());
     }
 	
 	// Add skipTo test	
@@ -131,26 +131,26 @@
         //ordered distance 0 to 1
         sq = createQuery("s:d","s:b",0,1,true);
         kr = ki.search(sq, (short) 10);
-        assertEquals(4, kr.getTotalResults());
+        assertEquals((long) 4, kr.getTotalResults());
         
 		SpanTermQuery stq = new SpanTermQuery(new Term("base", "s:c"));
 		kr = ki.search(stq, (short) 10);
-		assertEquals(6, kr.getTotalResults());
+		assertEquals((long) 6, kr.getTotalResults());
 		
 		SpanNextQuery snq = new SpanNextQuery(stq,sq);		
         kr = ki.search(snq, (short) 10);
-        assertEquals(2, kr.getTotalResults());
-        assertEquals(3, kr.match(0).getStartPos());
-	    assertEquals(5, kr.match(0).getEndPos());
-	    assertEquals(8, kr.match(1).getStartPos());
-	    assertEquals(10, kr.match(1).getEndPos());
+        assertEquals((long) 2, kr.getTotalResults());
+        assertEquals(3, kr.getMatch(0).getStartPos());
+	    assertEquals(5, kr.getMatch(0).getEndPos());
+	    assertEquals(8, kr.getMatch(1).getStartPos());
+	    assertEquals(10, kr.getMatch(1).getEndPos());
 	    
         /*System.out.print(kr.getTotalResults()+"\n");
 		for (int i=0; i< kr.getTotalResults(); i++){
 			System.out.println(
-				kr.match(i).getLocalDocID()+" "+
-				kr.match(i).startPos + " " +
-				kr.match(i).endPos
+				kr.getMatch(i).getLocalDocID()+" "+
+				kr.getMatch(i).startPos + " " +
+				kr.getMatch(i).endPos
 		    );
 		}*/
 	}
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
index b124eff..eba418d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestDistanceIndex.java
@@ -103,27 +103,27 @@
         sq = createQuery("s:b","s:c",0,1,true);                
         kr = ki.search(sq, (short) 10);
 //        System.out.println(sq);
-        assertEquals(2, kr.totalResults());
-        assertEquals(0, kr.match(0).startPos);
-        assertEquals(1, kr.match(0).endPos);
-        assertEquals(1, kr.match(1).startPos);
-        assertEquals(3, kr.match(1).endPos);
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(0, kr.getMatch(0).startPos);
+        assertEquals(1, kr.getMatch(0).endPos);
+        assertEquals(1, kr.getMatch(1).startPos);
+        assertEquals(3, kr.getMatch(1).endPos);
         
         // ---- Distance 2 to 2
         sq = createQuery("s:b","s:c",2,2,true);                
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(2, kr.totalResults());
-        assertEquals(0, kr.match(0).startPos);
-        assertEquals(3, kr.match(0).endPos);
-        assertEquals(1, kr.match(1).startPos);
-        assertEquals(4, kr.match(1).endPos);
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(0, kr.getMatch(0).startPos);
+        assertEquals(3, kr.getMatch(0).endPos);
+        assertEquals(1, kr.getMatch(1).startPos);
+        assertEquals(4, kr.getMatch(1).endPos);
         
         // ---- Distance 2 to 3
         sq = createQuery("s:b","s:c",2,3,true);                
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(3, kr.totalResults());
+        assertEquals(kr.getTotalResults(), 3);
         
         ki.close();
     }
@@ -144,7 +144,7 @@
 	    SpanQuery sq = createQuery("s:c","s:d",1,3,true);                
 	    kr = ki.search(sq, (short) 10);
 	        	    
-	    assertEquals(4, kr.getTotalResults());
+	    assertEquals((long) 4, kr.getTotalResults());
 	    assertEquals(2, kr.getMatch(0).startPos);
 	    assertEquals(5, kr.getMatch(0).endPos);
 	    assertEquals(3, kr.getMatch(2).startPos);
@@ -157,7 +157,7 @@
 	    // Candidate list is empty, but there are secondspans in the other doc
 	    sq = createQuery("s:c","s:d",3,3,true);                
 	    kr = ki.search(sq, (short) 10);
-	    assertEquals(2, kr.getTotalResults());
+	    assertEquals((long) 2, kr.getTotalResults());
 	    
 	    ki.close();
     }
@@ -178,7 +178,7 @@
         sq = createQuery("s:c","s:d",3,3,true);    
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(2, kr.totalResults());
+        assertEquals(kr.getTotalResults(), 2);
     }
     
     /** - Firstspan.next() is in the other doc, but there is
@@ -199,7 +199,7 @@
         SpanQuery sq = createQuery("s:b","s:c",1,2,true);                
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(3, kr.totalResults());
+        assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getMatch(0).startPos);
 	    assertEquals(3, kr.getMatch(0).endPos);
 	    assertEquals(1, kr.getMatch(1).startPos);
@@ -220,7 +220,7 @@
 	    SpanQuery sq = createElementQuery("x","y",0,0,true);                
 	    kr = ki.search(sq, (short) 10);
     	
-	    assertEquals(4, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 4);
 	    assertEquals(2, kr.getMatch(0).startPos);
 	    assertEquals(7, kr.getMatch(0).endPos);
 	    assertEquals(3, kr.getMatch(1).startPos);
@@ -232,7 +232,7 @@
 	    sq = createElementQuery("y","x",1,1,true);                
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(1, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 1);
 	    assertEquals(5, kr.getMatch(0).startPos);
 	    assertEquals(10, kr.getMatch(0).endPos);
 	    
@@ -240,7 +240,7 @@
 	    sq = createElementQuery("y","x",1,2,true);                
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(2, kr.totalResults());	    
+	    assertEquals(kr.getTotalResults(), 2);	    
 	    assertEquals(4, kr.getMatch(0).startPos);
 	    assertEquals(9, kr.getMatch(0).endPos);
 	    assertEquals(5, kr.getMatch(1).startPos);
@@ -250,7 +250,7 @@
 	    sq = createElementQuery("x","x",1,2,true);
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(2, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 2);
     }
     
     /** Skip to */    
@@ -264,7 +264,7 @@
 	    SpanQuery firstClause = createQuery("s:d", "s:e", 3, 4,true);
 	    kr = ki.search(firstClause, (short) 10); 
 	    
-	    assertEquals(3, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 3);
 	    assertEquals(0, kr.getMatch(0).getLocalDocID());
 	    assertEquals(2, kr.getMatch(0).startPos);
 	    assertEquals(6, kr.getMatch(0).endPos);
@@ -281,7 +281,7 @@
 		);	    
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(1, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 1);
 	    assertEquals(4, kr.getMatch(0).startPos);
 	    assertEquals(9, kr.getMatch(0).endPos);	    
     }
@@ -296,7 +296,7 @@
 	    SpanQuery sq = createQuery("s:c", "s:c", 1, 2,true);
 	    kr = ki.search(sq, (short) 10); 
     
-	    assertEquals(3, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 3);
         assertEquals(0, kr.getMatch(0).startPos);
 	    assertEquals(3, kr.getMatch(0).endPos);
 	    assertEquals(2, kr.getMatch(1).startPos);
@@ -311,13 +311,13 @@
 	    sq = createQuery("s:e", "s:e", 1, 1,true);
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(1, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 1);
 	    
 	    // without order
 	    sq = createQuery("s:e", "s:e", 1, 1,false);
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(2, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 2);
     }    
     
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
index 23bcead..2fde5e5 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceExclusionIndex.java
@@ -96,9 +96,9 @@
         SpanQuery sq;
         sq = createQuery("s","s:d","s:c",0,0,false,true);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(1, kr.totalResults());
-        assertEquals(6, kr.match(0).startPos);
-        assertEquals(7, kr.match(0).endPos);
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(6, kr.getMatch(0).startPos);
+        assertEquals(7, kr.getMatch(0).endPos);
     }
     
     /** There is another firstspan within max distance
@@ -114,15 +114,15 @@
 	    sq = createQuery("s","s:c","s:d",0,0,false,true);                
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(4, kr.totalResults());
-	    assertEquals(0, kr.match(0).startPos);
-        assertEquals(1, kr.match(0).endPos);
-        assertEquals(2, kr.match(1).startPos);
-        assertEquals(3, kr.match(1).endPos);
-        assertEquals(3, kr.match(2).startPos);
-        assertEquals(4, kr.match(2).endPos);
-        assertEquals(8, kr.match(3).startPos);
-        assertEquals(9, kr.match(3).endPos);
+	    assertEquals(kr.getTotalResults(), 4);
+	    assertEquals(0, kr.getMatch(0).startPos);
+        assertEquals(1, kr.getMatch(0).endPos);
+        assertEquals(2, kr.getMatch(1).startPos);
+        assertEquals(3, kr.getMatch(1).endPos);
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(4, kr.getMatch(2).endPos);
+        assertEquals(8, kr.getMatch(3).startPos);
+        assertEquals(9, kr.getMatch(3).endPos);
     }
     
     /** Distance 0-1, ordered, unordered
@@ -136,18 +136,18 @@
         // unordered
         sq = createQuery("s","s:c","s:e",0,1,false,true);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(1, kr.totalResults());
-        assertEquals(5, kr.match(0).startPos);
-        assertEquals(6, kr.match(0).endPos);
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(5, kr.getMatch(0).startPos);
+        assertEquals(6, kr.getMatch(0).endPos);
         
         //ordered 
         sq = createQuery("s","s:c","s:e",0,1,true,true);                
         kr = ki.search(sq, (short) 10);
-        assertEquals(3, kr.totalResults());
-        assertEquals(2, kr.match(0).startPos);
-        assertEquals(3, kr.match(0).endPos);
-        assertEquals(3, kr.match(1).startPos);
-        assertEquals(4, kr.match(1).endPos);
+        assertEquals(kr.getTotalResults(), 3);
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(3, kr.getMatch(0).endPos);
+        assertEquals(3, kr.getMatch(1).startPos);
+        assertEquals(4, kr.getMatch(1).endPos);
     }
     
 	/** Multiple documents, ordered
@@ -164,14 +164,14 @@
         sq = createQuery("s","s:d","s:e",1,1,true,true);                
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(3, kr.totalResults());
-	    assertEquals(4, kr.match(0).startPos);
-        assertEquals(5, kr.match(0).endPos);
-        assertEquals(1, kr.match(1).getLocalDocID());
-        assertEquals(2, kr.match(1).startPos);
-        assertEquals(3, kr.match(1).endPos);
-        assertEquals(8, kr.match(2).startPos);
-        assertEquals(9, kr.match(2).endPos);
+        assertEquals(kr.getTotalResults(), 3);
+	    assertEquals(4, kr.getMatch(0).startPos);
+        assertEquals(5, kr.getMatch(0).endPos);
+        assertEquals(1, kr.getMatch(1).getLocalDocID());
+        assertEquals(2, kr.getMatch(1).startPos);
+        assertEquals(3, kr.getMatch(1).endPos);
+        assertEquals(8, kr.getMatch(2).startPos);
+        assertEquals(9, kr.getMatch(2).endPos);
 	}
     
 	/** Skip to
@@ -188,19 +188,19 @@
         SpanQuery sq = createQuery("s","s:c","s:d",1,1,false,true);
         kr = ki.search(sq, (short) 10);
 
-        assertEquals(3, kr.totalResults());        
-        assertEquals(3, kr.match(2).getLocalDocID());
-        assertEquals(3, kr.match(2).startPos);
-        assertEquals(4, kr.match(2).endPos);
+        assertEquals(kr.getTotalResults(), 3);        
+        assertEquals(3, kr.getMatch(2).getLocalDocID());
+        assertEquals(3, kr.getMatch(2).startPos);
+        assertEquals(4, kr.getMatch(2).endPos);
         
         sq = new SpanNextQuery(
         		createQuery("s","s:c","s:d",1,1,false,true), 
         		new SpanTermQuery(new Term("base", "s:a")));
         
         kr = ki.search(sq, (short) 10);
-        assertEquals(1, kr.totalResults());
-        assertEquals(3, kr.match(0).getLocalDocID());
-        assertEquals(3, kr.match(0).startPos);
-        assertEquals(5, kr.match(0).endPos);
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(3, kr.getMatch(0).getLocalDocID());
+        assertEquals(3, kr.getMatch(0).startPos);
+        assertEquals(5, kr.getMatch(0).endPos);
 	}
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
index ce969db..3e7ac5d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementDistanceIndex.java
@@ -118,11 +118,11 @@
         sq = createQuery("s", "s:b", "s:c", 0, 2,true);        
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(4, kr.totalResults());
-        assertEquals(0, kr.match(0).startPos);
-        assertEquals(1, kr.match(0).endPos);
-        assertEquals(0, kr.match(1).startPos);
-        assertEquals(3, kr.match(1).endPos);         
+        assertEquals(kr.getTotalResults(), 4);
+        assertEquals(0, kr.getMatch(0).startPos);
+        assertEquals(1, kr.getMatch(0).endPos);
+        assertEquals(0, kr.getMatch(1).startPos);
+        assertEquals(3, kr.getMatch(1).endPos);         
 	}
 	
 	/** Ensure terms and elements are in the same doc
@@ -140,10 +140,10 @@
         sq = createQuery("p", "s:b", "s:d", 1, 1,true);
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(1, kr.totalResults());
-        assertEquals(2, kr.match(0).getLocalDocID());
-        assertEquals(2, kr.match(0).startPos);
-        assertEquals(4, kr.match(0).endPos);
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(2, kr.getMatch(0).getLocalDocID());
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(4, kr.getMatch(0).endPos);
         
 	}	
 	
@@ -165,10 +165,10 @@
         
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(1, kr.totalResults());
-        assertEquals(2, kr.match(0).getLocalDocID());
-        assertEquals(2, kr.match(0).startPos);
-        assertEquals(5, kr.match(0).endPos);
+        assertEquals(kr.getTotalResults(), 1);
+        assertEquals(2, kr.getMatch(0).getLocalDocID());
+        assertEquals(2, kr.getMatch(0).startPos);
+        assertEquals(5, kr.getMatch(0).endPos);
         
 	}
 	
@@ -184,11 +184,11 @@
         sq = createQuery("s", "s:b", "s:b", 1, 2,true);
         kr = ki.search(sq, (short) 10);
     		
-        assertEquals(2, kr.totalResults());
-        assertEquals(0, kr.match(0).startPos);
-        assertEquals(4, kr.match(0).endPos);
-        assertEquals(3, kr.match(1).startPos);
-        assertEquals(5, kr.match(1).endPos);
+        assertEquals(kr.getTotalResults(), 2);
+        assertEquals(0, kr.getMatch(0).startPos);
+        assertEquals(4, kr.getMatch(0).endPos);
+        assertEquals(3, kr.getMatch(1).startPos);
+        assertEquals(5, kr.getMatch(1).endPos);
         
     }
 	
@@ -211,7 +211,7 @@
         
         SpanQueryWrapper sqwi;
         try {    	    
-    	    sqwi = new KorapQuery("tokens").fromJSON(json);
+    	    sqwi = new KorapQuery("tokens").fromJson(json);
     	}
     	catch (QueryException e) {
     	    fail(e.getMessage());
@@ -223,7 +223,7 @@
         sq = sqwi.toQuery();
         kr = ki.search(sq, (short) 10);
     	
-        assertEquals(3, kr.getTotalResults());
+        assertEquals((long) 3, kr.getTotalResults());
         assertEquals(14, kr.getMatch(0).startPos);
         assertEquals(19, kr.getMatch(0).endPos);
         assertEquals(30, kr.getMatch(1).startPos);
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
index a42131f..3f14ab3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestElementIndex.java
@@ -78,21 +78,21 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 6, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 6);
 
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 1, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 9, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 2, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 6, kr.match(2).endPos);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 9, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 6, kr.getMatch(2).endPos);
 
-	assertEquals("StartPos (0)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(3).endPos);
-	assertEquals("StartPos (1)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (1)", 9, kr.match(4).endPos);
-	assertEquals("StartPos (2)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (2)", 6, kr.match(5).endPos);
+	assertEquals("StartPos (0)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(3).endPos);
+	assertEquals("StartPos (1)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (1)", 9, kr.getMatch(4).endPos);
+	assertEquals("StartPos (2)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (2)", 6, kr.getMatch(5).endPos);
 
 	// System.err.println(kr.toJSON());
     };
@@ -126,13 +126,13 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 9, kr.match(2).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 9, kr.getMatch(2).endPos);
     };
 
     @Test
@@ -228,35 +228,35 @@
 
 	// System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", 12, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 12);
 
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 0, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 0, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 0, kr.match(2).endPos);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 0, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 0, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 0, kr.getMatch(2).endPos);
 
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 12, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
 
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 12, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 1, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 9, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 2, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 6, kr.match(8).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 12, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 1, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 9, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 2, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 6, kr.getMatch(8).endPos);
 
-	assertEquals("StartPos (9)", 0, kr.match(9).startPos);
-	assertEquals("EndPos (9)", 3, kr.match(9).endPos);
-	assertEquals("StartPos (10)", 0, kr.match(10).startPos);
-	assertEquals("EndPos (10)", 6, kr.match(10).endPos);
-	assertEquals("StartPos (11)", 0, kr.match(11).startPos);
-	assertEquals("EndPos (11)", 9, kr.match(11).endPos);
+	assertEquals("StartPos (9)", 0, kr.getMatch(9).startPos);
+	assertEquals("EndPos (9)", 3, kr.getMatch(9).endPos);
+	assertEquals("StartPos (10)", 0, kr.getMatch(10).startPos);
+	assertEquals("EndPos (10)", 6, kr.getMatch(10).endPos);
+	assertEquals("StartPos (11)", 0, kr.getMatch(11).startPos);
+	assertEquals("EndPos (11)", 9, kr.getMatch(11).endPos);
     };
 
 
@@ -288,8 +288,8 @@
 
 	KorapResult kr = ki.search(sq, 0, (short) 15, false, (short) 3, false, (short) 3);
 	
-	assertEquals("... ccc[222222]fff ...", kr.match(0).getSnippetBrackets());
-	assertEquals("... fff[333333]iii ...", kr.match(1).getSnippetBrackets());
+	assertEquals("... ccc[222222]fff ...", kr.getMatch(0).getSnippetBrackets());
+	assertEquals("... fff[333333]iii ...", kr.getMatch(1).getSnippetBrackets());
     };
 
 
@@ -321,9 +321,9 @@
 
 	KorapResult kr = ki.search(sq, 0, (short) 15, false, (short) 3, false, (short) 3);
 
-	assertEquals("[111111]ccc ...", kr.match(0).getSnippetBrackets());
-	assertEquals("... ccc[222222]fff ...", kr.match(1).getSnippetBrackets());
-	assertEquals("... fff[333333]iii ...", kr.match(2).getSnippetBrackets());
+	assertEquals("[111111]ccc ...", kr.getMatch(0).getSnippetBrackets());
+	assertEquals("... ccc[222222]fff ...", kr.getMatch(1).getSnippetBrackets());
+	assertEquals("... fff[333333]iii ...", kr.getMatch(2).getSnippetBrackets());
     };
 
 
@@ -408,6 +408,6 @@
 	// System.err.println(kr.toJSON());
 	
 	assertEquals(5, ki.numberOf("documents"));
-	assertEquals("totalResults", 7, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 7);
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
index 7bf771b..20ea4be 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestFieldDocument.java
@@ -151,7 +151,6 @@
 	assertEquals(km.getPubDate().toDisplay(),"2013-06-17");
 
 	assertEquals(km.getSnippetBrackets(),"a[{3:b}]c");
-	//	System.err.println(kr.toJSON());
     };
 
 
@@ -251,7 +250,7 @@
 	
 	try {
 	    String json = getString(jsonFile);
-	    sqwi = new KorapQuery("tokens").fromJSON(json);
+	    sqwi = new KorapQuery("tokens").fromJson(json);
 	}
 	catch (QueryException e) {
 	    fail(e.getMessage());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
index 3acc821..4f73ce3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIdentifier.java
@@ -92,14 +92,16 @@
 	ki.commit();
 
 	KorapQuery kq = new KorapQuery("tokens");
-	KorapSearch ks = new KorapSearch(kq._(2,kq.seq(kq.seg("s:b")).append(kq._(kq.seg("s:a")))));
+	KorapSearch ks = new KorapSearch(
+	    kq._(2,kq.seq(kq.seg("s:b")).append(kq._(kq.seg("s:a"))))
+        );
 	KorapResult kr = ki.search(ks);
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("StartPos (0)", 7, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.match(0).endPos);
+	assertEquals("totalResults", kr.getTotalResults(),    1);
+	assertEquals("StartPos (0)", kr.getMatch(0).startPos, 7);
+	assertEquals("EndPos (0)",   kr.getMatch(0).endPos,   9);
 
-	KorapMatch km = kr.match(0);
+	KorapMatch km = kr.getMatch(0);
 
 	assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", km.snippetBrackets());
 	assertEquals("ID (0)", "match-c1!d1-p7-9(2)7-8(1)8-8", km.getID());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
index 102c917..f2d081e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMatchIndex.java
@@ -70,12 +70,12 @@
         );
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("StartPos (0)", 7, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... bcabca[b{1:a}]c", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("StartPos (0)", 7, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "... bcabca[b{1:a}]c", kr.getMatch(0).snippetBrackets());
 
-	assertEquals("Test no 'more' context", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\">b<em class=\"class-1 level-0\">a</em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
+	assertEquals("Test no 'more' context", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\">b<em class=\"class-1 level-0\">a</em></span><span class=\"context-right\">c</span>", kr.getMatch(0).snippetHTML());
 	sq = new SpanMatchModifyClassQuery(
   	     new SpanNextQuery(
                 new SpanTermQuery(new Term("base", "s:b")),
@@ -86,10 +86,10 @@
 	);
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("StartPos (0)", 8, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 9, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "... cabcab[{1:a}]c", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("StartPos (0)", 8, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 9, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "... cabcab[{1:a}]c", kr.getMatch(0).snippetBrackets());
 	sq = new SpanMatchModifyClassQuery(
             new SpanNextQuery(
 	        new SpanClassQuery(new SpanTermQuery(new Term("base", "s:a")), (byte) 2),
@@ -99,23 +99,23 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", kr.getMatch(0).snippetBrackets());
 	
 
-	assertEquals("<span class=\"context-left\">a</span><span class=\"match\"><em class=\"class-3 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
+	assertEquals("<span class=\"context-left\">a</span><span class=\"match\"><em class=\"class-3 level-0\">b</em></span><span class=\"context-right\">cabcab<span class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
 
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{3:b}]cabac", kr.match(1).snippetBrackets());
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abca[{3:b}]cabac", kr.getMatch(1).snippetBrackets());
 
-	assertEquals("<span class=\"context-left\">abca</span><span class=\"match\"><em class=\"class-3 level-0\">b</em></span><span class=\"context-right\">cabac</span>", kr.match(1).snippetHTML());
+	assertEquals("<span class=\"context-left\">abca</span><span class=\"match\"><em class=\"class-3 level-0\">b</em></span><span class=\"context-right\">cabac</span>", kr.getMatch(1).snippetHTML());
 
-	assertEquals("StartPos (2)", 7, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
-	assertEquals("SnippetBrackets (2)", "... bcabca[{3:b}]ac", kr.match(2).snippetBrackets());
+	assertEquals("StartPos (2)", 7, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
+	assertEquals("SnippetBrackets (2)", "... bcabca[{3:b}]ac", kr.getMatch(2).snippetBrackets());
 
 
 
@@ -132,26 +132,24 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	// System.err.println(kr.toJSON());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", kr.getMatch(0).snippetBrackets());
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... bcabca[{2:b{1:a}}]c", kr.match(0).snippetBrackets());
-
-	assertEquals("SnippetHTML (0) 1", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\"><em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.match(0).snippetHTML());
+	assertEquals("SnippetHTML (0) 1", "<span class=\"context-left\"><span class=\"more\"></span>bcabca</span><span class=\"match\"><em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\">c</span>", kr.getMatch(0).snippetHTML());
 
 	// Offset tokens
 	kr = ki.search(sq, 0, (short) 10, true, (short) 2, true, (short) 2);
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... ca[{2:b{1:a}}]c", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... ca[{2:b{1:a}}]c", kr.getMatch(0).snippetBrackets());
 
 
 
 	// Offset Characters
 	kr = ki.search(sq, 0, (short) 10, false, (short) 1, false, (short) 0);
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... a[{2:b{1:a}}] ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... a[{2:b{1:a}}] ...", kr.getMatch(0).snippetBrackets());
 
-	assertEquals("SnippetHTML (0) 2", "<span class=\"context-left\"><span class=\"more\"></span>a</span><span class=\"match\"><em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(0).snippetHTML());
+	assertEquals("SnippetHTML (0) 2", "<span class=\"context-left\"><span class=\"more\"></span>a</span><span class=\"match\"><em class=\"class-2 level-0\">b<em class=\"class-1 level-1\">a</em></em></span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
 
 	sq = new SpanMatchModifyClassQuery(
             new SpanClassQuery(
@@ -164,13 +162,13 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{3:{1:b}{2:c}}]abcaba ...", kr.match(0).snippetBrackets());
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{3:{1:b}{2:c}}]abac", kr.match(1).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "a[{3:{1:b}{2:c}}]abcaba ...", kr.getMatch(0).snippetBrackets());
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abca[{3:{1:b}{2:c}}]abac", kr.getMatch(1).snippetBrackets());
 
 	assertEquals("Document count", 1, ki.numberOf("base", "documents"));
 	assertEquals("Token count", 10, ki.numberOf("base", "t"));
@@ -185,7 +183,7 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	assertEquals("totalResults", 0, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 0);
 
 	sq = new SpanMatchModifyClassQuery(
             new SpanNextQuery(
@@ -201,13 +199,13 @@
 
 	kr = ki.search(sq, (short) 2);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("SnippetBrackets (0)", "a[{1:bc}]abcaba ...", kr.match(0).snippetBrackets());
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
-	assertEquals("SnippetBrackets (1)", "abca[{1:bc}]abac", kr.match(1).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("SnippetBrackets (0)", "a[{1:bc}]abcaba ...", kr.getMatch(0).snippetBrackets());
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
+	assertEquals("SnippetBrackets (1)", "abca[{1:bc}]abac", kr.getMatch(1).snippetBrackets());
 
 	assertEquals(1, ki.numberOf("base", "documents"));
 	assertEquals(10, ki.numberOf("base", "t"));
@@ -246,27 +244,27 @@
         );
 	kr = ki.search(sq, (short) 20);
 
-	assertEquals("totalResults", 7, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\">bcabca<span class=\"more\"></span></span>", kr.match(0).snippetHTML());
-	assertEquals("SnippetBrackets (0)", "[a]bcabca ...", kr.match(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 7);
+	assertEquals("SnippetBrackets (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\">bcabca<span class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
+	assertEquals("SnippetBrackets (0)", "[a]bcabca ...", kr.getMatch(0).snippetBrackets());
 
-	assertEquals("SnippetBrackets (1)", "ab[c]abcaba ...", kr.match(1).snippetBrackets());
-	assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">ab</span><span class=\"match\">c</span><span class=\"context-right\">abcaba<span class=\"more\"></span></span>", kr.match(1).snippetHTML());
+	assertEquals("SnippetBrackets (1)", "ab[c]abcaba ...", kr.getMatch(1).snippetBrackets());
+	assertEquals("SnippetBrackets (1)", "<span class=\"context-left\">ab</span><span class=\"match\">c</span><span class=\"context-right\">abcaba<span class=\"more\"></span></span>", kr.getMatch(1).snippetHTML());
 
-	assertEquals("SnippetBrackets (6)", "... abcaba[c]", kr.match(6).snippetBrackets());
-	assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span>abcaba</span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.match(6).snippetHTML());
+	assertEquals("SnippetBrackets (6)", "... abcaba[c]", kr.getMatch(6).snippetBrackets());
+	assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span>abcaba</span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.getMatch(6).snippetHTML());
 
 	kr = ki.search(sq, 0, (short) 20, true, (short) 0, true, (short) 0);
 
-	assertEquals("totalResults", 7, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "[a] ...", kr.match(0).snippetBrackets());
-	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(0).snippetHTML());
+	assertEquals("totalResults", kr.getTotalResults(), 7);
+	assertEquals("SnippetBrackets (0)", "[a] ...", kr.getMatch(0).snippetBrackets());
+	assertEquals("SnippetHTML (0)", "<span class=\"context-left\"></span><span class=\"match\">a</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(0).snippetHTML());
 
-	assertEquals("SnippetBrackets (1)", "... [c] ...", kr.match(1).snippetBrackets());
-	assertEquals("SnippetHTML (1)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.match(1).snippetHTML());
+	assertEquals("SnippetBrackets (1)", "... [c] ...", kr.getMatch(1).snippetBrackets());
+	assertEquals("SnippetHTML (1)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"><span class=\"more\"></span></span>", kr.getMatch(1).snippetHTML());
 
-	assertEquals("SnippetBrackets (6)", "... [c]", kr.match(6).snippetBrackets());
-	assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.match(6).snippetHTML());
+	assertEquals("SnippetBrackets (6)", "... [c]", kr.getMatch(6).snippetBrackets());
+	assertEquals("SnippetBrackets (6)", "<span class=\"context-left\"><span class=\"more\"></span></span><span class=\"match\">c</span><span class=\"context-right\"></span>", kr.getMatch(6).snippetHTML());
     };
 
 
@@ -300,10 +298,8 @@
 
 	kr = ki.search(sq, 0, (short) 20, true, (short) 2, true, (short) 5);
 
-	assertEquals("totalResults", 1, kr.totalResults());
-	assertEquals("SnippetBrackets (0)", "... ca[{1:ba{2:c}}]", kr.match(0).snippetBrackets());
-
-	//	System.err.println(kr.toJSON());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
+	assertEquals("SnippetBrackets (0)", "... ca[{1:ba{2:c}}]", kr.getMatch(0).snippetBrackets());
     };
 
 
@@ -341,9 +337,9 @@
 
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 3);
 
-	KorapMatch km = kr.match(0);
+	KorapMatch km = kr.getMatch(0);
 	assertEquals("StartPos (0)", 1, km.startPos);
 	assertEquals("EndPos (0)", 2, km.endPos);
 	assertEquals("SnippetBrackets (0)", "a[{3:b}]cabcab ...", km.getSnippetBrackets());
@@ -359,7 +355,7 @@
 	
 	kr = ki.search(sq, (short) 10);
 
-	km = kr.match(0);
+	km = kr.getMatch(0);
 	assertEquals("StartPos (0)", 0, km.startPos);
 	assertEquals("EndPos (0)", 1, km.endPos);
 	assertEquals("SnippetBrackets (0)", "[{2:a}]bcabca ...", km.getSnippetBrackets());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
index a3e649b..b57e888 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestMultipleDistanceIndex.java
@@ -121,7 +121,7 @@
 		kr = ki.search(mdq, (short) 10);
 		// System.out.println(mdq);
 		
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 	    assertEquals(0, kr.getMatch(0).getStartPos());
 	    assertEquals(2, kr.getMatch(0).getEndPos());
 	    assertEquals(1, kr.getMatch(1).getStartPos());
@@ -149,7 +149,7 @@
 	    SpanQuery mdq;	    
 		mdq = createQuery("s:b", "s:c", constraints,true);
 		kr = ki.search(mdq, (short) 10);		
-	    assertEquals(3, kr.getTotalResults());
+	    assertEquals((long) 3, kr.getTotalResults());
 	    assertEquals(0, kr.getMatch(0).getStartPos());
 	    assertEquals(3, kr.getMatch(0).getEndPos());
 	    assertEquals(1, kr.getMatch(1).getStartPos());
@@ -161,7 +161,7 @@
 		constraints.add(createConstraint("p", 0, 0, true, false));		
 		mdq = createQuery("s:b", "s:c", constraints,true);
 		kr = ki.search(mdq, (short) 10);
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 		
 		
 		// Unordered - two constraints
@@ -171,7 +171,7 @@
 	    	   
 	    mdq = createQuery("s:c", "s:b", constraints,false);
 	    kr = ki.search(mdq, (short) 10);
-	    assertEquals(4, kr.getTotalResults());
+	    assertEquals((long) 4, kr.getTotalResults());
 	    assertEquals(1, kr.getMatch(2).getStartPos());
 	    assertEquals(4, kr.getMatch(2).getEndPos());
 		
@@ -179,7 +179,7 @@
 		constraints.add(createConstraint("p", 0, 0, false, false));
 		mdq = createQuery("s:b", "s:c", constraints,false);
 		kr = ki.search(mdq, (short) 10);		
-		assertEquals(3, kr.getTotalResults());	
+		assertEquals((long) 3, kr.getTotalResults());	
 
 	}
     
@@ -202,7 +202,7 @@
 		mdq = createQuery("s:b", "s:e", constraints,false);
 		kr = ki.search(mdq, (short) 10);		
 
-		assertEquals(5, kr.getTotalResults());		
+		assertEquals((long) 5, kr.getTotalResults());		
 	    assertEquals(3, kr.getMatch(0).getStartPos());
 	    assertEquals(6, kr.getMatch(0).getEndPos());
 	    assertEquals(2, kr.getMatch(1).getLocalDocID());
@@ -246,7 +246,7 @@
 				new SpanTermQuery(new Term("base","s:e")));
 		kr = ki.search(sq, (short) 10);
 		
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 	    assertEquals(3, kr.getMatch(0).getStartPos());
 	    assertEquals(6, kr.getMatch(0).getEndPos());
 	    assertEquals(3, kr.getMatch(1).getLocalDocID());
@@ -272,7 +272,7 @@
 		mdq = createQuery("s:c", "s:c", constraints,false);
 		kr = ki.search(mdq, (short) 10);
 		
-		assertEquals(4, kr.getTotalResults());
+		assertEquals((long) 4, kr.getTotalResults());
 	    assertEquals(1, kr.getMatch(0).getStartPos());
 	    assertEquals(3, kr.getMatch(0).getEndPos());
 	    assertEquals(2, kr.getMatch(1).getStartPos());
@@ -302,7 +302,7 @@
 		SpanDistanceQuery sq = new SpanDistanceQuery(sx, sy, dc1, true);
 		
 		kr = ki.search(sq, (short) 10);
-		assertEquals(1, kr.getTotalResults());
+		assertEquals((long) 1, kr.getTotalResults());
 		// 4-5
 		
     	// Second constraint - element distance
@@ -310,7 +310,7 @@
 		sq = new SpanDistanceQuery(sx, sy, dc2, true);		
 		kr = ki.search(sq, (short) 10);		
 		// 0-3, 1-3, 1-4, 1-5, 3-7, 4-7
-		assertEquals(6, kr.getTotalResults());
+		assertEquals((long) 6, kr.getTotalResults());
 		
 		
     	List<DistanceConstraint> constraints = new ArrayList<DistanceConstraint>();
@@ -321,7 +321,7 @@
 		mdq = createQuery("s:b", "s:c", constraints,false);
 		kr = ki.search(mdq, (short) 10);
 		
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 	    assertEquals(1, kr.getMatch(0).getStartPos());
 	    assertEquals(5, kr.getMatch(0).getEndPos());
 	    assertEquals(4, kr.getMatch(1).getStartPos());
@@ -344,7 +344,7 @@
 				createConstraint("s", 0, 0, false, true),
 				true);
 		kr = ki.search(sq, (short) 10);
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
     	// 0-1, 1-2, 6-7
 				
 	    // Exclusion within the same sentence
@@ -355,7 +355,7 @@
 	    SpanQuery mdq;	   
 		mdq = createQuery("s:b", "s:c", constraints,false);
 		kr = ki.search(mdq, (short) 10);		
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 	    assertEquals(0, kr.getMatch(0).getStartPos());
 	    assertEquals(1, kr.getMatch(0).getEndPos());
 	    assertEquals(6, kr.getMatch(1).getStartPos());
@@ -367,14 +367,14 @@
 				createConstraint("p", 0, 0, false, true), 
 				true);
 	    kr = ki.search(sq, (short) 10);
-		assertEquals(1, kr.getTotalResults());
+		assertEquals((long) 1, kr.getTotalResults());
 		// 6-7
 	    
 		constraints.add(createConstraint("p", 0, 0, false, true));
 	    mdq = createQuery("s:b", "s:c", constraints,false);
 		kr = ki.search(mdq, (short) 10);			
 		
-	    assertEquals(1, kr.getTotalResults());
+	    assertEquals((long) 1, kr.getTotalResults());
 	    assertEquals(6, kr.getMatch(0).getStartPos());
 	    assertEquals(7, kr.getMatch(0).getEndPos());
 
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
index 8471b20..59b8525 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestNextIndex.java
@@ -71,13 +71,13 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 6, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 8, kr.match(2).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 6, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 8, kr.getMatch(2).endPos);
 	
 	sq = new SpanNextQuery(
             new SpanTermQuery(new Term("base", "s:b")),
@@ -86,11 +86,11 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
 
 	assertEquals(1, ki.numberOf("base", "documents"));
 	assertEquals(10, ki.numberOf("base", "t"));
@@ -106,11 +106,11 @@
 
 	kr = ki.search(sq, (short) 2);
 	
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 6, kr.match(1).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 6, kr.getMatch(1).endPos);
 
 	assertEquals(1, ki.numberOf("base", "documents"));
 	assertEquals(10, ki.numberOf("base", "t"));
@@ -148,7 +148,7 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals("ab[cabca]bac", kr.match(1).getSnippetBrackets());
+	assertEquals("ab[cabca]bac", kr.getMatch(1).getSnippetBrackets());
 
     };
 
@@ -183,7 +183,7 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals("abc[abcab]ac", kr.match(0).getSnippetBrackets());
+	assertEquals("abc[abcab]ac", kr.getMatch(0).getSnippetBrackets());
     };
 
     @Test
@@ -237,9 +237,9 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals(2, kr.totalResults());
-	assertEquals("abc[abcab]ac", kr.match(0).getSnippetBrackets());
-	assertEquals("xbz[xbzxb]xz", kr.match(1).getSnippetBrackets());
+	assertEquals("TotalResults", kr.getTotalResults(), 2);
+	assertEquals("abc[abcab]ac", kr.getMatch(0).getSnippetBrackets());
+	assertEquals("xbz[xbzxb]xz", kr.getMatch(1).getSnippetBrackets());
 
 	sq = new SpanNextQuery(
 	       new SpanTermQuery(new Term("base", "s:c")),
@@ -247,8 +247,8 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals(1, kr.totalResults());
-	assertEquals("ab[cabca]bac", kr.match(0).getSnippetBrackets());
+	assertEquals(kr.getTotalResults(), 1);
+	assertEquals("ab[cabca]bac", kr.getMatch(0).getSnippetBrackets());
 
 	sq = new SpanNextQuery(
 	       new SpanTermQuery(new Term("base", "s:z")),
@@ -256,8 +256,8 @@
 	);
 	
 	kr = ki.search(sq, (short) 10);
-	assertEquals(1, kr.totalResults());
-	assertEquals("xb[zxbzx]bxz", kr.match(0).getSnippetBrackets());
+	assertEquals(kr.getTotalResults(), 1);
+	assertEquals("xb[zxbzx]bxz", kr.getMatch(0).getSnippetBrackets());
     };
     
     /**
@@ -279,15 +279,15 @@
 				);
 		KorapResult kr = ki.search(sq, (short) 10);			
 				
-		assertEquals("totalResults", 2, kr.totalResults());
+		assertEquals("totalResults", kr.getTotalResults(), 2);
 		// Match #0
-		assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 4, kr.match(0).startPos);
-		assertEquals("EndPos", 6, kr.match(0).endPos);
+		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 4, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 6, kr.getMatch(0).endPos);
 		// Match #1
-		assertEquals("doc-number", 0, kr.match(1).getLocalDocID());
-		assertEquals("StartPos", 1, kr.match(1).startPos);
-		assertEquals("EndPos", 3, kr.match(1).endPos);
+		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+		assertEquals("StartPos", 1, kr.getMatch(1).startPos);
+		assertEquals("EndPos", 3, kr.getMatch(1).endPos);
 		
 		sq = new SpanNextQuery(
 				new SpanTermQuery(new Term("base","s:b")),
@@ -295,10 +295,10 @@
 			);
 		kr = ki.search(sq, (short) 10);
 		
-		assertEquals("totalResults", 1, kr.totalResults());
-		assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 2, kr.match(0).startPos);
-		assertEquals("EndPos", 4, kr.match(0).endPos);
+		assertEquals("totalResults", kr.getTotalResults(), 1);
+		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 2, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 4, kr.getMatch(0).endPos);
 	}
 	
 	/** Skip to NextSpan */
@@ -319,10 +319,10 @@
 			);
 		
 		KorapResult kr = ki.search(sq, (short) 10);			
-		assertEquals("totalResults", 1, kr.totalResults());
-		assertEquals("doc-number", 2, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 0, kr.match(0).startPos);
-		assertEquals("EndPos", 3, kr.match(0).endPos);	
+		assertEquals("totalResults", kr.getTotalResults(), 1);
+		assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 0, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 3, kr.getMatch(0).endPos);	
 		
 	}
 
@@ -340,10 +340,10 @@
 		
 		KorapResult kr = ki.search(sq.toQuery(), (short) 10);			
 
-		assertEquals("totalResults", 3, kr.totalResults());
-		assertEquals("doc-number", "match-doc-0-p2-5", kr.match(0).getID());
-		assertEquals("doc-number", "match-doc-2-p2-4", kr.match(1).getID());
-		assertEquals("doc-number", "match-doc-3-p2-5", kr.match(2).getID());
+		assertEquals("totalResults", kr.getTotalResults(), 3);
+		assertEquals("doc-number", "match-doc-0-p2-5", kr.getMatch(0).getID());
+		assertEquals("doc-number", "match-doc-2-p2-4", kr.getMatch(1).getID());
+		assertEquals("doc-number", "match-doc-3-p2-5", kr.getMatch(2).getID());
 	};
 
 	@Test
@@ -360,10 +360,10 @@
 		
 		KorapResult kr = ki.search(sq.toQuery(), (short) 10);			
 
-		assertEquals("totalResults", 3, kr.totalResults());
-		assertEquals("doc-number", "match-doc-0-p3-6", kr.match(0).getID());
-		assertEquals("doc-number", "match-doc-1-p1-3", kr.match(1).getID());
-		assertEquals("doc-number", "match-doc-3-p3-6", kr.match(2).getID());
+		assertEquals("totalResults", kr.getTotalResults(), 3);
+		assertEquals("doc-number", "match-doc-0-p3-6", kr.getMatch(0).getID());
+		assertEquals("doc-number", "match-doc-1-p1-3", kr.getMatch(1).getID());
+		assertEquals("doc-number", "match-doc-3-p3-6", kr.getMatch(2).getID());
 	};
 
 	@Test
@@ -381,14 +381,10 @@
 		
 		KorapResult kr = ki.search(sq, (short) 10);
 		
-		assertEquals(0, kr.match(0).getStartPos());
-		assertEquals(2, kr.match(0).getEndPos());
-		assertEquals(3, kr.match(1).getStartPos());
-		assertEquals(5, kr.match(1).getEndPos());
-		
-//		for (KorapMatch m : kr.getMatches()){
-//			System.out.println(m.getStartPos() +" "+ m.getEndPos());
-//		}
+		assertEquals(0, kr.getMatch(0).getStartPos());
+		assertEquals(2, kr.getMatch(0).getEndPos());
+		assertEquals(3, kr.getMatch(1).getStartPos());
+		assertEquals(5, kr.getMatch(1).getEndPos());
 	}
 	
 	
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
index 1062d4a..070665e 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRealIndex.java
@@ -39,7 +39,7 @@
 	ks = new KorapSearch(kq.within(kq.tag("base/s:s"), kq.seq(kq.re("s:.*")).append(kq._(kq.re("s:.*")))).toQuery());
 	ks.setTimeOut(10000);
 	kr = ks.run(ki);
-	System.err.println(kr.toJSON());
+	System.err.println(kr.toJsonString());
 	assertEquals(8, kr.getTotalResults());
     };
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
index 1c23494..04c7913 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRegexWildcardIndex.java
@@ -57,27 +57,27 @@
 	ks.context.right.setToken(true).setLength(1);
 
 	KorapResult kr = ki.search(ks);
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:baum.*").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:.....?garten").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:ha.s").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... franz [hans] haus ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... hans [haus] efeu ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:.*ff.*").toQuery()));
-	assertEquals(3, kr.getTotalResults());
+	assertEquals((long) 3, kr.getTotalResults());
 	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
 	assertEquals("... efeu [effe]", kr.getMatch(2).getSnippetBrackets());
@@ -114,30 +114,30 @@
 	ks.context.right.setToken(true).setLength(1);
 
 	KorapResult kr = ki.search(ks);
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("affe [afffe] baum ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").wc("s:baum.*").toQuery()));
-	assertEquals(0, kr.getTotalResults());
+	assertEquals((long) 0, kr.getTotalResults());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").wc("s:baum*").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... afffe [baum] baumgarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").wc("s:*garten").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... baum [baumgarten] steingarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... baumgarten [steingarten] franz ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").wc("s:ha?s").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... franz [hans] haus ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... hans [haus] efeu ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").wc("s:?ff?").toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("[affe] afffe ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... efeu [effe]", kr.getMatch(1).getSnippetBrackets());
     };
@@ -173,35 +173,35 @@
 	ks.context.right.setToken(true).setLength(1);
 
 	KorapResult kr = ki.search(ks);
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:Af.*e").toQuery()));
-	assertEquals(1, kr.getTotalResults());
+	assertEquals((long) 1, kr.getTotalResults());
 	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:baum.*", true).toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... aFfFE [Baum] Baumgarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:.*garten", true).toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... Baumgarten [SteinGarten] franZ ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:.*garten", false).toQuery()));
-	assertEquals(1, kr.getTotalResults());
+	assertEquals((long) 1, kr.getTotalResults());
 	assertEquals("... Baum [Baumgarten] SteinGarten ...", kr.getMatch(0).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:ha.s", true).toQuery()));
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 	assertEquals("... franZ [HaNs] Haus ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("... HaNs [Haus] Efeu ...", kr.getMatch(1).getSnippetBrackets());
 
 	kr = ki.search(ks.setQuery(new KorapQuery("base").re("s:.*f*e", true).toQuery()));
-	assertEquals(3, kr.getTotalResults());
+	assertEquals((long) 3, kr.getTotalResults());
 	assertEquals("[AfFe] aFfFE ...", kr.getMatch(0).getSnippetBrackets());
 	assertEquals("AfFe [aFfFE] Baum ...", kr.getMatch(1).getSnippetBrackets());
 	assertEquals("... Efeu [effe]", kr.getMatch(2).getSnippetBrackets());
@@ -238,7 +238,7 @@
 	ks.context.right.setToken(true).setLength(1);
 
 	KorapResult kr = ki.search(ks);
-	assertEquals(1, kr.getTotalResults());
+	assertEquals((long) 1, kr.getTotalResults());
 	assertEquals("[affe afffe] baum ...", kr.getMatch(0).getSnippetBrackets());
     };
 
@@ -279,7 +279,7 @@
 	ks.context.right.setToken(true).setLength(1);
 
 	KorapResult kr = ki.search(ks);
-	assertEquals(1, kr.getTotalResults());
+	assertEquals((long) 1, kr.getTotalResults());
 	assertEquals("[affe afffe] baum ...", kr.getMatch(0).getSnippetBrackets());
     };
 };
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
index c44ffee..7c5d021 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRelationIndex.java
@@ -187,7 +187,7 @@
 				new SpanTermQuery(new Term("base",">:xip/syntax-dep_rel")),true);
 		kr = ki.search(sq,(short) 10);
 		
-		assertEquals(7, kr.getTotalResults());
+		assertEquals((long) 7, kr.getTotalResults());
 		// token to token
 		assertEquals(0,kr.getMatch(0).getLocalDocID());
 		assertEquals(0,kr.getMatch(0).getStartPos());
@@ -226,7 +226,7 @@
 				new SpanTermQuery(new Term("base","<:xip/syntax-dep_rel")),true);
 		kr = ki.search(sq,(short) 10);
 		
-		assertEquals(7, kr.getTotalResults());
+		assertEquals((long) 7, kr.getTotalResults());
 		// token to token
 		assertEquals(0,kr.getMatch(0).getLocalDocID());
 		assertEquals(1,kr.getMatch(0).getStartPos());
@@ -261,7 +261,7 @@
 				new SpanTermQuery(new Term("base",">:child-of")),true);
 		kr = ki.search(srq,(short) 20);
 		
-		assertEquals(13, kr.getTotalResults());
+		assertEquals((long) 13, kr.getTotalResults());
 		
 		// child-of with attr func=sbj
 		SpanWithAttributeQuery wq = 
@@ -273,7 +273,7 @@
 		);
 		
 		kr = ki.search(wq,(short) 10);		
-		assertEquals(1, kr.getTotalResults());
+		assertEquals((long) 1, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos()); // token
 		assertEquals(1,kr.getMatch(0).getEndPos());
 		
@@ -286,7 +286,7 @@
 				true
 		);
 		kr = ki.search(wq,(short) 20);
-		assertEquals(12, kr.getTotalResults());
+		assertEquals((long) 12, kr.getTotalResults());
 		
 		/*for (KorapMatch km : kr.getMatches()){		
 			System.out.println(km.getStartPos() +","+km.getEndPos()
@@ -304,7 +304,7 @@
 		
 		kr = ki.search(wq,(short) 10);
 		
-		assertEquals(1, kr.getTotalResults());
+		assertEquals((long) 1, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos()); // element
 		assertEquals(4,kr.getMatch(0).getEndPos());
 			
@@ -313,7 +313,7 @@
 				new SpanTermQuery(new Term("base","<:dep")),true);
 		kr = ki.search(srq,(short) 10);
 		
-		assertEquals(6, kr.getTotalResults());
+		assertEquals((long) 6, kr.getTotalResults());
 		
 		// target of a dependency relation, which is also a head
 		wq = new SpanWithAttributeQuery(srq, 
@@ -325,7 +325,7 @@
 		
 		kr = ki.search(wq,(short) 20);
 		
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 		assertEquals(3,kr.getMatch(0).getStartPos());
 		assertEquals(4,kr.getMatch(0).getEndPos());
 		assertEquals(6,kr.getMatch(1).getStartPos());
@@ -354,7 +354,7 @@
 				
 		kr = ki.search(rv,(short) 10);
 		
-		assertEquals(7, kr.getTotalResults());
+		assertEquals((long) 7, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(1,kr.getMatch(0).getEndPos());
 		assertEquals(2,kr.getMatch(1).getStartPos());
@@ -375,7 +375,7 @@
 		SpanSegmentQuery rv2 = new SpanSegmentQuery(rv, new SpanTermQuery(new Term("base","pos:ART")));		
 		kr = ki.search(rv2,(short) 10);
 				
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos());
 		assertEquals(3,kr.getMatch(0).getEndPos());
 		assertEquals(5,kr.getMatch(1).getStartPos());
@@ -393,7 +393,7 @@
 				+km.getSnippetBrackets()
 					);
 		}	*/
-		assertEquals(2, kr.getTotalResults());
+		assertEquals((long) 2, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos());
 		assertEquals(4,kr.getMatch(0).getEndPos());
 		assertEquals(5,kr.getMatch(1).getStartPos());
@@ -425,7 +425,7 @@
 				+km.getSnippetBrackets());
 			}*/
 		
-		assertEquals(7, kr.getTotalResults());
+		assertEquals((long) 7, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(1,kr.getMatch(0).getEndPos());
 		assertEquals(2,kr.getMatch(1).getStartPos());
@@ -465,7 +465,7 @@
 			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
 				+km.getSnippetBrackets());
 			}*/
-		assertEquals(4, kr.getTotalResults());
+		assertEquals((long) 4, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(7,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
@@ -497,7 +497,7 @@
 			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
 				+km.getSnippetBrackets());
 			}*/
-		assertEquals(4, kr.getTotalResults());
+		assertEquals((long) 4, kr.getTotalResults());
 		assertEquals(0,kr.getMatch(0).getStartPos());
 		assertEquals(7,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
@@ -521,7 +521,7 @@
 		System.out.println(km.getStartPos() +","+km.getEndPos()+" "
 			+km.getSnippetBrackets());
 		}*/		
-		assertEquals(8, kr.getTotalResults());
+		assertEquals((long) 8, kr.getTotalResults());
 	}
 	
 	/** Relations whose source/target do not embed 
@@ -542,7 +542,7 @@
 				new SpanTermWithIdQuery(new Term("base","pos:NN"), true), 
 				true, false, true);
 		kr = ki.search(rv,(short) 10);
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
@@ -558,7 +558,7 @@
 				new SpanTermWithIdQuery(new Term("base","pos:NN"),true), 
 				true, false, true);
 		kr = ki.search(rv,(short) 10);
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos());
 		assertEquals(3,kr.getMatch(0).getEndPos());
 		assertEquals(4,kr.getMatch(1).getStartPos());
@@ -577,7 +577,7 @@
 				false, true, true);
 		kr = ki.search(rv,(short) 10);
 			
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(2,kr.getMatch(0).getStartPos());
 		assertEquals(3,kr.getMatch(0).getEndPos());
 		assertEquals(4,kr.getMatch(1).getStartPos());
@@ -599,7 +599,7 @@
 				+km.getSnippetBrackets());
 			}*/
 		
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
@@ -623,7 +623,7 @@
 				6, true, false, true); 
 				
 		kr = ki.search(rv,(short) 10);
-		assertEquals(7, kr.getTotalResults());
+		assertEquals((long) 7, kr.getTotalResults());
 		
 		rv =new SpanRelationPartQuery(
 				new SpanRelationQuery(
@@ -639,7 +639,7 @@
 				);
 		}*/
 		
-		assertEquals(3, kr.getTotalResults());
+		assertEquals((long) 3, kr.getTotalResults());
 		assertEquals(1,kr.getMatch(0).getStartPos());
 		assertEquals(2,kr.getMatch(0).getEndPos());
 		assertEquals(1,kr.getMatch(1).getStartPos());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
index b404373..052dd0d 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestRepetitionIndex.java
@@ -95,7 +95,7 @@
         sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,2, true);
         kr = ki.search(sq, (short) 10);
         // 0-1, 2-3, 2-4, 3-4, 5-6
-        assertEquals(5,kr.getTotalResults());        
+        assertEquals((long) 5,kr.getTotalResults());        
         
         // ec{1,2}
         sq = new SpanNextQuery(
@@ -105,12 +105,12 @@
         
         kr = ki.search(sq, (short) 10);
         // 1-3, 1-4, 4-6
-        assertEquals(3,kr.getTotalResults());   
+        assertEquals((long) 3, kr.getTotalResults());   
         
         // ec{1,2}d
         sq2 = new SpanNextQuery(sq, new SpanTermQuery(new Term("base", "s:d")));        
         kr = ki.search(sq2, (short) 10);        
-        assertEquals(2,kr.getTotalResults());
+        assertEquals((long) 2,kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
         assertEquals(4, kr.getMatch(1).startPos);
@@ -120,7 +120,7 @@
         ki.addDoc(createFieldDoc1());
         ki.commit();
         kr = ki.search(sq2, (short) 10);
-        assertEquals(5,kr.getTotalResults());
+        assertEquals((long) 5, kr.getTotalResults());
 	}
 	
 	/** Skip to */
@@ -138,7 +138,7 @@
         sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),2,2, true);
         kr = ki.search(sq, (short) 10);
         // doc1 2-4, 3-5, 4-6
-        assertEquals(6,kr.getTotalResults());
+        assertEquals((long)6,kr.getTotalResults());
         
         // ec{2,2}
         kr = ki.search(sq, (short) 10); 
@@ -148,7 +148,7 @@
     		);
         
         kr = ki.search(sq, (short) 10); 
-        assertEquals(2,kr.getTotalResults());
+        assertEquals((long)2,kr.getTotalResults());
         assertEquals(3,kr.getMatch(1).getLocalDocID());        
        
 	}
@@ -170,7 +170,7 @@
 				)
     		);        
         kr = ki.search(sq, (short) 10); 
-        assertEquals(3,kr.getTotalResults());
+        assertEquals((long)3,kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(3, kr.getMatch(0).endPos);
         assertEquals(4, kr.getMatch(1).startPos);
@@ -191,12 +191,12 @@
         sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),1,3, true);
         kr = ki.search(sq, (short) 10);
         // 2-3, 2-4, 2-5, 3-4, 3-5, 3-6, 4-5, 4-6, 5-6, 7-8  
-        assertEquals(10,kr.getTotalResults());
+        assertEquals((long)10,kr.getTotalResults());
         
         sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("base","s:c")),2,3, true);
         kr = ki.search(sq, (short) 10);
         // 2-4, 2-5, 3-5, 3-6, 4-6 
-        assertEquals(5,kr.getTotalResults());
+        assertEquals((long)5,kr.getTotalResults());
         
 //        System.out.print(kr.getTotalResults()+"\n");
 //		for (int i=0; i< kr.getTotalResults(); i++){
@@ -222,7 +222,7 @@
         sq2 = new SpanNextQuery(sq1,sq0);        
         kr = ki.search(sq2, (short) 10);
         
-        assertEquals(2,kr.getTotalResults());
+        assertEquals((long)2,kr.getTotalResults());
         assertEquals(73, kr.getMatch(0).getStartPos());
         assertEquals(77, kr.getMatch(0).getEndPos());
         assertEquals(74, kr.getMatch(1).getStartPos());
@@ -237,7 +237,7 @@
         		sq2);
         kr = ki.search(sq2, (short) 10);
         
-        assertEquals(1,kr.getTotalResults());
+        assertEquals((long)1,kr.getTotalResults());
         assertEquals(73, kr.getMatch(0).getStartPos());
         assertEquals(77, kr.getMatch(0).getEndPos());
         /*
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
index adc550b..e05d730 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSegmentIndex.java
@@ -43,7 +43,6 @@
 	/** Multiple matches in one document. */
 	@Test
 	public void testCase1() throws IOException {
-//		log.trace("Testcase1");
 		sq = new SpanSegmentQuery(
 				new SpanTermQuery(new Term("base","s:b")),
 				new SpanTermQuery(new Term("base","s:c"))
@@ -52,11 +51,11 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();
 		
-		assertEquals("totalResults", 3, kr.totalResults());
-		assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-		assertEquals("EndPos (0)", 2, kr.match(0).endPos);
-		assertEquals("StartPos (1)", 4, kr.match(1).startPos);
-		assertEquals("EndPos (1)", 5, kr.match(1).endPos);		
+		assertEquals("totalResults", kr.getTotalResults(), 3);
+		assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+		assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);
+		assertEquals("StartPos (1)", 4, kr.getMatch(1).startPos);
+		assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);		
 	}
 	
 	/** Matches in multiple documents.
@@ -73,15 +72,15 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();
 				
-		assertEquals("totalResults", 3, kr.totalResults());
+		assertEquals("totalResults", kr.getTotalResults(), 3);
 		// Match #0
-		assertEquals("doc-number", 1, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 1, kr.match(0).startPos);
-		assertEquals("EndPos", 2, kr.match(0).endPos);
+		assertEquals("doc-number", 1, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 1, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 2, kr.getMatch(0).endPos);
 		// Match #2
-		assertEquals("doc-number", 2, kr.match(2).getLocalDocID());
-		assertEquals("StartPos", 2, kr.match(2).startPos);
-		assertEquals("EndPos", 3, kr.match(2).endPos);		
+		assertEquals("doc-number", 2, kr.getMatch(2).getLocalDocID());
+		assertEquals("StartPos", 2, kr.getMatch(2).startPos);
+		assertEquals("EndPos", 3, kr.getMatch(2).endPos);		
 	}
 	
 	
@@ -97,10 +96,10 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();
 		
-		assertEquals("totalResults", 1, kr.totalResults());
-		assertEquals("doc-number", 2, kr.match(0).getLocalDocID());
-		assertEquals("StartPos (0)", 1, kr.match(0).startPos);
-		assertEquals("EndPos (0)", 2, kr.match(0).endPos);		
+		assertEquals("totalResults", kr.getTotalResults(), 1);
+		assertEquals("doc-number", 2, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos (0)", 1, kr.getMatch(0).startPos);
+		assertEquals("EndPos (0)", 2, kr.getMatch(0).endPos);		
 	}
 	
 	/** Matching a SpanElementQuery and a SpanNextQuery 
@@ -128,15 +127,15 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();
 		
-		assertEquals("totalResults", 2, kr.totalResults());
+		assertEquals("totalResults", kr.getTotalResults(), 2);
 		// Match #0
-		assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 3, kr.match(0).startPos);
-		assertEquals("EndPos", 5, kr.match(0).endPos);
+		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 3, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 5, kr.getMatch(0).endPos);
 		// Match #1
-		assertEquals("doc-number", 0, kr.match(1).getLocalDocID());
-		assertEquals("StartPos", 1, kr.match(1).startPos);
-		assertEquals("EndPos", 3, kr.match(1).endPos);				
+		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+		assertEquals("StartPos", 1, kr.getMatch(1).startPos);
+		assertEquals("EndPos", 3, kr.getMatch(1).endPos);				
 	}
 	
 	/** Matching SpanElementQueries */
@@ -151,11 +150,11 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();			
 		
-		assertEquals("totalResults", 1, kr.totalResults());
+		assertEquals("totalResults", kr.getTotalResults(), 1);
 		// Match #0
-		assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-		assertEquals("StartPos", 3, kr.match(0).startPos);
-		assertEquals("EndPos", 5, kr.match(0).endPos);				
+		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos", 3, kr.getMatch(0).startPos);
+		assertEquals("EndPos", 5, kr.getMatch(0).endPos);				
 	}
 		
 	/** Skip to SegmentSpan */
@@ -174,15 +173,15 @@
 		kr = ki.search(sq, (short) 10);
 		ki.close();
 		
-		assertEquals("totalResults", 2, kr.totalResults());				
+		assertEquals("totalResults", kr.getTotalResults(), 2);				
 		// Match #0
-		assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-		assertEquals("StartPos (0)", 4, kr.match(0).startPos);
-		assertEquals("EndPos (0)", 6, kr.match(0).endPos);
+		assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+		assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
+		assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
 		// Match #1 in the other atomic index
-		assertEquals("doc-number", 0, kr.match(1).getLocalDocID());
-		assertEquals("StartPos (0)", 0, kr.match(1).startPos);
-		assertEquals("EndPos (0)", 2, kr.match(1).endPos);
+		assertEquals("doc-number", 0, kr.getMatch(1).getLocalDocID());
+		assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
+		assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
 	}
 
     
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
index 7a3851b..d9a23f3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSegmentNegationIndex.java
@@ -43,16 +43,16 @@
 
 	kr = ki.search(sqw.toQuery(), (short) 10);
 		
-	assertEquals("totalResults", 2, kr.totalResults());				
+	assertEquals("totalResults", kr.getTotalResults(), 2);				
 	// Match #0
-	assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-	assertEquals("StartPos (0)", 4, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 6, kr.match(0).endPos);
+	assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+	assertEquals("StartPos (0)", 4, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 6, kr.getMatch(0).endPos);
 
 	// Match #1 in the other atomic index
-	assertEquals("doc-number", 3, kr.match(1).getLocalDocID());
-	assertEquals("StartPos (0)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (0)", 2, kr.match(1).endPos);
+	assertEquals("doc-number", 3, kr.getMatch(1).getLocalDocID());
+	assertEquals("StartPos (0)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (0)", 2, kr.getMatch(1).endPos);
 		
 	ssqw = new SpanSegmentQueryWrapper("base","s:b");
 	ssqw.without("s:c");
@@ -60,21 +60,21 @@
 
 	kr = ki.search(sqw.toQuery(), (short) 10);
 
-	assertEquals("doc-number", 0, kr.match(0).getLocalDocID());
-	assertEquals("StartPos (0)", 2, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
+	assertEquals("doc-number", 0, kr.getMatch(0).getLocalDocID());
+	assertEquals("StartPos (0)", 2, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
 
-	assertEquals("doc-number", 1, kr.match(1).getLocalDocID());
-	assertEquals("StartPos (1)", 1, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 3, kr.match(1).endPos);
+	assertEquals("doc-number", 1, kr.getMatch(1).getLocalDocID());
+	assertEquals("StartPos (1)", 1, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 3, kr.getMatch(1).endPos);
 
-	assertEquals("doc-number", 1, kr.match(2).getLocalDocID());
-	assertEquals("StartPos (2)", 2, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 4, kr.match(2).endPos);
+	assertEquals("doc-number", 1, kr.getMatch(2).getLocalDocID());
+	assertEquals("StartPos (2)", 2, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 4, kr.getMatch(2).endPos);
 
-	assertEquals("doc-number", 2, kr.match(3).getLocalDocID());
-	assertEquals("StartPos (3)", 1, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 3, kr.match(3).endPos);
+	assertEquals("doc-number", 2, kr.getMatch(3).getLocalDocID());
+	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 3, kr.getMatch(3).endPos);
     }
     
     private FieldDocument createFieldDoc0(){
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
index 0a90445..7339f90 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSpanExpansionIndex.java
@@ -210,7 +210,7 @@
 		SpanExpansionQuery seq = new SpanExpansionQuery(stq,2,2, -1, true);		
 		kr = ki.search(seq, (short) 10);
 		
-		assertEquals(4,kr.getTotalResults());
+		assertEquals((long) 4,kr.getTotalResults());
 		assertEquals(0, kr.getMatch(0).getStartPos());
         assertEquals(2, kr.getMatch(0).getEndPos());
         
@@ -218,7 +218,7 @@
         seq = new SpanExpansionQuery(stq,3,3,0, true);		
 		kr = ki.search(seq, (short) 10);
         		
-		assertEquals(4,kr.getTotalResults());
+		assertEquals((long) 4,kr.getTotalResults());
 		assertEquals(7, kr.getMatch(2).getStartPos());
         assertEquals(11, kr.getMatch(2).getEndPos());
         assertEquals(8, kr.getMatch(3).getStartPos());
@@ -273,7 +273,7 @@
 		
 		String jsonPath = getClass().getResource("/queries/poly3.json").getFile();
 		String jsonQuery = readFile(jsonPath);
-		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON(
+		SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJson(
 				jsonQuery
 		);
 		
@@ -315,7 +315,7 @@
 		SpanRepetitionQuery rep = new SpanRepetitionQuery(seq, 2, 2, true);
 		
 		kr = ki.search(rep, (short) 20);
-		assertEquals(3,kr.getTotalResults());
+		assertEquals((long) 3,kr.getTotalResults());
 		
 		/*for (KorapMatch km : kr.getMatches()){
 			System.out.println(km.getStartPos() +","+km.getEndPos()+" "
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
index 9a50dce..ba9b14f 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestSubSpanIndex.java
@@ -37,7 +37,7 @@
 		SpanSubspanQuery ssq = new SpanSubspanQuery(sdq, 0, 2, true);		
 		kr = ki.search(ssq, (short) 10);
 		
-		assertEquals(8,kr.getTotalResults());
+		assertEquals((long) 8,kr.getTotalResults());
 		assertEquals(35, kr.getMatch(0).getStartPos());
         assertEquals(37, kr.getMatch(0).getEndPos());
         assertEquals(179, kr.getMatch(1).getStartPos());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
index 079a91f..a26d1b3 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedDistanceIndex.java
@@ -112,7 +112,7 @@
 	    SpanQuery sq = createQuery("s:c","s:d",0,3,false);                
 	    kr = ki.search(sq, (short) 10);
 	    	    
-	    assertEquals(5, kr.totalResults());	    
+	    assertEquals(kr.getTotalResults(), 5);	    
 	}
 	
 	/** Multiple documents 
@@ -132,7 +132,7 @@
 	    SpanQuery sq = createQuery("s:c","s:d",1,2,false);                
 	    kr = ki.search(sq, (short) 10);
 	    	    
-	    assertEquals(6, kr.totalResults());	    
+	    assertEquals(kr.getTotalResults(), 6);	    
 	}
 	
 	/** Multiple documents 
@@ -151,13 +151,13 @@
 	    SpanQuery sq = createQuery("s:e","s:f",1,2,false);                
 	    kr = ki.search(sq, (short) 10);
 	    	    
-	    assertEquals(3, kr.totalResults());
-	    assertEquals(0, kr.match(0).getLocalDocID());
-	    assertEquals(7, kr.match(0).getStartPos());
-	    assertEquals(9, kr.match(0).getEndPos());
-	    assertEquals(2, kr.match(1).getLocalDocID());
-	    assertEquals(0, kr.match(1).getStartPos());
-	    assertEquals(3, kr.match(1).getEndPos());
+	    assertEquals(kr.getTotalResults(), 3);
+	    assertEquals(0, kr.getMatch(0).getLocalDocID());
+	    assertEquals(7, kr.getMatch(0).getStartPos());
+	    assertEquals(9, kr.getMatch(0).getEndPos());
+	    assertEquals(2, kr.getMatch(1).getLocalDocID());
+	    assertEquals(0, kr.getMatch(1).getStartPos());
+	    assertEquals(3, kr.getMatch(1).getEndPos());
 	}
 	
 	/** Skip to */
@@ -176,7 +176,7 @@
 		);
 	    
 	    kr = ki.search(sq, (short) 10);
-	    assertEquals(2, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 2);
 	    assertEquals(2,kr.getMatch(0).getLocalDocID());
 	    assertEquals(2,kr.getMatch(0).getStartPos());
 	    assertEquals(6,kr.getMatch(0).getEndPos());
@@ -196,7 +196,7 @@
 	    SpanQuery sq = createElementQuery("x","y",0,0,false);                
 	    kr = ki.search(sq, (short) 10);
     	
-	    assertEquals(4, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 4);
 	    assertEquals(2, kr.getMatch(0).startPos);
 	    assertEquals(7, kr.getMatch(0).endPos);
 	    assertEquals(3, kr.getMatch(1).startPos);
@@ -209,7 +209,7 @@
 	    sq = createElementQuery("x","y",1,1,false);                
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(1, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 1);
 	    assertEquals(5, kr.getMatch(0).startPos);
 	    assertEquals(10, kr.getMatch(0).endPos);
 	    
@@ -218,7 +218,7 @@
 	    sq = createElementQuery("x","y",1,2,false);                
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(2, kr.totalResults());	    
+	    assertEquals(kr.getTotalResults(), 2);	    
 	    assertEquals(4, kr.getMatch(0).startPos);
 	    assertEquals(9, kr.getMatch(0).endPos);
 	    assertEquals(5, kr.getMatch(1).startPos);
@@ -244,7 +244,7 @@
 	    SpanQuery sq = createElementQuery("x","x",1,2,false);
 	    kr = ki.search(sq, (short) 10);
 	    
-	    assertEquals(4, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 4);
     }
 
     /** Nested distance queries
@@ -264,7 +264,7 @@
         		new DistanceConstraint(1, 2, true, false),        		
         		true);
 	    kr = ki.search(sq2, (short) 10);	    
-	    assertEquals(3, kr.totalResults());	
+	    assertEquals(kr.getTotalResults(), 3);	
 	    assertEquals(5, kr.getMatch(0).getStartPos());
 	    assertEquals(9, kr.getMatch(0).getEndPos());
 	    assertEquals(1, kr.getMatch(1).getLocalDocID());
@@ -287,7 +287,7 @@
 		);
 	    kr = ki.search(sq, (short) 10);
     
-	    assertEquals(3, kr.totalResults());
+	    assertEquals(kr.getTotalResults(), 3);
 	    assertEquals(0,kr.getMatch(1).getStartPos());
 	    assertEquals(4,kr.getMatch(1).getEndPos());
 	    
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
index 952c325..1f4e094 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestUnorderedElementDistanceIndex.java
@@ -116,7 +116,7 @@
         sq = createQuery("s", "s:b", "s:c", 0, 1,false);        
         kr = ki.search(sq, (short) 10);
 		
-        assertEquals(5,kr.getTotalResults());
+        assertEquals((long) 5,kr.getTotalResults());
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(1, kr.getMatch(0).endPos);
         assertEquals(0, kr.getMatch(1).startPos);
@@ -147,7 +147,7 @@
         sq = createQuery("p", "s:b", "s:e", 0, 2,false);        
         kr = ki.search(sq, (short) 10);
 
-        assertEquals(3,kr.getTotalResults());
+        assertEquals((long) 3,kr.getTotalResults());
         assertEquals(2,kr.getMatch(0).getLocalDocID());
         assertEquals(3, kr.getMatch(0).startPos);
         assertEquals(5, kr.getMatch(0).endPos);
@@ -170,7 +170,7 @@
         sq = createQuery("s", "s:c", "s:e", 1, 2,false);        
         kr = ki.search(sq, (short) 10);
 	
-        assertEquals(4,kr.getTotalResults());
+        assertEquals((long) 4,kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).startPos);
         assertEquals(6, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
@@ -201,7 +201,7 @@
         
         kr = ki.search(sq, (short) 10);
         
-        assertEquals(4,kr.getTotalResults());
+        assertEquals((long) 4,kr.getTotalResults());
         assertEquals(0, kr.getMatch(0).startPos);
         assertEquals(3, kr.getMatch(0).endPos);
         assertEquals(1, kr.getMatch(1).startPos);
@@ -224,13 +224,13 @@
         SpanQuery sq, edq;
         edq = createQuery("s", "s:b", "s:c", 0, 2,false);
         kr = ki.search(edq, (short) 10);
-        assertEquals(6, kr.getTotalResults());
+        assertEquals((long) 6, kr.getTotalResults());
 
         sq = new SpanNextQuery( 
         		new SpanTermQuery(new Term("base", "s:b"))
         		,edq);
         kr = ki.search(sq, (short) 10);
-        assertEquals(2, kr.getTotalResults());
+        assertEquals((long) 2, kr.getTotalResults());
         assertEquals(1, kr.getMatch(0).getStartPos());
         assertEquals(4, kr.getMatch(0).getEndPos());
         assertEquals(2, kr.getMatch(1).getStartPos());
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
index 4f6226d..9bf4952 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWPDIndex.java
@@ -72,18 +72,18 @@
 		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true,false);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(8, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 8);
 
 		// unordered
 		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false,false);				
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(11, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 11);
 		
 		sq = createDistanceQuery("s:kommen", "s:Wir", 1, 1, false,false);				
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(11, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 11);
 		//System.out.println(kr.getTotalResults());
 		//for (KorapMatch km : kr.getMatches()){
 			//System.out.println(km.getDocID() +" "+km.getStartPos() +" "+ km.getEndPos());
@@ -99,20 +99,20 @@
 		SpanQuery q = new SpanTermQuery(new Term("tokens","s:Wir"));
 		ks = new KorapSearch(q);
 		kr = ks.run(ki);
-		assertEquals(1907, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1907);
 		
 		SpanDistanceQuery sq;
 		// ordered
 		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, true, true);				
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(1899, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1899);
 		
 		// unordered
 		sq = createDistanceQuery("s:Wir", "s:kommen", 1, 1, false, true);				
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(1896, kr.getTotalResults());	
+		assertEquals(kr.getTotalResults(), 1896);	
 	}
 	
 	/** Element distance spans */
@@ -123,22 +123,22 @@
 				0, 1, true, false);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);		
-		assertEquals(3,kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 3);
 		
 		// unordered
 		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 0, 1, false,false);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(5,kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 5);
 		
 		// only 0
 		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 0, 0, false,false);
 		kr = ki.search(sq, (short) 100);
-		assertEquals(2,kr.getTotalResults());
-		assertEquals("WPD_BBB.04463", kr.match(0).getDocID());
+		assertEquals(kr.getTotalResults(), 2);
+		assertEquals("WPD_BBB.04463", kr.getMatch(0).getDocID());
 		assertEquals(1094,kr.getMatch(0).getStartPos());
 		assertEquals(1115,kr.getMatch(0).getEndPos());
-		assertEquals("WPD_III.00758", kr.match(1).getDocID());
+		assertEquals("WPD_III.00758", kr.getMatch(1).getDocID());
 		assertEquals(444,kr.getMatch(1).getStartPos());
 		assertEquals(451,kr.getMatch(1).getEndPos());
 		
@@ -146,7 +146,7 @@
 		sq = createElementDistanceQuery("s","s:weg", "s:fahren", 1, 1, false,false);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(3,kr.getTotalResults());		
+		assertEquals(kr.getTotalResults(), 3);		
 	}
 	
 	/** Element distance exclusion */
@@ -155,7 +155,7 @@
 		SpanDistanceQuery sq = createElementDistanceQuery("s","s:weg", "s:fahren", 1, 1, false, true);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(979,kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 979);
 		//0.8s
 		
 		// Check if it includes some results
@@ -176,18 +176,18 @@
 		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),1,2, true);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(4116416, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 4116416);
 		//0.9s
 		
 		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),1,1, true);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(3879671, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 3879671);
 		
 		sq = new SpanRepetitionQuery(new SpanTermQuery(new Term("tokens","mate/p:ADJA")),2,2, true);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(236745, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 236745);
 		//0.65s
 	}
 	
@@ -200,14 +200,14 @@
     		);
 		ks = new KorapSearch(sq);
 		kr = ks.run(ki);
-		assertEquals(30223, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 30223);
 		// 1.1s
 		
 		SpanQuery sq2 = new SpanNextQuery(sq,
 				new SpanTermQuery(new Term("tokens", "tt/p:NN")));
 		ks = new KorapSearch(sq2);
 		kr = ks.run(ki);
-		assertEquals(26607, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 26607);
 		// 1.1s
 	}
 }
diff --git a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
index 75ff3c9..618fad1 100644
--- a/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
+++ b/src/test/java/de/ids_mannheim/korap/index/TestWithinIndex.java
@@ -73,22 +73,20 @@
 
 	kr = ki.search(sq, (short) 10);
 	
-	// System.err.println(kr.toJSON());
+	assertEquals("totalResults", kr.getTotalResults(), 6);
 
-	assertEquals("totalResults", 6, kr.totalResults());
-
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 12, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 12, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 1, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 9, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
 
 	assertEquals(1, ki.numberOf("documents"));
     };
@@ -148,51 +146,45 @@
 
 	kr = ki.search(sq, (short) 15);
 	
-	assertEquals("totalResults", 12, kr.totalResults());
-
-
-
-
-	//	System.err.println(kr.toJSON());
-
+	assertEquals("totalResults", kr.getTotalResults(), 12);
 	
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(0).endPos);
-	assertEquals("Doc (0)", 0, kr.match(0).internalDocID);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 12, kr.match(1).endPos);
-	assertEquals("Doc (1)", 0, kr.match(1).internalDocID);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 12, kr.match(2).endPos);
-	assertEquals("Doc (2)", 0, kr.match(2).internalDocID);
-	assertEquals("StartPos (3)", 1, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 9, kr.match(3).endPos);
-	assertEquals("Doc (3)", 0, kr.match(3).internalDocID);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("Doc (4)", 0, kr.match(4).internalDocID);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
-	assertEquals("Doc (5)", 0, kr.match(5).internalDocID);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+	assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
+	assertEquals("Doc (1)", 0, kr.getMatch(1).internalDocID);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
+	assertEquals("Doc (2)", 0, kr.getMatch(2).internalDocID);
+	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
+	assertEquals("Doc (3)", 0, kr.getMatch(3).internalDocID);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("Doc (4)", 0, kr.getMatch(4).internalDocID);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
+	assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
 
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 12, kr.match(6).endPos);
-	assertEquals("Doc (6)", 1, kr.match(6).internalDocID);
-	assertEquals("StartPos (7)", 0, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 12, kr.match(7).endPos);
-	assertEquals("Doc (7)", 1, kr.match(7).internalDocID);
-	assertEquals("StartPos (8)", 0, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 12, kr.match(8).endPos);
-	assertEquals("Doc (8)", 1, kr.match(8).internalDocID);
-	assertEquals("StartPos (9)", 1, kr.match(9).startPos);
-	assertEquals("EndPos (9)", 9, kr.match(9).endPos);
-	assertEquals("Doc (9)", 1, kr.match(9).internalDocID);
-	assertEquals("StartPos (10)", 1, kr.match(10).startPos);
-	assertEquals("EndPos (10)", 9, kr.match(10).endPos);
-	assertEquals("Doc (10)", 1, kr.match(10).internalDocID);
-	assertEquals("StartPos (11)", 2, kr.match(11).startPos);
-	assertEquals("EndPos (11)", 6, kr.match(11).endPos);
-	assertEquals("Doc (11)", 1, kr.match(11).internalDocID);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 12, kr.getMatch(6).endPos);
+	assertEquals("Doc (6)", 1, kr.getMatch(6).internalDocID);
+	assertEquals("StartPos (7)", 0, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 12, kr.getMatch(7).endPos);
+	assertEquals("Doc (7)", 1, kr.getMatch(7).internalDocID);
+	assertEquals("StartPos (8)", 0, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 12, kr.getMatch(8).endPos);
+	assertEquals("Doc (8)", 1, kr.getMatch(8).internalDocID);
+	assertEquals("StartPos (9)", 1, kr.getMatch(9).startPos);
+	assertEquals("EndPos (9)", 9, kr.getMatch(9).endPos);
+	assertEquals("Doc (9)", 1, kr.getMatch(9).internalDocID);
+	assertEquals("StartPos (10)", 1, kr.getMatch(10).startPos);
+	assertEquals("EndPos (10)", 9, kr.getMatch(10).endPos);
+	assertEquals("Doc (10)", 1, kr.getMatch(10).internalDocID);
+	assertEquals("StartPos (11)", 2, kr.getMatch(11).startPos);
+	assertEquals("EndPos (11)", 6, kr.getMatch(11).endPos);
+	assertEquals("Doc (11)", 1, kr.getMatch(11).internalDocID);
 
 	assertEquals(2, ki.numberOf("documents"));
     };
@@ -253,28 +245,26 @@
 
 	kr = ki.search(sq, (short) 15);
 	
-	// System.err.println(kr.toJSON());
+	assertEquals("totalResults", kr.getTotalResults(), 6);
 
-	assertEquals("totalResults", 6, kr.totalResults());
-
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(0).endPos);
-	assertEquals("Doc (0)", 0, kr.match(0).internalDocID);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 12, kr.match(1).endPos);
-	assertEquals("Doc (1)", 0, kr.match(1).internalDocID);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 12, kr.match(2).endPos);
-	assertEquals("Doc (2)", 0, kr.match(2).internalDocID);
-	assertEquals("StartPos (3)", 1, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 9, kr.match(3).endPos);
-	assertEquals("Doc (3)", 0, kr.match(3).internalDocID);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("Doc (4)", 0, kr.match(4).internalDocID);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
-	assertEquals("Doc (5)", 0, kr.match(5).internalDocID);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+	assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
+	assertEquals("Doc (1)", 0, kr.getMatch(1).internalDocID);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
+	assertEquals("Doc (2)", 0, kr.getMatch(2).internalDocID);
+	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
+	assertEquals("Doc (3)", 0, kr.getMatch(3).internalDocID);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("Doc (4)", 0, kr.getMatch(4).internalDocID);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
+	assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
 
 	assertEquals(2, ki.numberOf("documents"));
     };
@@ -346,28 +336,26 @@
 
 	kr = ki.search(sq, (short) 15);
 	
-	// System.err.println(kr.toJSON());
+	assertEquals("totalResults", kr.getTotalResults(), 6);
 
-	assertEquals("totalResults", 6, kr.totalResults());
-
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 12, kr.match(0).endPos);
-	assertEquals("Doc (0)", 0, kr.match(0).internalDocID);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 12, kr.match(1).endPos);
-	assertEquals("Doc (1)", 0, kr.match(1).internalDocID);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 12, kr.match(2).endPos);
-	assertEquals("Doc (2)", 0, kr.match(2).internalDocID);
-	assertEquals("StartPos (3)", 1, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 9, kr.match(3).endPos);
-	assertEquals("Doc (3)", 0, kr.match(3).internalDocID);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("Doc (4)", 0, kr.match(4).internalDocID);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
-	assertEquals("Doc (5)", 0, kr.match(5).internalDocID);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 12, kr.getMatch(0).endPos);
+	assertEquals("Doc (0)", 0, kr.getMatch(0).internalDocID);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 12, kr.getMatch(1).endPos);
+	assertEquals("Doc (1)", 0, kr.getMatch(1).internalDocID);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 12, kr.getMatch(2).endPos);
+	assertEquals("Doc (2)", 0, kr.getMatch(2).internalDocID);
+	assertEquals("StartPos (3)", 1, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 9, kr.getMatch(3).endPos);
+	assertEquals("Doc (3)", 0, kr.getMatch(3).internalDocID);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("Doc (4)", 0, kr.getMatch(4).internalDocID);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
+	assertEquals("Doc (5)", 0, kr.getMatch(5).internalDocID);
 
 	assertEquals(3, ki.numberOf("documents"));
     };
@@ -407,13 +395,13 @@
 	sq = new SpanElementQuery("base", "a");
 	kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 7, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 10, kr.match(2).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 7, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
 	    
 	sq = new SpanWithinQuery(
 	    new SpanElementQuery("base", "a"),
@@ -421,27 +409,26 @@
         );
 
 	kr = ki.search(sq, (short) 10);
-	//	System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", 9, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 4, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 7, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 7, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 0, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 7, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 0, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 10, kr.match(5).endPos);
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 10, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 0, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 10, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 0, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 10, kr.match(8).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 9);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 7, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 7, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 0, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 7, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 0, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 10, kr.getMatch(5).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 10, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 0, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 10, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 0, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 10, kr.getMatch(8).endPos);
     };
 
     @Test
@@ -475,13 +462,13 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 3, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 7, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 10, kr.match(2).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 3);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 7, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
 
 	sq = new SpanWithinQuery(
 	    new SpanElementQuery("base", "a"),
@@ -489,27 +476,26 @@
         );
 
 	kr = ki.search(sq, (short) 10);
-	//	System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", 9, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 4, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 7, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 7, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 0, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 7, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 0, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 10, kr.match(5).endPos);
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 10, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 0, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 10, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 0, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 10, kr.match(8).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 9);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 7, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 7, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 0, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 7, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 0, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 10, kr.getMatch(5).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 10, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 0, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 10, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 0, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 10, kr.getMatch(8).endPos);
     };
 
 
@@ -545,15 +531,15 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 4, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 7, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 10, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 11, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 12, kr.match(3).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 4);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 7, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 11, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
 
 	sq = new SpanWithinQuery(
 	    new SpanElementQuery("base", "a"),
@@ -561,27 +547,26 @@
         );
 
 	kr = ki.search(sq, (short) 10);
-	//	System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", 9, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 4, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 7, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 7, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 0, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 7, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 0, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 10, kr.match(5).endPos);
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 10, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 0, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 10, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 0, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 10, kr.match(8).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 9);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 7, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 7, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 0, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 7, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 0, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 10, kr.getMatch(5).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 10, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 0, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 10, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 0, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 10, kr.getMatch(8).endPos);
     };
 
 
@@ -617,15 +602,15 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 4, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 7, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 10, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 11, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 12, kr.match(3).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 4);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 7, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 11, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
 
 	sq = new SpanWithinQuery(
 	    new SpanElementQuery("base", "a"),
@@ -633,29 +618,28 @@
         );
 
 	kr = ki.search(sq, (short) 15);
-	//	System.err.println(kr.toJSON());
 
-	assertEquals("totalResults", 10, kr.totalResults());
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 4, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 4, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 7, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 7, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 0, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 7, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 0, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 10, kr.match(5).endPos);
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 10, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 0, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 10, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 0, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 10, kr.match(8).endPos);
-	assertEquals("StartPos (9)", 11, kr.match(9).startPos);
-	assertEquals("EndPos (9)", 12, kr.match(9).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 10);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 4, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 4, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 7, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 7, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 0, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 7, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 0, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 10, kr.getMatch(5).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 10, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 0, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 10, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 0, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 10, kr.getMatch(8).endPos);
+	assertEquals("StartPos (9)", 11, kr.getMatch(9).startPos);
+	assertEquals("EndPos (9)", 12, kr.getMatch(9).endPos);
     };
 
 
@@ -750,36 +734,35 @@
 
 	KorapResult kr = ki.search(sq, (short) 15);
 
-	//	System.err.println(ki.search(sq, (short) 10).toJSON());
-	assertEquals("totalResults", 12, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 12);
 
-	assertEquals("StartPos (0)", 0, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 0, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 0, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 0, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 0, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 0, kr.match(2).endPos);
+	assertEquals("StartPos (0)", 0, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 0, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 0, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 0, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 0, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 0, kr.getMatch(2).endPos);
 
-	assertEquals("StartPos (3)", 0, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 12, kr.match(3).endPos);
-	assertEquals("StartPos (4)", 1, kr.match(4).startPos);
-	assertEquals("EndPos (4)", 9, kr.match(4).endPos);
-	assertEquals("StartPos (5)", 2, kr.match(5).startPos);
-	assertEquals("EndPos (5)", 6, kr.match(5).endPos);
+	assertEquals("StartPos (3)", 0, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 12, kr.getMatch(3).endPos);
+	assertEquals("StartPos (4)", 1, kr.getMatch(4).startPos);
+	assertEquals("EndPos (4)", 9, kr.getMatch(4).endPos);
+	assertEquals("StartPos (5)", 2, kr.getMatch(5).startPos);
+	assertEquals("EndPos (5)", 6, kr.getMatch(5).endPos);
 
-	assertEquals("StartPos (6)", 0, kr.match(6).startPos);
-	assertEquals("EndPos (6)", 12, kr.match(6).endPos);
-	assertEquals("StartPos (7)", 1, kr.match(7).startPos);
-	assertEquals("EndPos (7)", 9, kr.match(7).endPos);
-	assertEquals("StartPos (8)", 2, kr.match(8).startPos);
-	assertEquals("EndPos (8)", 6, kr.match(8).endPos);
+	assertEquals("StartPos (6)", 0, kr.getMatch(6).startPos);
+	assertEquals("EndPos (6)", 12, kr.getMatch(6).endPos);
+	assertEquals("StartPos (7)", 1, kr.getMatch(7).startPos);
+	assertEquals("EndPos (7)", 9, kr.getMatch(7).endPos);
+	assertEquals("StartPos (8)", 2, kr.getMatch(8).startPos);
+	assertEquals("EndPos (8)", 6, kr.getMatch(8).endPos);
 
-	assertEquals("StartPos (9)", 0, kr.match(9).startPos);
-	assertEquals("EndPos (9)", 3, kr.match(9).endPos);
-	assertEquals("StartPos (10)", 0, kr.match(10).startPos);
-	assertEquals("EndPos (10)", 6, kr.match(10).endPos);
-	assertEquals("StartPos (11)", 0, kr.match(11).startPos);
-	assertEquals("EndPos (11)", 9, kr.match(11).endPos);
+	assertEquals("StartPos (9)", 0, kr.getMatch(9).startPos);
+	assertEquals("EndPos (9)", 3, kr.getMatch(9).endPos);
+	assertEquals("StartPos (10)", 0, kr.getMatch(10).startPos);
+	assertEquals("EndPos (10)", 6, kr.getMatch(10).endPos);
+	assertEquals("StartPos (11)", 0, kr.getMatch(11).startPos);
+	assertEquals("EndPos (11)", 9, kr.getMatch(11).endPos);
     };
 
     @Test
@@ -806,24 +789,24 @@
 	SpanQuery sq = new SpanClassQuery(new SpanElementQuery("base", "sentence"), (byte)3);
 	KorapResult kr;
 	kr = ki.search(sq, 0, (short) 15, true, (short) 1, true, (short) 1);
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
-	assertEquals("... schrie: [\"{3:Das war ich}!\"] und ...",kr.match(0).snippetBrackets());
-	assertEquals("<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><span class=\"match\">&quot;<em class=\"class-3 level-0\">Das war ich</em>!&quot;</span><span class=\"context-right\"> und<span class=\"more\"></span></span>",kr.match(0).snippetHTML());
+	assertEquals("... schrie: [\"{3:Das war ich}!\"] und ...",kr.getMatch(0).snippetBrackets());
+	assertEquals("<span class=\"context-left\"><span class=\"more\"></span>schrie: </span><span class=\"match\">&quot;<em class=\"class-3 level-0\">Das war ich</em>!&quot;</span><span class=\"context-right\"> und<span class=\"more\"></span></span>",kr.getMatch(0).snippetHTML());
 
 
 	kr = ki.search(sq, 0, (short) 15, true, (short) 0, true, (short) 0);
-	assertEquals("... [\"{3:Das war ich}!\"] ...",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("... [\"{3:Das war ich}!\"] ...",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 
 	kr = ki.search(sq, 0, (short) 15, true, (short) 6, true, (short) 6);
-	assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging.",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging.",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 	kr = ki.search(sq, 0, (short) 15, true, (short) 2, true, (short) 2);
-	assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging ...",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("Er schrie: [\"{3:Das war ich}!\"] und ging ...",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 
 	sq = new SpanClassQuery(
@@ -835,8 +818,8 @@
         ), (byte) 1);
 
 	kr = ki.search(sq, (short) 15);
-	assertEquals("Er schrie: [\"{1:{2:Das} war ich}!\"] und ging.",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("Er schrie: [\"{1:{2:Das} war ich}!\"] und ging.",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 	sq = new SpanClassQuery(
           new SpanWithinQuery(
@@ -847,8 +830,8 @@
         ), (byte) 1);
 
 	kr = ki.search(sq, (short) 15);
-	assertEquals("Er schrie: [\"{1:Das {2:war} ich}!\"] und ging.",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("Er schrie: [\"{1:Das {2:war} ich}!\"] und ging.",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 	sq = new SpanClassQuery(
           new SpanWithinQuery(
@@ -859,8 +842,8 @@
         ), (byte) 1);
 
 	kr = ki.search(sq, (short) 15);
-	assertEquals("Er schrie: [\"{1:Das war {2:ich}}!\"] und ging.",kr.match(0).snippetBrackets());
-	assertEquals("totalResults", 1, kr.totalResults());
+	assertEquals("Er schrie: [\"{1:Das war {2:ich}}!\"] und ging.",kr.getMatch(0).snippetBrackets());
+	assertEquals("totalResults", kr.getTotalResults(), 1);
 
 	sq = new SpanClassQuery(
           new SpanWithinQuery(
@@ -871,7 +854,7 @@
         ), (byte) 1);
 
 	kr = ki.search(sq, (short) 15);
-	assertEquals("totalResults", 0, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 0);
 
 	sq = new SpanClassQuery(
           new SpanWithinQuery(
@@ -882,7 +865,7 @@
         ), (byte) 1);
 
 	kr = ki.search(sq, (short) 15);
-	assertEquals("totalResults", 0, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 0);
     };
 
     //!! Offset is 1 token tooo long
@@ -916,12 +899,11 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	// System.err.println(kr.toJSON());
-	assertEquals("totalResults", 2, kr.totalResults());
-	assertEquals("StartPos (0)", 2, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 3, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 2, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 5, kr.match(1).endPos);
+	assertEquals("totalResults", kr.getTotalResults(), 2);
+	assertEquals("StartPos (0)", 2, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 3, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 2, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 5, kr.getMatch(1).endPos);
     };
 
 
@@ -961,16 +943,16 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 4, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 4);
 
-	assertEquals("StartPos (0)", 3, kr.match(0).startPos);
-	assertEquals("EndPos (0)", 10, kr.match(0).endPos);
-	assertEquals("StartPos (1)", 3, kr.match(1).startPos);
-	assertEquals("EndPos (1)", 10, kr.match(1).endPos);
-	assertEquals("StartPos (2)", 3, kr.match(2).startPos);
-	assertEquals("EndPos (2)", 10, kr.match(2).endPos);
-	assertEquals("StartPos (3)", 5, kr.match(3).startPos);
-	assertEquals("EndPos (3)", 8, kr.match(3).endPos);
+	assertEquals("StartPos (0)", 3, kr.getMatch(0).startPos);
+	assertEquals("EndPos (0)", 10, kr.getMatch(0).endPos);
+	assertEquals("StartPos (1)", 3, kr.getMatch(1).startPos);
+	assertEquals("EndPos (1)", 10, kr.getMatch(1).endPos);
+	assertEquals("StartPos (2)", 3, kr.getMatch(2).startPos);
+	assertEquals("EndPos (2)", 10, kr.getMatch(2).endPos);
+	assertEquals("StartPos (3)", 5, kr.getMatch(3).startPos);
+	assertEquals("EndPos (3)", 8, kr.getMatch(3).endPos);
     };
 
     @Test
@@ -1010,7 +992,7 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 0, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 0);
     };
 
 
@@ -1050,7 +1032,7 @@
 
 	KorapResult kr = ki.search(sq, (short) 10);
 
-	assertEquals("totalResults", 0, kr.totalResults());
+	assertEquals("totalResults", kr.getTotalResults(), 0);
     };
     
     /** SpanElementQueries 
@@ -1080,7 +1062,7 @@
 	
 	String jsonPath = getClass().getResource("/queries/poly2.json").getFile();
 	String jsonPQuery = readFile(jsonPath);		
-	SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON(
+	SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJson(
 								  jsonPQuery
 								  );
 		
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
index becff26..0a75172 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestKorapQueryJSON.java
@@ -184,7 +184,7 @@
 
     @Test
     public void queryJSONDemo () throws QueryException {
-	SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJSON("{ \"query\" : { \"@type\" : \"korap:token\", \"wrap\" : { \"@type\" : \"korap:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
+	SpanQueryWrapper sqwi = new KorapQuery("tokens").fromJson("{ \"query\" : { \"@type\" : \"korap:token\", \"wrap\" : { \"@type\" : \"korap:term\", \"foundry\" : \"base\", \"layer\" : \"p\", \"key\" : \"foo\", \"match\" : \"match:eq\" }}}");
 
 	assertEquals(sqwi.toQuery().toString(), "tokens:base/p:foo");
     };
@@ -306,7 +306,7 @@
 	// ((MORPH(APPR) ODER MORPH(APPRART)) /+w1 Urlaub
 	try {
 	    String json = getString(getClass().getResource("/queries/bugs/underspecified_token.jsonld").getFile());
-	    new KorapQuery("tokens").fromJSON(json);
+	    new KorapQuery("tokens").fromJson(json);
 	}
 	catch (QueryException e) {
 	    assertEquals(701, e.getErrorCode());
@@ -357,7 +357,7 @@
 	
 	try {
 	    String json = getString(jsonFile);
-	    sqwi = new KorapQuery("tokens").fromJSON(json);
+	    sqwi = new KorapQuery("tokens").fromJson(json);
 	}
 	catch (QueryException e) {
 	    fail(e.getMessage());
diff --git a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
index 608c9de..afa8bab 100644
--- a/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
+++ b/src/test/java/de/ids_mannheim/korap/query/TestTemporaryQueryLimitations.java
@@ -55,7 +55,7 @@
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
 	assertEquals(kr.getQuery(),"shrink(130: {131: spanContain({129: <tokens:s />}, {130: tokens:s:wegen})})");
-	assertEquals(kr.totalResults(),0);
+	assertEquals(kr.getTotalResults(),0);
 	assertEquals(kr.getStartIndex(),0);
 
 	assertEquals("This is a warning coming from the serialization",
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestMessage.java b/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
index 440e027..094a38b 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestMessage.java
@@ -15,27 +15,27 @@
     @Test
     public void StringMessage () {
 	Messages km = new Messages();
-	assertEquals("[]", km.toJSON());
+	assertEquals("[]", km.toJsonString());
     };
 
     @Test
     public void StringMessageSet () {
 	Messages km = new Messages();
 	km.add(612,"Foo");
-	assertEquals("[[612,\"Foo\"]]", km.toJSON());
+	assertEquals("[[612,\"Foo\"]]", km.toJsonString());
 	km.add(613,"Bar");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\"]]", km.toJSON());
+	assertEquals("[[612,\"Foo\"],[613,\"Bar\"]]", km.toJsonString());
     };
 
     @Test
     public void StringMessageParameters () {
 	Messages km = new Messages();
 	km.add(612,"Foo");
-	assertEquals("[[612,\"Foo\"]]", km.toJSON());
+	assertEquals("[[612,\"Foo\"]]", km.toJsonString());
 	km.add(613,"Bar", "Instanz");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"]]", km.toJSON());
+	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"]]", km.toJsonString());
 	km.add(614,"Test");
-	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"],[614,\"Test\"]]", km.toJSON());
+	assertEquals("[[612,\"Foo\"],[613,\"Bar\",\"Instanz\"],[614,\"Test\"]]", km.toJsonString());
     };
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java b/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
index f92af6e..9bbf396 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestNotifications.java
@@ -22,7 +22,7 @@
     @Test
     public void testNotification () {
 	Notifications notes = new Notifications();
-	assertEquals("{}", notes.toJSON());
+	assertEquals("{}", notes.toJsonString());
     };
 
     @Test
@@ -36,7 +36,7 @@
 	notes.addWarning(614, "Bar", "Spiel");
 
 	assertEquals("{\"warnings\":[[613,\"Foo\"],[614,\"Bar\"," +
-		     "\"Spiel\"]]}", notes.toJSON());
+		     "\"Spiel\"]]}", notes.toJsonString());
 
 	assertTrue(notes.hasWarnings());
 	assertFalse(notes.hasMessages());
@@ -48,7 +48,7 @@
 	assertFalse(notes.hasMessages());
 	assertTrue(notes.hasErrors());
 
-	JsonNode noteJson = mapper.readTree(notes.toJSON());
+	JsonNode noteJson = mapper.readTree(notes.toJsonString());
 
 	// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],"errors":[[412,"Test"]]}
 	assertEquals(613, noteJson.at("/warnings/0/0").asInt());
@@ -65,7 +65,7 @@
 	assertTrue(notes.hasMessages());
 	assertTrue(notes.hasErrors());
 
-	noteJson = mapper.readTree(notes.toJSON());
+	noteJson = mapper.readTree(notes.toJsonString());
 
 	// {"warnings":[[613,"Foo"],[614,"Bar","Spiel"]],
 	// "errors":[[412,"Test"]]}
@@ -85,7 +85,7 @@
 
 	Messages msgs = notes.getWarnings();
 	assertEquals("[[613,\"Foo\"],[614,\"Bar\",\"Spiel\"]]",
-		     msgs.toJSON());
+		     msgs.toJsonString());
     };
 
 
@@ -115,7 +115,7 @@
 	assertTrue(notes1.hasMessages());
 	assertTrue(notes1.hasErrors());
 
-	JsonNode noteJson = mapper.readTree(notes1.toJSON());
+	JsonNode noteJson = mapper.readTree(notes1.toJsonString());
 	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
 	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
 	assertEquals(2, noteJson.at("/warnings/1/0").asInt());
@@ -152,7 +152,7 @@
 	assertTrue(notes1.hasMessages());
 	assertTrue(notes1.hasErrors());
 
-	noteJson = mapper.readTree(notes1.toJSON());
+	noteJson = mapper.readTree(notes1.toJsonString());
 
 	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
 	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
@@ -179,7 +179,7 @@
 	assertTrue(notes1.hasMessages());
 	assertTrue(notes1.hasErrors());
 
-	noteJson = mapper.readTree(notes1.toJSON());
+	noteJson = mapper.readTree(notes1.toJsonString());
 
 	assertEquals(1, noteJson.at("/warnings/0/0").asInt());
 	assertEquals("Foo", noteJson.at("/warnings/0/1").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
index 57babbb..b2116cb 100644
--- a/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
+++ b/src/test/java/de/ids_mannheim/korap/response/TestResponse.java
@@ -23,7 +23,7 @@
     @Test
     public void testResponse () throws IOException {
 	KorapResponse resp = new KorapResponse();
-	assertEquals("{}", resp.toJSON());
+	assertEquals("{}", resp.toJsonString());
 	resp.setVersion("0.24");
 	resp.setNode("Tanja");
 	assertEquals("0.24",resp.getVersion());
@@ -33,18 +33,18 @@
 	assertFalse(resp.hasMessages());
 	assertFalse(resp.hasErrors());
 
-	JsonNode respJson = mapper.readTree(resp.toJSON());
+	JsonNode respJson = mapper.readTree(resp.toJsonString());
 	assertEquals("0.24", respJson.at("/version").asText());
 	assertEquals("Tanja", respJson.at("/node").asText());
 
 	resp.setName("Index");
-	respJson = mapper.readTree(resp.toJSON());
+	respJson = mapper.readTree(resp.toJsonString());
 	assertEquals("Index-0.24", respJson.at("/version").asText());
 	assertEquals("Tanja", respJson.at("/node").asText());
 
 	resp.setBenchmark("took a while");
 	resp.setListener("localhost:3000");
-	respJson = mapper.readTree(resp.toJSON());
+	respJson = mapper.readTree(resp.toJsonString());
 	assertEquals("localhost:3000", respJson.at("/listener").asText());
 	assertEquals("took a while", respJson.at("/benchmark").asText());
     };
@@ -52,7 +52,7 @@
     @Test
     public void testResponseNotifications () throws IOException {
 	KorapResponse resp = new KorapResponse();
-	assertEquals("{}", resp.toJSON());
+	assertEquals("{}", resp.toJsonString());
 	resp.setVersion("0.24");
 	resp.setNode("Tanja");
 	assertEquals("0.24",resp.getVersion());
@@ -62,7 +62,7 @@
 	assertFalse(resp.hasMessages());
 	assertFalse(resp.hasErrors());
 
-	JsonNode respJson = mapper.readTree(resp.toJSON());
+	JsonNode respJson = mapper.readTree(resp.toJsonString());
 	assertEquals("0.24", respJson.at("/version").asText());
 	assertEquals("Tanja", respJson.at("/node").asText());
 
@@ -72,7 +72,7 @@
 
 	resp.addError(4, "Fehler 4");
 
-	respJson = mapper.readTree(resp.toJSON());
+	respJson = mapper.readTree(resp.toJsonString());
 	assertEquals("0.24", respJson.at("/version").asText());
 	assertEquals("Tanja", respJson.at("/node").asText());
 
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
index 76f3736..0357cca 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapResult.java
@@ -57,10 +57,10 @@
 	KorapQuery kq = new KorapQuery("base");
 	SpanQuery q = (SpanQuery) kq.or(kq._(1, kq.seg("s:a"))).or(kq._(2, kq.seg("s:b"))).toQuery();
 	KorapResult kr = ki.search(q);
-	assertEquals(7, kr.getTotalResults());
+	assertEquals((long) 7, kr.getTotalResults());
 
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toJSON());
+	JsonNode res = mapper.readTree(kr.toJsonString());
 	assertEquals(7, res.at("/totalResults").asInt());
 	assertEquals("spanOr([{1: base:s:a}, {2: base:s:b}])", res.at("/query").asText());
 	assertEquals(0, res.at("/startIndex").asInt());
@@ -113,10 +113,10 @@
 	KorapSearch ks = new KorapSearch(json);
 
 	KorapResult kr = ks.run(ki);
-	assertEquals(2, kr.getTotalResults());
+	assertEquals((long) 2, kr.getTotalResults());
 
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toJSON());
+	JsonNode res = mapper.readTree(kr.toJsonString());
 
 	// Old:
 	// assertEquals("Optionality of query is ignored", res.at("/warning").asText());
@@ -155,10 +155,10 @@
 	String json = getString(getClass().getResource("/queries/bsp-result-check.jsonld").getFile());
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(7, kr.getTotalResults());
+	assertEquals((long) 7, kr.getTotalResults());
 
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toJSON());
+	JsonNode res = mapper.readTree(kr.toJsonString());
 
 	assertEquals(7, res.at("/totalResults").asInt());
 	assertEquals("spanOr([tokens:s:a, tokens:s:b])", res.at("/query").asText());
@@ -224,9 +224,9 @@
 	SpanQuery q = (SpanQuery) kq.seq(kq.seg("s:a")).append(kq.seg("s:b")).toQuery();
 	KorapResult kr = ki.search(q);
 
-	assertEquals(3, kr.getTotalResults());
+	assertEquals((long) 3, kr.getTotalResults());
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toTokenListJSON());
+	JsonNode res = mapper.readTree(kr.toTokenListJsonString());
 	assertEquals(3, res.at("/totalResults").asInt());
 	assertEquals("spanNext(base:s:a, base:s:b)", res.at("/query").asText());
 	assertEquals(0, res.at("/startIndex").asInt());
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
index 240f33c..d7f30a4 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestKorapSearch.java
@@ -103,7 +103,7 @@
 	ks.context.left.setLength(1);
 	ks.context.right.setLength(1);
 	KorapResult kr = ks.run(ki);
-	assertEquals(6, kr.totalResults());
+	assertEquals(kr.getTotalResults(), 6);
 	assertEquals(kr.getMatch(0).getSnippetBrackets(), "... dem [Buchstaben] A ...");
     };
 
@@ -131,7 +131,7 @@
 	KorapSearch ks = new KorapSearch(json);
 	
 	KorapResult kr = ks.run(ki);
-	assertEquals(66, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 66);
 	assertEquals(5, kr.getItemsPerPage());
 	assertEquals(5, kr.getStartIndex());
 	assertEquals("... a: A ist [der klangreichste] der V ...", kr.getMatch(0).getSnippetBrackets());
@@ -169,24 +169,24 @@
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
 
-	assertEquals(1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 1);
 
 	ks = new KorapSearch(json);
 	// Ignore the collection part of the query!
 	ks.setCollection(new KorapCollection());
 	kr = ks.run(ki);
 
-	assertEquals(5, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 5);
 
 	json = getString(getClass().getResource("/queries/metaquery5.jsonld").getFile());
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
-	assertEquals(1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 1);
 
 	json = getString(getClass().getResource("/queries/metaquery6.jsonld").getFile());
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
-	assertEquals(1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 1);
     };
 
 
@@ -212,7 +212,7 @@
 
 	KorapResult kr = new KorapSearch("{ query").run(ki);
 
-	assertEquals(0, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 0);
 	assertEquals(kr.getError(0).getMessage(), "Unable to parse JSON");
     };
 
@@ -241,7 +241,7 @@
 
 	KorapResult kr = new KorapSearch(json).run(ki);
 	assertEquals(0, kr.getStartIndex());
-	assertEquals(0, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 0);
 	assertEquals(25, kr.getItemsPerPage());
     };
 
@@ -269,7 +269,7 @@
 	KorapResult kr = new KorapSearch(json).run(ki);
 	assertEquals(50, kr.getItemsPerPage());
 	assertEquals(49950, kr.getStartIndex());
-	assertEquals(0, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 0);
     };
 
 
@@ -296,13 +296,13 @@
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 10);
 	assertEquals("A bzw. a ist der erste Buchstabe des lateinischen [Alphabets] und ein Vokal. Der Buchstabe A hat in deutschen Texten eine durchschnittliche Häufigkeit  ...", kr.getMatch(0).getSnippetBrackets());
 
 	ks.setCount(5);
 	ks.setStartPage(2);
 	kr = ks.run(ki);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 10);
 	assertEquals(5, kr.getStartIndex());
 	assertEquals(5, kr.getItemsPerPage());
 
@@ -310,7 +310,7 @@
 	json = getString(getClass().getResource("/queries/bsp-context-2.jsonld").getFile());
 
 	kr = new KorapSearch(json).run(ki);
-	assertEquals(-1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), -1);
 	assertEquals("... lls seit den Griechen beibehalten worden. 3. Bedeutungen in der Biologie steht A für das Nukleosid Adenosin steht A die Base Adenin steht A für die Aminosäure Alanin in der Informatik steht a für den dezimalen [Wert] 97 sowohl im ASCII- als auch im Unicode-Zeichensatz steht A für den dezimalen Wert 65 sowohl im ASCII- als auch im Unicode-Zeichensatz als Kfz-Kennzeichen steht A in Deutschland für Augsburg. in Österreich auf ...", kr.getMatch(0).getSnippetBrackets());
     };
 
@@ -337,7 +337,7 @@
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 10);
 	assertEquals(5, kr.getStartIndex());
 	assertEquals(5, kr.getItemsPerPage());
 
@@ -345,7 +345,7 @@
 	ks = ks = new KorapSearch(json);
 
 	kr = ks.run(ki);
-	assertEquals(-1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), -1);
 	assertEquals(2, kr.getStartIndex());
 	assertEquals(2, kr.getItemsPerPage());
 
@@ -379,7 +379,7 @@
 
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(10, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 10);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(20, kr.getItemsPerPage());
 
@@ -399,7 +399,7 @@
 	assertEquals("WPD_AAA.00002", kr.getMatch(1).getDocID());
 	assertEquals("WPD_AAA.00004", kr.getMatch(2).getDocID());
 
-	assertEquals(3, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 3);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(20, kr.getItemsPerPage());
 
@@ -409,15 +409,13 @@
 
 	kr = ks.run(ki);
 
-	//	System.err.println(kr.toJSON());
-
 	assertEquals("WPD_AAA.00001", kr.getMatch(0).getDocID());
 	assertEquals("WPD_AAA.00001", kr.getMatch(1).getDocID());
 	assertEquals("WPD_AAA.00002", kr.getMatch(2).getDocID());
 	assertEquals("WPD_AAA.00002", kr.getMatch(3).getDocID());
 	assertEquals("WPD_AAA.00004", kr.getMatch(4).getDocID());
 
-	assertEquals(5, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 5);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(20, kr.getItemsPerPage());
 
@@ -431,7 +429,7 @@
 	
 	assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
 
-	assertEquals(3, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 3);
 	assertEquals(1, kr.getStartIndex());
 	assertEquals(1, kr.getItemsPerPage());
 
@@ -477,7 +475,7 @@
 
 	KorapResult kr = ks.run(ki);
 
-	assertEquals(2, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 2);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(25, kr.getItemsPerPage());
     };
@@ -538,7 +536,7 @@
         );
 	KorapResult kr = ks.run(ki);
 
-	assertEquals(148, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 148);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(25, kr.getItemsPerPage());
     };
@@ -603,7 +601,7 @@
         );
 	KorapResult kr = ks.run(ki);
 
-	assertEquals(6, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 6);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(25, kr.getItemsPerPage());
     };
@@ -669,7 +667,7 @@
 	    "ins Leben] gerufen hatten. Pressemeldungen zufolge haben sich ..."
         );
 
-	assertEquals(1, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 1);
 	assertEquals(0, kr.getStartIndex());
     };
 
@@ -704,7 +702,7 @@
 	    "Pressemeldungen zufolge haben sich in ..."
         );
 
-	assertEquals(2, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 2);
 	assertEquals(0, kr.getStartIndex());
     };
 
@@ -730,7 +728,7 @@
 	KorapResult kr = ks.run(ki);
 
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toTokenListJSON());
+	JsonNode res = mapper.readTree(kr.toTokenListJsonString());
 
 	assertEquals(1, res.at("/totalResults").asInt());
 	assertEquals("{4: spanNext({1: spanNext({2: tokens:s:ins}, " +
@@ -789,7 +787,7 @@
 	    "SpanMultiTermQueryWrapper(tokens:/tt/p:N.*/))])"
         );
 
-	assertEquals(58, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 58);
 	assertEquals(0, kr.getStartIndex());
 
 	assertEquals(
@@ -842,7 +840,7 @@
 	
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(276, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 276);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(10, kr.getItemsPerPage());
 
@@ -851,7 +849,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 
-	assertEquals(147, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 147);
 	assertEquals("WPD_AAA.00001", kr.getMatch(0).getDocID());
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(10, kr.getItemsPerPage());
@@ -861,7 +859,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 
-	assertEquals(28, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 28);
 	assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(10, kr.getItemsPerPage());
@@ -871,7 +869,7 @@
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
 
-	assertEquals(0, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 0);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(10, kr.getItemsPerPage());
 
@@ -882,7 +880,7 @@
 
 	assertEquals("filter with QueryWrapperFilter(+(ID:WPD_AAA.00003 (+tokens:s:die +tokens:s:Schriftzeichen)))", ks.getCollection().getFilter(1).toString());
 
-	assertEquals(119, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 119);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(10, kr.getItemsPerPage());
     };
@@ -911,10 +909,10 @@
 
 	KorapResult kr = ks.run(ki);
 	assertEquals(kr.getMatch(1).getSnippetBrackets(), "... dezimalen [Wert] 65 sowohl ...");
-	assertEquals(3, kr.getTotalResults());
+	assertEquals(kr.getTotalResults(), 3);
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(25, kr.getItemsPerPage());
-	assertFalse(kr.getContext().toJSON().toString().equals("\"s\""));
+	assertFalse(kr.getContext().toJsonNode().toString().equals("\"s\""));
 
 	json = getString(getClass().getResource("/queries/bsp-context-sentence.jsonld").getFile());
 
@@ -926,7 +924,7 @@
 	assertEquals(kr.getMatch(2).getSnippetBrackets(),
 		     "In einem Zahlensystem mit einer Basis größer als 10 steht A oder a häufig für den dezimalen [Wert] 10, siehe auch Hexadezimalsystem.");
 
-	assertEquals(kr.getContext().toJSON().toString(), "\"s\"");
+	assertEquals(kr.getContext().toJsonNode().toString(), "\"s\"");
     };
 
 
@@ -982,7 +980,7 @@
 			     "in Eigennamen und Ortsnamen ...",
 			     kr.getMatch(0).getSnippetBrackets());
 		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(1, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1);
 	
 		// der alte Digraph Aa durch []
 		// Works with one document
@@ -997,7 +995,7 @@
 			     "in Eigennamen und Ortsnamen ...",
 			     kr.getMatch(0).getSnippetBrackets());
 		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(1, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1);
 	
 		// Now try with one file ahead
 		ki = new KorapIndex();
@@ -1022,7 +1020,7 @@
 			     "in Eigennamen und Ortsnamen ...",
 			     kr.getMatch(0).getSnippetBrackets());
 		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(1, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1);
 	
 		// der alte Digraph Aa durch []
 		json = getString(
@@ -1035,7 +1033,7 @@
 			     "in Eigennamen und Ortsnamen ...",
 			     kr.getMatch(0).getSnippetBrackets());
 		assertEquals("WPD_AAA.00002", kr.getMatch(0).getDocID());
-		assertEquals(1, kr.getTotalResults());
+		assertEquals(kr.getTotalResults(), 1);
     };
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
index 0677fc1..34b1f29 100644
--- a/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
+++ b/src/test/java/de/ids_mannheim/korap/search/TestMetaFields.java
@@ -51,12 +51,12 @@
 	
 	KorapSearch ks = new KorapSearch(json);
 	KorapResult kr = ks.run(ki);
-	assertEquals(17, kr.getTotalResults());
+	assertEquals((long) 17, kr.getTotalResults());
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(9, kr.getItemsPerPage());
 
 	ObjectMapper mapper = new ObjectMapper();
-	JsonNode res = mapper.readTree(kr.toJSON());
+	JsonNode res = mapper.readTree(kr.toJsonString());
 	assertEquals(0, res.at("/matches/0/UID").asInt());
 	assertEquals("WPD", res.at("/matches/0/corpusID").asText());
 	assertEquals("", res.at("/matches/0/docID").asText());
@@ -77,12 +77,12 @@
         );
 	ks = new KorapSearch(json);
 	kr = ks.run(ki);
-	assertEquals(17, kr.getTotalResults());
+	assertEquals((long) 17, kr.getTotalResults());
 	assertEquals(0, kr.getStartIndex());
 	assertEquals(2, kr.getItemsPerPage());
 	
 	mapper = new ObjectMapper();
-	res = mapper.readTree(kr.toJSON());
+	res = mapper.readTree(kr.toJsonString());
 	assertEquals(0, res.at("/matches/0/UID").asInt());
 	assertEquals("", res.at("/matches/0/corpusID").asText());
 	assertEquals("Ruru,Jens.Ol,Aglarech", res.at("/matches/0/author").asText());