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..99b4372 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();
     }
@@ -128,9 +128,13 @@
         //        meta.addEntry("itemsPerResource", 1);
         serializer.addMeta(meta);
 
+        if (cq != null)
+            serializer.setCollection(cq);
+
         String query = processor.process(serializer.toJSON());
         jlog.info("the serialized query {}", query);
 
+        // This may not work with the the KoralQuery
         if (eng.equals(KustvaktConfiguration.BACKENDS.NEO4J)) {
             MultivaluedMap map = new MultivaluedMapImpl();
             map.add("q", query);
@@ -145,7 +149,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 +216,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 +235,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 +251,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 +273,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
