diff --git a/src/main/java/de/ids_mannheim/korap/web/SearchLucene.java b/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
similarity index 83%
rename from src/main/java/de/ids_mannheim/korap/web/SearchLucene.java
rename to src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
index be19540..d04193e 100644
--- a/src/main/java/de/ids_mannheim/korap/web/SearchLucene.java
+++ b/src/main/java/de/ids_mannheim/korap/web/SearchKrill.java
@@ -18,15 +18,14 @@
 import java.util.List;
 
 /**
- * The SearchLucene class allows for searching in the Lucene backend
- * by JSON-LD serialized queries.
- * It supports span queries, virtual collections, and paging.
+ * The SearchKrill class allows for searching in the
+ * Lucene based Krill backend by applying KoralQuery.
  *
  * @author Nils Diewald
  */
-public class SearchLucene {
+public class SearchKrill {
     private final static Logger qlog = KorAPLogger.initiate("queryLogger");
-    private final static Logger log = KorAPLogger.initiate(SearchLucene.class);
+    private final static Logger log = KorAPLogger.initiate(SearchKrill.class);
     // Temporary
     String indexDir = "/data/prep_corpus/index/";
     String i = "/Users/hanl/Projects/prep_corpus";
@@ -38,7 +37,7 @@
      * Constructor
      */
     // todo: use korap.config to get index location
-    public SearchLucene(String path) {
+    public SearchKrill(String path) {
         try {
             File f = new File(path);
             log.info("Loading index from " + path);
@@ -47,7 +46,7 @@
                 System.exit(-1);
             }
             this.index = new KrillIndex(new MMapDirectory(new File(path)));
-        }catch (IOException e) {
+        } catch (IOException e) {
             KorAPLogger.ERROR_LOGGER
                     .error("Unable to load index: {}", e.getMessage());
         }
@@ -61,31 +60,28 @@
     public String search(String json) {
         qlog.trace(json);
         if (this.index != null)
-            return new Krill(json).setIndex(this.index).toJsonString();
+            return new Krill(json).apply(this.index).toJsonString();
 
         Result kr = new Result();
-        //        kr.setError("Index not found");
+        kr.addError(601, "Unable to find index");
         return kr.toJsonString();
-    }
-
-    ;
+    };
 
     /**
      * Search in the Lucene index and return matches as token lists.
      *
      * @param json JSON-LD string with search and potential meta filters.
      */
+    @Deprecated
     public String searchTokenList(String json) {
         qlog.trace(json);
         if (this.index != null)
-            return new Krill(json).setIndex(this.index).toJsonString();
+            return new Krill(json).apply(this.index).toTokenListJsonString();
 
         Result kr = new Result();
-        //        kr.setError("Index not found");
+        kr.addError(601, "Unable to find index");
         return kr.toJsonString();
-    }
-
-    ;
+    };
 
     /**
      * Get info on a match - by means of a richly annotated html snippet.
@@ -97,17 +93,17 @@
         if (this.index != null) {
             try {
                 return this.index.getMatch(id).toJsonString();
-            }catch (QueryException qe) {
+            } catch (QueryException qe) {
                 Match km = new Match();
-                km.setError(qe.getMessage());
+                km.addError(qe.getErrorCode(), qe.getMessage());
                 return km.toJsonString();
             }
-        }
+        };
 
         Match km = new Match();
-        km.setError("Index not found");
+        km.addError(601, "Unable to find index");
         return km.toJsonString();
-    }
+    };
 
     public String getMatch(String id, List<String> foundries,
             List<String> layers, boolean includeSpans,
@@ -119,18 +115,18 @@
                         .getMatchInfo(id, "tokens", true, foundries, layers,
                                 includeSpans, includeHighlights,
                                 sentenceExpansion).toJsonString();
-            }catch (QueryException qe) {
+            } catch (QueryException qe) {
                 Match km = new Match();
-                km.setError(qe.getMessage());
+                km.addError(qe.getErrorCode(), qe.getMessage());
                 return km.toJsonString();
             }
-        }
+        };
 
         Match km = new Match();
-        km.setError("Index not found");
+        km.addError(601, "Unable to find index");
         return km.toJsonString();
+    };
 
-    }
 
     /**
      * Get info on a match - by means of a richly annotated html snippet.
@@ -141,7 +137,7 @@
      * @param includeSpans      Should spans be included (or only token infos)?
      * @param includeHighlights Should highlight markup be included?
      */
-    public String getMatch(String id, String foundry, String layer,
+    public String getMatch (String id, String foundry, String layer,
             boolean includeSpans, boolean includeHighlights,
             boolean sentenceExpansion) {
 
@@ -163,24 +159,25 @@
                 return this.index.getMatchInfo(id, "tokens", foundry, layer,
                         includeSpans, includeHighlights, sentenceExpansion)
                         .toJsonString();
-            }catch (QueryException qe) {
+            } catch (QueryException qe) {
                 Match km = new Match();
-                km.setError(qe.getMessage());
+                km.addError(qe.getErrorCode(), qe.getMessage());
                 return km.toJsonString();
             }
-        }
+        };
 
         Match km = new Match();
-        km.setError("Index not found");
+        km.addError(601, "Unable to find index");
         return km.toJsonString();
-    }
+    };
 
     /**
      * Get statistics on (virtual) collections.
      *
      * @param json JSON-LD string with potential meta filters.
      */
-    public String getStatisticsLegacy(JsonNode json) throws QueryException {
+    @Deprecated
+    public String getStatisticsLegacy (JsonNode json) throws QueryException {
         qlog.trace(JsonUtils.toJSON(json));
         System.out.println("THE NODE BEFORE GETTING STATISTICS " + json);
 
@@ -196,9 +193,9 @@
         kc.setIndex(this.index);
 
         long docs = 0,
-                tokens = 0,
-                sentences = 0,
-                paragraphs = 0;
+            tokens = 0,
+            sentences = 0,
+            paragraphs = 0;
 
         // Get numbers from index (currently slow)
         try {
@@ -206,7 +203,7 @@
             tokens = kc.numberOf("tokens");
             sentences = kc.numberOf("sentences");
             paragraphs = kc.numberOf("paragraphs");
-        }catch (IOException e) {
+        } catch (IOException e) {
             e.printStackTrace();
         }
 
@@ -228,7 +225,8 @@
      *
      * @param json JSON-LD string with potential meta filters.
      */
-    public String getStatistics(String json) {
+    @Deprecated
+    public String getStatistics (String json) {
         qlog.trace(json);
 
         if (this.index == null) {
@@ -252,7 +250,7 @@
             tokens = kc.numberOf("tokens");
             sentences = kc.numberOf("sentences");
             paragraphs = kc.numberOf("paragraphs");
-        }catch (IOException e) {
+        } catch (IOException e) {
             e.printStackTrace();
         }
 
@@ -274,7 +272,8 @@
      *
      * @param json JSON-LD string with potential meta filters.
      */
-    public String getTermRelation(String json, String field) {
+    @Deprecated
+    public String getTermRelation (String json, String field) {
         qlog.trace(json);
 
         if (this.index == null) {
@@ -289,14 +288,14 @@
         long v = 0L;
         try {
             v = kc.numberOf("documents");
-        }catch (IOException e) {
+        } catch (IOException e) {
             e.printStackTrace();
         }
 
         try {
             // Get term relations as a json string
             return kc.getTermRelationJSON(field);
-        }catch (IOException e) {
+        } catch (IOException e) {
             KorAPLogger.ERROR_LOGGER
                     .error("Unable to retrieve term relations: {}",
                             e.getMessage());
@@ -304,7 +303,7 @@
         }
     }
 
-    public String getMatchId(String type, String docid, String tofrom) {
+    public String getMatchId (String type, String docid, String tofrom) {
         return new StringBuilder().append("contains-").append(type).append("!")
                 .append(type).append("_").append(docid).append("-")
                 .append(tofrom).toString();
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
index 35e1c6b..f064d33 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
@@ -12,7 +12,7 @@
 import de.ids_mannheim.korap.utils.KorAPLogger;
 import de.ids_mannheim.korap.utils.StringUtils;
 import de.ids_mannheim.korap.web.ClientsHandler;
-import de.ids_mannheim.korap.web.SearchLucene;
+import de.ids_mannheim.korap.web.SearchKrill;
 import de.ids_mannheim.korap.web.TRACE;
 import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
 import org.slf4j.Logger;
@@ -34,12 +34,12 @@
 
     private static Logger jlog = KorAPLogger.initiate(LightService.class);
 
-    private SearchLucene searchLucene;
+    private SearchKrill searchKrill;
     private ClientsHandler graphDBhandler;
     private RewriteProcessor processor;
 
     public LightService() {
-        this.searchLucene = new SearchLucene(
+        this.searchKrill = new SearchKrill(
                 BeanConfiguration.getConfiguration().getIndexDir());
         UriBuilder builder = UriBuilder.fromUri("http://10.0.10.13").port(9997);
         this.graphDBhandler = new ClientsHandler(builder.build());
@@ -101,8 +101,8 @@
         // todo: should be possible to add the meta part to the query serialization
         jlog.info("Serialized search: {}", jsonld);
 
-        // fixme: to use the systemarchitecture pointcut thingis, searchlucene must be injected via
-        String result = searchLucene.search(jsonld);
+        // fixme: to use the systemarchitecture pointcut thingis, searchkrill must be injected via
+        String result = searchKrill.search(jsonld);
         KorAPLogger.QUERY_LOGGER.trace("The result set: {}", result);
         return Response.ok(result).build();
     }
@@ -145,7 +145,7 @@
                 throw KustvaktResponseHandler.throwit(e);
             }
         }else
-            result = searchLucene.search(query);
+            result = searchKrill.search(query);
         KorAPLogger.QUERY_LOGGER.trace("The result set: {}", result);
         return Response.ok(result).build();
     }
@@ -212,7 +212,7 @@
                         String.valueOf(meta.getSpanContext().getRight_size()));
                 result = this.graphDBhandler.getResponse(map, "distKwic");
             }else
-                result = searchLucene.search(query);
+                result = searchKrill.search(query);
 
         }catch (Exception e) {
             KorAPLogger.ERROR_LOGGER
@@ -231,7 +231,7 @@
         CollectionQueryBuilder builder = new CollectionQueryBuilder();
         builder.addResource(json);
 
-        String stats = searchLucene.getStatistics(builder.toCollections());
+        String stats = searchKrill.getStatistics(builder.toCollections());
         if (stats.contains("-1"))
             throw KustvaktResponseHandler.throwit(StatusCodes.EMPTY_RESULTS);
 
@@ -247,7 +247,7 @@
             @QueryParam("layer") Set<String> layers,
             @QueryParam("spans") Boolean spans) {
         spans = spans != null ? spans : false;
-        String matchid = searchLucene.getMatchId(id, docid, rest);
+        String matchid = searchKrill.getMatchId(id, docid, rest);
 
         if (layers == null || layers.isEmpty())
             layers = new HashSet<>();
@@ -269,18 +269,18 @@
                     f_list.add(sep[0]);
                     l_list.add(sep[1]);
                 }
-                results = searchLucene
+                results = searchKrill
                         .getMatch(matchid, new ArrayList<>(f_list),
                                 new ArrayList<>(l_list), spans, false, true);
             }
         }
         try {
             if (!match_only)
-                results = searchLucene
+                results = searchKrill
                         .getMatch(matchid, new ArrayList<>(foundries),
                                 new ArrayList<>(layers), spans, false, true);
             else
-                results = searchLucene.getMatch(matchid);
+                results = searchKrill.getMatch(matchid);
         }catch (Exception e) {
             KorAPLogger.ERROR_LOGGER.error("Exception encountered!", e);
             throw KustvaktResponseHandler
