text rewrite tests
diff --git a/pom.xml b/pom.xml
index dd918d6..cdde2f4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
     <modelVersion>4.0.0</modelVersion>
     <groupId>de.ids_mannheim.korap</groupId>
     <artifactId>Kustvakt-core</artifactId>
-    <version>0.59.2</version>
+    <version>0.59.4</version>
     <packaging>jar</packaging>
     <name>Kustvakt core</name>
     <description>Kustvakt core, basic rest api for testing purposes and default
@@ -131,7 +131,7 @@
                     <compilerCompliance>1.7</compilerCompliance>
                     <compilerTargetPlatform>1.7</compilerTargetPlatform>
                 </configuration>
-                <!--
+
                 <executions>
                     <execution>
                         <goals>
@@ -139,7 +139,7 @@
                         </goals>
                     </execution>
                 </executions>
-                -->
+
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/main/java/de/ids_mannheim/korap/config/Attributes.java b/src/main/java/de/ids_mannheim/korap/config/Attributes.java
index 6e2c227..77fa6e1 100644
--- a/src/main/java/de/ids_mannheim/korap/config/Attributes.java
+++ b/src/main/java/de/ids_mannheim/korap/config/Attributes.java
@@ -87,8 +87,8 @@
     public static final String DESCRIPTION = "description";
 
     public static final String CORPUS_SIGLE = "corpusSigle";
-
     public static final String DOC_SIGLE = "docSigle";
+    public static final String TEXT_SIGLE = "textSigle";
 
     public static final String REF_CORPUS = "refCorpus";
     public static final String QUERY = "query";
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanupFilter.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanupFilter.java
deleted file mode 100644
index 3985bd0..0000000
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionCleanupFilter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package de.ids_mannheim.korap.resource.rewrite;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import de.ids_mannheim.korap.config.BeanInjectable;
-import de.ids_mannheim.korap.config.ContextHolder;
-import de.ids_mannheim.korap.config.KustvaktConfiguration;
-import de.ids_mannheim.korap.user.User;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import edu.emory.mathcs.backport.java.util.Arrays;
-
-import java.util.Iterator;
-
-/**
- * @author hanl
- * @date 28/07/2015
- */
-public class CollectionCleanupFilter implements RewriteTask.RewriteNodeAt {
-
-    @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
-            User user) {
-        return process(node.rawNode());
-    }
-
-
-    private JsonNode process (JsonNode root) {
-        JsonNode sub = root;
-        if (root.isObject()) {
-            if (root.has("operands")) {
-                JsonNode node = root.at("/operands");
-                Iterator<JsonNode> it = node.elements();
-                while (it.hasNext()) {
-                    JsonNode n = it.next();
-                    JsonNode s = process(n);
-                    if (s == null)
-                        it.remove();
-                }
-
-                int count = node.size();
-                // remove group element and replace with single doc
-                if (count == 1)
-                    sub = node.path(0);
-                // indicate empty group
-                else if (count == 0) // can't do anything here -- fixme: edge case?!
-                    return null;
-            }
-
-            // what happens to array nodes?
-            if (!root.equals(sub)) {
-                if (sub.isObject()) {
-                    ObjectNode ob = (ObjectNode) root;
-                    ob.remove(Arrays.asList(new String[]{"@type", "operation", "operands"}));
-                    ob.putAll((ObjectNode) sub);
-                    //if (!rewrites.isMissingNode())
-                    //    ob.put("rewrites", rewrites);
-                }
-            }
-        }
-        return root;
-    }
-
-    @Override
-    public JsonNode postProcess (KoralNode node) {
-        return null;
-    }
-
-
-    @Override
-    public String at () {
-        return "/collection";
-    }
-}
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionConstraint.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionConstraint.java
index f725c9a..f005413 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionConstraint.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/CollectionConstraint.java
@@ -17,30 +17,32 @@
 
 
 
-
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         if (node.get("@type").equals("koral:doc")) {
-            if (node.get("key").equals(Attributes.CORPUS_SIGLE)
-                    && !check(node, user))
-                node.removeNode(Attributes.CORPUS_SIGLE);
+            if (node.get("key").equals(Attributes.CORPUS_SIGLE)) {
+                String id = node.get("value");
+                KustvaktResource corpus = check(id, user);
+                if (corpus == null)
+                    node.removeNode(new KoralNode.RewriteIdentifier(
+                            Attributes.CORPUS_SIGLE, id));
+            }
         }
         return node.rawNode();
     }
 
 
     /**
-     * @param node
+     * @param id
      * @param user
      * @return boolean if true access granted
      */
-    private boolean check (KoralNode node, User user) {
+    private KustvaktResource check (String id, User user) {
         // todo: can be used to circumvent access control if public filter not applied
         if (user == null)
-            return true;
+            return null;
 
-        String id = node.get("value");
         KustvaktResource corpus;
         try {
             SecurityManager m = SecurityManager
@@ -48,14 +50,14 @@
             corpus = m.getResource();
         }
         catch (RuntimeException | KustvaktException e) {
-            return false;
+            return null;
         }
-        return corpus != null;
+        return corpus;
     }
 
 
     @Override
-    public JsonNode postProcess (KoralNode node) {
+    public JsonNode rewriteResult (KoralNode node) {
         return null;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
index b3f99f5..fc47c8b 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/DocMatchRewrite.java
@@ -36,24 +36,25 @@
 
 
     @Override
-    public JsonNode postProcess (KoralNode node) throws KustvaktException {
+    public JsonNode rewriteResult (KoralNode node) throws KustvaktException {
         Document doc = null;
         if (this.docDao == null)
             throw new RuntimeException("Document dao must be set!");
 
-        if (node.has(Attributes.DOC_SIGLE)) {
-            String docID = node.get(Attributes.DOC_SIGLE);
-            Element e = this.cache.get(docID);
+        if (node.has(Attributes.TEXT_SIGLE)) {
+            String textSigle = node.get(Attributes.TEXT_SIGLE);
+            Element e = this.cache.get(textSigle);
             if (e == null) {
-                doc = docDao.findbyId(docID, null);
+                doc = docDao.findbyId(textSigle, null);
                 if (doc != null)
-                    this.cache.put(new Element(docID, doc));
+                    this.cache.put(new Element(textSigle, doc));
             }
             else
                 doc = (Document) e.getObjectValue();
 
             if (doc != null && doc.isDisabled())
-                node.removeNode(Attributes.DOC_SIGLE);
+                node.removeNode(new KoralNode.RewriteIdentifier(
+                        Attributes.TEXT_SIGLE, doc.getPersistentID()));
         }
         return node.rawNode();
     }
@@ -66,7 +67,7 @@
 
 
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         return null;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
index 486ae25..9c3762b 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/FoundryInject.java
@@ -30,7 +30,7 @@
 
 
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) throws KustvaktException {
         LayerMapper mapper;
 
@@ -62,7 +62,7 @@
 
 
     @Override
-    public JsonNode postProcess (KoralNode node) {
+    public JsonNode rewriteResult (KoralNode node) {
         return null;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java
index f0b1200..e35fd17 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/IdWriter.java
@@ -14,13 +14,14 @@
 
     private int counter;
 
+
     public IdWriter () {
         this.counter = 0;
     }
 
 
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         if (node.get("@type").equals("koral:token")) {
             String s = extractToken(node.rawNode());
@@ -30,6 +31,7 @@
         return node.rawNode();
     }
 
+
     private String extractToken (JsonNode token) {
         JsonNode wrap = token.path("wrap");
         if (!wrap.isMissingNode())
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
index dbce70e..6de5552 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/KoralNode.java
@@ -29,14 +29,16 @@
     }
 
 
-    public void buildRewrites(JsonNode node) {
+    public void buildRewrites (JsonNode node) {
         this.rewrites.build(node);
     }
 
-    public void buildRewrites() {
+
+    public void buildRewrites () {
         this.rewrites.build(this.node);
     }
 
+
     @Override
     public String toString () {
         return this.node.toString();
@@ -60,7 +62,7 @@
     }
 
 
-    public void remove (Object identifier) {
+    public void remove (Object identifier, RewriteIdentifier ident) {
         boolean set = false;
         if (this.node.isObject() && identifier instanceof String) {
             ObjectNode n = (ObjectNode) this.node;
@@ -72,13 +74,17 @@
             n.remove((Integer) identifier);
             set = true;
         }
+
+        if (ident != null)
+            identifier = ident.toString();
+
         if (set) {
             this.rewrites.add("deletion", identifier);
         }
     }
 
 
-    public void replace (String name, Object value) {
+    public void replace (String name, Object value, RewriteIdentifier ident) {
         if (this.node.isObject() && this.node.has(name)) {
             ObjectNode n = (ObjectNode) this.node;
             if (value instanceof String)
@@ -87,11 +93,16 @@
                 n.put(name, (Integer) value);
             else if (value instanceof JsonNode)
                 n.put(name, (JsonNode) value);
+
+            if (ident != null)
+                name = ident.toString();
+
             this.rewrites.add("override", name);
         }
     }
 
-    public void set (String name, Object value, String attrIdent) {
+
+    public void set (String name, Object value, RewriteIdentifier ident) {
         if (this.node.isObject()) {
             ObjectNode n = (ObjectNode) this.node;
             if (value instanceof String)
@@ -100,10 +111,16 @@
                 n.put(name, (Integer) value);
             else if (value instanceof JsonNode)
                 n.put(name, (JsonNode) value);
-            this.rewrites.add("insertion", attrIdent);
+
+
+            if (ident != null)
+                name = ident.toString();
+
+            this.rewrites.add("insertion", name);
         }
     }
 
+
     public String get (String name) {
         if (this.node.isObject())
             return this.node.path(name).asText();
@@ -131,11 +148,30 @@
     }
 
 
-    public void removeNode (String identifier) {
-        this.rewrites.add("deletion", identifier);
+    public void removeNode (RewriteIdentifier ident) {
+        this.rewrites.add("deletion", ident.toString());
         this.remove = true;
     }
 
+    public static class RewriteIdentifier {
+
+        private String key, value;
+
+
+        public RewriteIdentifier (String key, Object value) {
+            this.key = key;
+            this.value = value.toString();
+        }
+
+
+        @Override
+        public String toString () {
+            return key + "(" + value + ")";
+        }
+
+
+    }
+
 
     public boolean isRemove () {
         return this.remove;
@@ -144,14 +180,15 @@
 
     public static class KoralRewriteBuilder {
 
-       private List<KoralRewrite> rewrites;
+        private List<KoralRewrite> rewrites;
 
-        public KoralRewriteBuilder() {
+
+        public KoralRewriteBuilder () {
             this.rewrites = new ArrayList<>();
         }
 
 
-        public KoralRewriteBuilder add(String op, Object scope) {
+        public KoralRewriteBuilder add (String op, Object scope) {
             KoralRewrite rewrite = new KoralRewrite();
             rewrite.setOperation(op);
             rewrite.setScope(scope.toString());
@@ -169,12 +206,17 @@
                 if (node.has("rewrites")) {
                     ArrayNode n = (ArrayNode) node.path("rewrites");
                     n.add(JsonUtils.valueToTree(rewrite.map));
-                } else {
+                }
+                else if (node.isObject()) {
                     ObjectNode n = (ObjectNode) node;
                     List l = new LinkedList<>();
                     l.add(JsonUtils.valueToTree(rewrite.map));
                     n.put("rewrites", JsonUtils.valueToTree(l));
                 }
+                else {
+                    //fixme: matches in result will land here. rewrites need to be placed under root node - though then there might be unclear where they belong to
+                }
+
             }
             this.rewrites.clear();
             return node;
@@ -184,11 +226,11 @@
 
 
 
-
     private static class KoralRewrite {
 
         private Map<String, String> map;
 
+
         private KoralRewrite () {
             this.map = new LinkedHashMap<>();
             this.map.put("@type", "koral:rewrite");
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java
index 3158af0..522ac45 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/MetaConstraint.java
@@ -13,7 +13,7 @@
 
 
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         // redundant
         if (node.rawNode().has("meta")) {
@@ -26,7 +26,7 @@
 
 
     @Override
-    public JsonNode postProcess (KoralNode node) {
+    public JsonNode rewriteResult (KoralNode node) {
         return null;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
index 114c35a..6bd59a5 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/PublicCollection.java
@@ -11,26 +11,24 @@
 import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.utils.KoralCollectionQueryBuilder;
 import de.ids_mannheim.korap.utils.JsonUtils;
-import org.w3c.dom.Attr;
 
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.HashSet;
 import java.util.Set;
 
 /**
  * @author hanl
  * @date 04/07/2015
  */
-public class PublicCollection implements RewriteTask.RewriteBefore {
+public class PublicCollection implements RewriteTask.RewriteQuery {
 
     public PublicCollection () {
         super();
     }
 
 
-    // todo: where to inject the array node into? --> super group with and relation plus subgroup with ids and or operator
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         JsonNode subnode = node.rawNode();
 
@@ -48,13 +46,18 @@
                     throw new KustvaktException(StatusCodes.PERMISSION_DENIED,
                             "No resources found for user", user.getUsername());
 
+                Set ids = new HashSet(resources.size());
                 for (int i = 0; i < list.size(); i++) {
                     if (i > 0)
                         b.or();
-                    b.with(Attributes.CORPUS_SIGLE+"=" + list.get(i).getPersistentID());
+                    b.with(Attributes.CORPUS_SIGLE + "="
+                            + list.get(i).getPersistentID());
+                    ids.add(list.get(i).getPersistentID());
                 }
                 JsonNode rewritten = JsonUtils.readTree(b.toJSON());
-                node.set("collection", rewritten.at("/collection"), Attributes.CORPUS_SIGLE);
+                node.set("collection", rewritten.at("/collection"),
+                        new KoralNode.RewriteIdentifier(
+                                Attributes.CORPUS_SIGLE, ids));
                 node.at("/collection");
             }
             catch (KustvaktException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
index 8d00d7a..3ede387 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandler.java
@@ -52,7 +52,7 @@
         this.add(PublicCollection.class);
         this.add(IdWriter.class);
         this.add(DocMatchRewrite.class);
-        this.add(CollectionCleanupFilter.class);
+        this.add(CollectionCleanRewrite.class);
     }
 
 
@@ -68,8 +68,8 @@
         else if (rewriter instanceof RewriteTask.IterableRewritePath)
             return this.node_processors
                     .add((RewriteTask.IterableRewritePath) rewriter);
-        else if (rewriter instanceof RewriteTask.RewriteBefore
-                | rewriter instanceof RewriteTask.RewriteAfter)
+        else if (rewriter instanceof RewriteTask.RewriteQuery
+                | rewriter instanceof RewriteTask.RewriteResult)
             return this.query_processors.add(rewriter);
 
         this.failed_task_registration.add(rewriter.getClass());
@@ -115,20 +115,31 @@
 
 
 
-
-    public String process(JsonNode root, User user) {
+    public String processQuery (JsonNode root, User user) {
         RewriteProcess process = new RewriteProcess(root, user);
         JsonNode pre = process.start(false);
-        //return iterate(pre, user, true);
         return JsonUtils.toJSON(pre);
     }
 
 
-    public String process(String json, User user) {
-        return process(JsonUtils.readTree(json), user);
+    public String processQuery (String json, User user) {
+        return processQuery(JsonUtils.readTree(json), user);
     }
 
 
+    public String processResult (String json, User user) {
+        return processResult(JsonUtils.readTree(json), user);
+    }
+
+
+    public String processResult (JsonNode node, User user) {
+        RewriteProcess process = new RewriteProcess(node, user);
+        JsonNode pre = process.start(true);
+        return JsonUtils.toJSON(pre);
+    }
+
+
+
     public void clear () {
         this.node_processors.clear();
         this.query_processors.clear();
@@ -149,12 +160,15 @@
         private JsonNode root;
         private User user;
 
-        private RewriteProcess(JsonNode root, User user) {
+
+        private RewriteProcess (JsonNode root, User user) {
             this.root = root;
             this.user = user;
         }
 
-        private KoralNode processNode (String key, JsonNode value, boolean post) {
+
+        private KoralNode processNode (String key, JsonNode value,
+                boolean result) {
             KoralNode kroot = KoralNode.wrapNode(value);
             if (value.isObject()) {
                 if (value.has("operands")) {
@@ -162,7 +176,7 @@
                     Iterator<JsonNode> it = ops.elements();
                     while (it.hasNext()) {
                         JsonNode next = it.next();
-                        KoralNode kn = processNode(key, next, post);
+                        KoralNode kn = processNode(key, next, result);
                         if (kn.isRemove())
                             it.remove();
                     }
@@ -170,19 +184,19 @@
                 else if (value.path("@type").asText().equals("koral:token")) {
                     // todo: koral:token nodes cannot be flagged for deletion --> creates the possibility for empty koral:token nodes
                     rewrite(key, kroot,
-                            RewriteHandler.this.token_node_processors, post);
-                    return processNode(key, value.path("wrap"), post);
+                            RewriteHandler.this.token_node_processors, result);
+                    return processNode(key, value.path("wrap"), result);
                 }
                 else {
                     return rewrite(key, kroot,
-                            RewriteHandler.this.node_processors, post);
+                            RewriteHandler.this.node_processors, result);
                 }
             }
             else if (value.isArray()) {
                 Iterator<JsonNode> it = value.elements();
                 while (it.hasNext()) {
                     JsonNode next = it.next();
-                    KoralNode kn = processNode(key, next, post);
+                    KoralNode kn = processNode(key, next, result);
                     if (kn.isRemove())
                         it.remove();
                 }
@@ -191,27 +205,30 @@
         }
 
 
-        private JsonNode start(boolean post) {
+        private JsonNode start (boolean result) {
             jlog.debug("Running rewrite process on query {}", root);
             if (root != null) {
                 Iterator<Map.Entry<String, JsonNode>> it = root.fields();
                 while (it.hasNext()) {
                     Map.Entry<String, JsonNode> next = it.next();
-                    processNode(next.getKey(), next.getValue(), post);
+                    processNode(next.getKey(), next.getValue(), result);
                 }
-                processFixedNode(root, RewriteHandler.this.query_processors, post);
+                processFixedNode(root, RewriteHandler.this.query_processors,
+                        result);
             }
             return root;
         }
 
+
         /**
          * @param node
          * @param tasks
-         * @return boolean true if node is to be removed from parent! Only
+         * @return boolean true if node is to be removed from parent!
+         *         Only
          *         applies if parent is an array node
          */
         private KoralNode rewrite (String rootNode, KoralNode node,
-                                   Collection<? extends RewriteTask> tasks, boolean post) {
+                Collection<? extends RewriteTask> tasks, boolean result) {
             if (RewriteHandler.this.config == null)
                 throw new RuntimeException("KustvaktConfiguration must be set!");
 
@@ -219,8 +236,10 @@
                 jlog.debug("running processor on node: " + node);
                 jlog.debug("on processor: " + task.getClass().toString());
 
-                if (RewriteHandler.this.beans != null && task instanceof BeanInjectable)
-                    ((BeanInjectable) task).insertBeans(RewriteHandler.this.beans);
+                if (RewriteHandler.this.beans != null
+                        && task instanceof BeanInjectable)
+                    ((BeanInjectable) task)
+                            .insertBeans(RewriteHandler.this.beans);
 
                 if (task instanceof RewriteTask.IterableRewritePath) {
                     RewriteTask.IterableRewritePath rw = (RewriteTask.IterableRewritePath) task;
@@ -230,31 +249,34 @@
                     }
                 }
                 try {
-                    if (!post && task instanceof RewriteTask.RewriteBefore) {
-                        ((RewriteTask.RewriteBefore) task).preProcess(node,
+                    if (!result && task instanceof RewriteTask.RewriteQuery) {
+                        ((RewriteTask.RewriteQuery) task).rewriteQuery(node,
                                 RewriteHandler.this.config, this.user);
                     }
-                    else if (task instanceof RewriteTask.RewriteAfter) {
-                        ((RewriteTask.RewriteAfter) task).postProcess(node);
+                    else if (task instanceof RewriteTask.RewriteResult) {
+                        ((RewriteTask.RewriteResult) task).rewriteResult(node);
                     }
                 }
                 catch (KustvaktException e) {
-                    jlog.error("Error in rewrite processor {} for node {}", task
-                            .getClass().getSimpleName(), node.rawNode().toString());
+                    jlog.error("Error in rewrite processor {} for node {}",
+                            task.getClass().getSimpleName(), node.rawNode()
+                                    .toString());
                     e.printStackTrace();
                 }
                 if (node.isRemove()) {
-                    node.buildRewrites(this.root.at("/"+ rootNode));
+                    node.buildRewrites(this.root.at("/" + rootNode));
                     break;
-                } else
+                }
+                else
                     node.buildRewrites();
             }
             return node;
         }
 
+
         // fixme: merge with processNode!
         private void processFixedNode (JsonNode node,
-                                       Collection<RewriteTask> tasks, boolean post) {
+                Collection<RewriteTask> tasks, boolean post) {
             for (RewriteTask task : tasks) {
                 KoralNode next = KoralNode.wrapNode(node);
                 if (task instanceof RewriteTask.RewriteNodeAt) {
@@ -264,16 +286,16 @@
                 }
 
                 try {
-                    if (!post & task instanceof RewriteTask.RewriteBefore)
-                        ((RewriteTask.RewriteBefore) task).preProcess(next,
+                    if (!post & task instanceof RewriteTask.RewriteQuery)
+                        ((RewriteTask.RewriteQuery) task).rewriteQuery(next,
                                 RewriteHandler.this.config, user);
-                    else if (task instanceof RewriteTask.RewriteAfter)
-                        ((RewriteTask.RewriteAfter) task).postProcess(next);
+                    else if (task instanceof RewriteTask.RewriteResult)
+                        ((RewriteTask.RewriteResult) task).rewriteResult(next);
                     next.buildRewrites();
                 }
                 catch (KustvaktException e) {
-                    jlog.error("Error in rewrite processor {} for node {}", task
-                            .getClass().getSimpleName(), next.toString());
+                    jlog.error("Error in rewrite processor {} for node {}",
+                            task.getClass().getSimpleName(), next.toString());
                     e.printStackTrace();
                 }
             }
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java
index fcc43aa..9eab6ca 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/RewriteTask.java
@@ -13,9 +13,10 @@
 
 
     /**
-     * unspecified query rewrite that gets injected the entire root node during preprocessing
+     * unspecified query rewrite that gets injected the entire root
+     * node during preprocessing
      */
-    interface RewriteBefore extends RewriteTask {
+    interface RewriteQuery extends RewriteTask {
         /**
          * @param node
          *            Json node in KoralNode wrapper
@@ -28,21 +29,18 @@
          *            checked properly
          * @return
          */
-        JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+        JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
                 User user) throws KustvaktException;
 
     }
 
     /**
      * Post processor targeted at result sets for queries
-     * {@link de.ids_mannheim.korap.resource.rewrite.RewriteTask.RewriteAfter}
-     * queries will run
-     * after
-     * {@link IterableRewritePath}
-     * have been processed
+     * {@link RewriteResult} queries will run
+     * after {@link IterableRewritePath} have been processed
      */
-    interface RewriteAfter extends RewriteTask {
-        JsonNode postProcess (KoralNode node) throws KustvaktException;
+    interface RewriteResult extends RewriteTask {
+        JsonNode rewriteResult (KoralNode node) throws KustvaktException;
     }
 
     /**
@@ -52,7 +50,7 @@
      * Deletion via KoralNode not allowed. Supports pre- and
      * post-processing
      */
-    interface RewriteNodeAt extends RewriteBefore, RewriteAfter {
+    interface RewriteNodeAt extends RewriteQuery, RewriteResult {
         String at ();
     }
 
@@ -61,7 +59,7 @@
      * iteration
      * (both object and array node iteration supported)
      */
-    interface IterableRewritePath extends RewriteBefore, RewriteAfter {
+    interface IterableRewritePath extends RewriteQuery, RewriteResult {
         String path ();
     }
 
@@ -72,6 +70,6 @@
      * rewrites {@link RewriteKoralToken} rewrite DOES NOT support the
      * deletion of the respective node
      */
-    interface RewriteKoralToken extends RewriteBefore {}
+    interface RewriteKoralToken extends RewriteQuery {}
 
 }
diff --git a/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java b/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java
index e4f134a..5713570 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/rewrite/TreeConstraint.java
@@ -60,7 +60,7 @@
 
 
     @Override
-    public JsonNode preProcess (KoralNode node, KustvaktConfiguration config,
+    public JsonNode rewriteQuery (KoralNode node, KustvaktConfiguration config,
             User user) {
         System.out.println("FIND PATH " + node.rawNode().findParent(pointer));
 
@@ -69,7 +69,7 @@
 
 
     @Override
-    public JsonNode postProcess (KoralNode node) {
+    public JsonNode rewriteResult (KoralNode node) {
         return null;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resources/Document.java b/src/main/java/de/ids_mannheim/korap/resources/Document.java
index 9f86444..c603011 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/Document.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/Document.java
@@ -7,6 +7,7 @@
  * @author hanl
  * @date 05/11/2014
  */
+// todo: distinguish between document and text!
 @Getter
 @Setter
 public class Document extends KustvaktResource {
@@ -37,6 +38,11 @@
     }
 
 
+    public boolean isText () {
+        return this.getPersistentID().contains(".");
+    }
+
+
     @Override
     public String toString () {
         return "Document{" + "id='" + this.getId() + "'" + "persistentid='"
diff --git a/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java b/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
index 532e8f3..7bbb43f 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/KustvaktResource.java
@@ -104,7 +104,8 @@
         return JsonUtils.valueToTree(this.fields);
     }
 
-    public String getStringData() {
+
+    public String getStringData () {
         return JsonUtils.toJSON(this.fields);
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java b/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
index c6de012..7890b4a 100644
--- a/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
+++ b/src/main/java/de/ids_mannheim/korap/resources/ResourceFactory.java
@@ -64,7 +64,8 @@
 
     public static <T extends KustvaktResource> T createID (T resource) {
         if (resource.getData() != null && !resource.getStringData().isEmpty())
-            resource.setPersistentID(DigestUtils.sha1Hex(resource.getStringData()));
+            resource.setPersistentID(DigestUtils.sha1Hex(resource
+                    .getStringData()));
         return resource;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
index 00a6e17..5c98f8f 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/KustvaktAuthenticationManager.java
@@ -757,7 +757,8 @@
 
             if (data == null)
                 throw new KustvaktException(user.getId(),
-                        StatusCodes.EMPTY_RESULTS, "No data found!", clazz.getSimpleName());
+                        StatusCodes.EMPTY_RESULTS, "No data found!",
+                        clazz.getSimpleName());
             return data;
         }
         catch (KustvaktException e) {
@@ -785,6 +786,7 @@
         }
     }
 
+
     private String cache_key (String input) throws KustvaktException {
         try {
             return crypto.hash(KEY + "@" + input);
diff --git a/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java b/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
index 4d6b6f1..86ac337 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/KoralCollectionQueryBuilder.java
@@ -26,12 +26,12 @@
     private String mergeOperator;
 
 
-    public KoralCollectionQueryBuilder() {
+    public KoralCollectionQueryBuilder () {
         this(false);
     }
 
 
-    public KoralCollectionQueryBuilder(boolean verbose) {
+    public KoralCollectionQueryBuilder (boolean verbose) {
         this.verbose = verbose;
         this.builder = new StringBuilder();
         this.base = null;
@@ -49,7 +49,7 @@
      * @return
      */
     public KoralCollectionQueryBuilder fieldValue (String field, String op,
-                                                   String value) {
+            String value) {
         this.builder.append(field + op + value);
         return this;
     }
@@ -65,7 +65,7 @@
      *            element
      * @return
      */
-    public KoralCollectionQueryBuilder with(String query) {
+    public KoralCollectionQueryBuilder with (String query) {
         if (!query.startsWith("(") && !query.endsWith(")"))
             query = "(" + query + ")";
         this.builder.append(query);
@@ -74,8 +74,6 @@
 
 
 
-
-
     public KoralCollectionQueryBuilder and () {
         if (this.builder.length() != 0)
             this.builder.append(" & ");
@@ -112,17 +110,20 @@
             if (request != null) {
                 JsonNode tobase = request.at("/collection");
                 request = tmp;
-                JsonNode result = JsonBuilder.buildDocGroup(this.mergeOperator != null
-                        ? this.mergeOperator.toLowerCase() : "and",
-                        request.at("/collection"), tobase);
+                JsonNode result = JsonBuilder.buildDocGroup(
+                        this.mergeOperator != null ? this.mergeOperator
+                                .toLowerCase() : "and", request
+                                .at("/collection"), tobase);
                 ((ObjectNode) request).put("collection", result);
-            } else
+            }
+            else
                 request = tmp;
         }
         return request;
     }
 
-    public JsonNode mergeWith(JsonNode node) {
+
+    public JsonNode mergeWith (JsonNode node) {
         if (this.base != null) {
             // check that collection non empty
             if (node != null) {
@@ -150,6 +151,8 @@
         this.base = JsonUtils.readTree(query);
         return this;
     }
+
+
     public KoralCollectionQueryBuilder setBaseQuery (JsonNode query) {
         this.base = query;
         return this;
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
index 8ff8f3c..9b04a14 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/ResourceService.java
@@ -312,7 +312,7 @@
 
         ss.setMeta(meta);
 
-        String query = this.processor.process(ss.toJSON(), user);
+        String query = this.processor.processQuery(ss.toJSON(), user);
         return Response.ok(query).build();
     }
 
@@ -385,7 +385,8 @@
             if (resource instanceof VirtualCollection)
                 cquery.mergeWith(resource.getData());
             else if (resource instanceof Corpus)
-                cquery.with(Attributes.CORPUS_SIGLE + resource.getPersistentID());
+                cquery.with(Attributes.CORPUS_SIGLE
+                        + resource.getPersistentID());
 
         }
         catch (KustvaktException e) {
@@ -409,7 +410,7 @@
         // todo: should be possible to add the meta part to the query serialization
         try {
             User user = controller.getUser(ctx.getUsername());
-            jsonld = this.processor.process(jsonld, user);
+            jsonld = this.processor.processQuery(jsonld, user);
         }
         catch (KustvaktException e) {
             throw KustvaktResponseHandler.throwit(e);
@@ -468,7 +469,7 @@
         serializer.setMeta(meta.raw());
 
         //fixme: policy rewrite!
-        String query = this.processor.process(serializer.toJSON(), user);
+        String query = this.processor.processQuery(serializer.toJSON(), user);
 
         jlog.info("the serialized query {}", query);
 
@@ -551,7 +552,8 @@
                 if (resource instanceof VirtualCollection)
                     builder.setBaseQuery(resource.getData());
                 else if (resource instanceof Corpus)
-                    builder.with(Attributes.CORPUS_SIGLE+ resource.getPersistentID());
+                    builder.with(Attributes.CORPUS_SIGLE
+                            + resource.getPersistentID());
                 else
                     throw KustvaktResponseHandler.throwit(
                             StatusCodes.ILLEGAL_ARGUMENT,
@@ -577,7 +579,7 @@
             try {
 
                 // rewrite process
-                query = this.processor.process(query, user);
+                query = this.processor.processQuery(query, user);
 
                 if (eng.equals(KustvaktConfiguration.BACKENDS.NEO4J)) {
                     if (raw)
@@ -669,10 +671,10 @@
                 query.setBaseQuery(resource.getData());
             }
             else if (resource instanceof Corpus) {
-                query.with(Attributes.CORPUS_SIGLE+"=" + resource.getName());
+                query.with(Attributes.CORPUS_SIGLE + "=" + resource.getName());
             }
             String res = query.toJSON();
-            String qstr = processor.process(res, user);
+            String qstr = processor.processQuery(res, user);
             return Response.ok(searchKrill.getStatistics(qstr)).build();
         }
         catch (KustvaktException e) {
@@ -705,8 +707,7 @@
         VirtualCollection tmp = resourceHandler.getCache(cache.getId(),
                 VirtualCollection.class);
         if (tmp == null) {
-            String query = this.processor.process(cache.getData(),
-                    user);
+            String query = this.processor.processQuery(cache.getData(), user);
             String stats = searchKrill.getStatistics(query);
             cache.setStats(JsonUtils.readSimple(stats, Map.class));
             resourceHandler.cache(cache);
@@ -787,8 +788,8 @@
             JsonNode base;
             if (reference != null && !reference.equals("null")) {
                 try {
-                    base = resourceHandler.findbyStrId(reference,
-                            user, VirtualCollection.class).getData();
+                    base = resourceHandler.findbyStrId(reference, user,
+                            VirtualCollection.class).getData();
                 }
                 catch (KustvaktException e) {
                     throw KustvaktResponseHandler.throwit(e);
@@ -877,8 +878,8 @@
             KoralCollectionQueryBuilder cquery = new KoralCollectionQueryBuilder();
             if (reference != null && !reference.equals("null")) {
                 try {
-                    cquery.setBaseQuery(resourceHandler.findbyStrId(
-                            reference, user, VirtualCollection.class).getData());
+                    cquery.setBaseQuery(resourceHandler.findbyStrId(reference,
+                            user, VirtualCollection.class).getData());
 
                 }
                 catch (KustvaktException e) {
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java b/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
index d07b912..b55cb45 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/light/LightService.java
@@ -88,8 +88,7 @@
             @QueryParam("cutoff") Boolean cutoff,
             @QueryParam("count") Integer pageLength,
             @QueryParam("offset") Integer pageIndex,
-            @QueryParam("page") Integer startPage,
-            @QueryParam("cq") String cq) {
+            @QueryParam("page") Integer startPage, @QueryParam("cq") String cq) {
         QuerySerializer ss = new QuerySerializer().setQuery(q, ql, v);
 
         MetaQueryBuilder meta = new MetaQueryBuilder();
@@ -102,14 +101,14 @@
         ss.setMeta(meta);
         if (cq != null)
             ss.setCollection(cq);
-        return Response.ok(processor.process(ss.toJSON(), null)).build();
+        return Response.ok(processor.processQuery(ss.toJSON(), null)).build();
     }
 
 
     @POST
     @Path("search")
     public Response queryRaw (@QueryParam("engine") String engine, String jsonld) {
-        jsonld = processor.process(jsonld, null);
+        jsonld = processor.processQuery(jsonld, null);
         // todo: should be possible to add the meta part to the query serialization
         jlog.info("Serialized search: {}", jsonld);
 
@@ -143,7 +142,7 @@
         if (cq != null)
             serializer.setCollection(cq);
 
-        String query = processor.process(serializer.toJSON(), null);
+        String query = processor.processQuery(serializer.toJSON(), null);
         jlog.info("the serialized query {}", query);
 
         // This may not work with the the KoralQuery
@@ -214,7 +213,7 @@
             //                meta.addEntry("itemsPerResource", 1);
             QuerySerializer s = new QuerySerializer().setQuery(query, ql, v)
                     .setMeta(meta);
-            query = processor.process(s.toJSON(), null);
+            query = processor.processQuery(s.toJSON(), null);
         }
         String result;
         try {
diff --git a/src/test/java/CollectionQueryBuilderTest.java b/src/test/java/CollectionQueryBuilderTest.java
index 407608d..f895962 100644
--- a/src/test/java/CollectionQueryBuilderTest.java
+++ b/src/test/java/CollectionQueryBuilderTest.java
@@ -38,7 +38,8 @@
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
         assertEquals("operation:and", node.at("/collection/operation").asText());
 
-        assertEquals("corpusSigle", node.at("/collection/operands/0/key").asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/0/key")
+                .asText());
         assertEquals("textClass", node.at("/collection/operands/1/key")
                 .asText());
     }
@@ -92,11 +93,14 @@
                 .asText());
         assertEquals(2, node.at("/collection/operands").size());
         assertEquals(2, node.at("/collection/operands/0/operands").size());
-        assertEquals(2, node.at("/collection/operands/0/operands/0/operands").size());
+        assertEquals(2, node.at("/collection/operands/0/operands/0/operands")
+                .size());
 
         assertEquals("operation:and", node.at("/collection/operation").asText());
-        assertEquals("operation:or", node.at("/collection/operands/0/operation").asText());
-        assertEquals("operation:and", node.at("/collection/operands/0/operands/0/operation").asText());
+        assertEquals("operation:or", node
+                .at("/collection/operands/0/operation").asText());
+        assertEquals("operation:and",
+                node.at("/collection/operands/0/operands/0/operation").asText());
         assertEquals("WPD", node.at("/collection/operands/1/value").asText());
     }
 
@@ -152,7 +156,8 @@
         assertEquals("koral:doc", res.at("/collection/operands/1/@type")
                 .asText());
         assertEquals("WPD", res.at("/collection/operands/0/value").asText());
-        assertEquals("corpusSigle", res.at("/collection/operands/0/key").asText());
+        assertEquals("corpusSigle", res.at("/collection/operands/0/key")
+                .asText());
 
         // check also that query is still there
         assertEquals("koral:token", res.at("/query/@type").asText());
@@ -182,8 +187,9 @@
         assertEquals(base.at("/collection/operands/0/operands").size(), 2);
     }
 
+
     @Test
-    public void testNodeMergeWithBase() {
+    public void testNodeMergeWithBase () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -209,8 +215,9 @@
 
     }
 
+
     @Test
-    public void testAddOROperator() {
+    public void testAddOROperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -227,8 +234,9 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
-    public void testAddANDOperator() {
+    public void testAddANDOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -245,8 +253,9 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
-    public void testAddDefaultOperator() {
+    public void testAddDefaultOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
@@ -263,9 +272,10 @@
         assertEquals(2, node.at("/collection/operands/1/operands").size());
     }
 
+
     @Test
     @Ignore
-    public void testMergeOperator() {
+    public void testMergeOperator () {
         String coll = "corpusSigle=WPD";
         String query = "[base=Haus]";
         QuerySerializer check = new QuerySerializer();
diff --git a/src/test/java/KoralNodeTest.java b/src/test/java/KoralNodeTest.java
index d8f5ab1..6418ee1 100644
--- a/src/test/java/KoralNodeTest.java
+++ b/src/test/java/KoralNodeTest.java
@@ -7,6 +7,7 @@
  * @author hanl
  * @date 21/10/2015
  */
+// todo: complete tests
 public class KoralNodeTest {
 
     // todo: 21.10.15 --> e.g. injection does not tell you if an entire node was injected, or just a value!
@@ -25,7 +26,7 @@
         ObjectNode node = JsonUtils.createObjectNode();
         node.put("value_1", "setting_1");
         KoralNode knode = KoralNode.wrapNode(node);
-        knode.remove("value_1");
+        knode.remove("value_1", null);
         System.out.println(knode.rawNode().toString());
     }
 
@@ -35,7 +36,7 @@
         ObjectNode node = JsonUtils.createObjectNode();
         node.put("value_1", "setting_1");
         KoralNode knode = KoralNode.wrapNode(node);
-        knode.replace("value_1", "settings_2");
+        knode.replace("value_1", "settings_2", null);
         System.out.println(knode.rawNode().toString());
     }
 
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
index d655713..8e67a30 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/CollectionRewriteTest.java
@@ -5,13 +5,10 @@
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
-import de.ids_mannheim.korap.resources.Corpus;
-import de.ids_mannheim.korap.security.ac.ResourceFinder;
 import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.utils.JsonUtils;
 import org.junit.Test;
 
-import java.util.Set;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -58,14 +55,15 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("textClass=politik & corpusSigle=WPD");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals(1, node.at("/collection/operands").size());
     }
 
+
     @Test
-    public void testCollectionNodeDeletionNotification() {
+    public void testCollectionNodeDeletionNotification () {
 
     }
 
@@ -80,13 +78,15 @@
         s.setCollection("corpusSigle=BRZ13 & corpusSigle=WPD");
         String result = s.toJSON();
         try {
-            JsonNode node = JsonUtils.readTree(handler.process(result,
+            JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                     User.UserFactory.getUser("test_user")));
             System.out.println(node);
             assertNotNull(node);
             assertEquals(0, node.at("/collection/operands").size());
-            assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
-        } catch ( Exception e) {
+            assertEquals("koral:rewrite",
+                    node.at("/collection/rewrites/0/@type").asText());
+        }
+        catch (Exception e) {
             e.printStackTrace();
         }
     }
@@ -101,7 +101,7 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & textClass=Wissenschaft) & corpusSigle=WPD");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
         assertNotNull(node);
@@ -109,7 +109,8 @@
                 .asText());
         assertEquals("textClass",
                 node.at("/collection/operands/0/operands/0/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -119,13 +120,13 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & corpusSigle=WPD) & textClass=Wissenschaft & textClass=Sport");
         String result = s.toJSON();
 
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
 
@@ -137,7 +138,8 @@
                 .asText());
         assertEquals("textClass", node.at("/collection/operands/1/key")
                 .asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -146,18 +148,19 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & textClass=wissenschaft)");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:doc", node.at("/collection/@type").asText());
         assertEquals("textClass", node.at("/collection/key").asText());
         assertEquals("wissenschaft", node.at("/collection/value").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -166,18 +169,19 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ13 & corpusSigle=WPD) & textClass=Wissenschaft");
         String result = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(result,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(result,
                 User.UserFactory.getUser("test_user")));
 
         assertNotNull(node);
         assertEquals("koral:doc", node.at("/collection/@type").asText());
         assertEquals("textClass", node.at("/collection/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -186,12 +190,12 @@
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(docID=random & textClass=Wissenschaft) & corpusSigle=WPD");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         System.out.println(node);
         assertNotNull(node);
@@ -201,7 +205,8 @@
                 .asText());
         assertEquals("koral:doc", node.at("/collection/operands/1/@type")
                 .asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
@@ -214,12 +219,16 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
-        assertEquals("corpusSigle", node.at("/collection/operands/0/key").asText());
-        assertEquals("corpusSigle", node.at("/collection/operands/1/key").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/0/key")
+                .asText());
+        assertEquals("corpusSigle", node.at("/collection/operands/1/key")
+                .asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
+        System.out.println("NODE " + node);
     }
 
 
@@ -230,22 +239,25 @@
         handler.insertBeans(helper().getContext());
         handler.add(PublicCollection.class);
 
-            QuerySerializer s = new QuerySerializer();
-            s.setQuery(simple_add_query, "poliqarp");
-            s.setCollection("(docSigle=WPD_AAA & textClass=wissenschaft)");
-            String org = s.toJSON();
-            JsonNode node = JsonUtils.readTree(handler.process(org,
-                    User.UserFactory.getUser("test_user")));
-            assertNotNull(node);
-            assertEquals(2, node.at("/collection/operands").size());
-            assertEquals("corpusSigle", node.at("/collection/operands/1/operands/0/key").asText());
-            assertEquals("corpusSigle", node.at("/collection/operands/1/operands/1/key").asText());
-            assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery(simple_add_query, "poliqarp");
+        s.setCollection("(docSigle=WPD_AAA & textClass=wissenschaft)");
+        String org = s.toJSON();
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
+                User.UserFactory.getUser("test_user")));
+        assertNotNull(node);
+        assertEquals(2, node.at("/collection/operands").size());
+        assertEquals("corpusSigle",
+                node.at("/collection/operands/1/operands/0/key").asText());
+        assertEquals("corpusSigle",
+                node.at("/collection/operands/1/operands/1/key").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
     @Test
-    public void testRemoveCorpusFromDifferentGroups() {
+    public void testRemoveCorpusFromDifferentGroups () {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
@@ -253,7 +265,7 @@
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ14 & textClass=wissenschaft) | (corpusSigle=AZPR | textClass=freizeit)");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
@@ -264,34 +276,43 @@
                 .asText());
         assertEquals(1, node.at("/collection/operands/0/operands").size());
         assertEquals(1, node.at("/collection/operands/1/operands").size());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
+
     @Test
-    public void testRemoveOneCorpusAndMoveDocFromTwoGroups() {
+    public void testRemoveOneCorpusAndMoveDocFromTwoGroups () {
         RewriteHandler handler = new RewriteHandler();
         handler.insertBeans(helper().getContext());
         handler.add(CollectionConstraint.class);
         // todo: use this collection query also to test clean up filter! after reduction of corpusSigle (wiss | freizeit)!
-        handler.add(CollectionCleanupFilter.class);
+        handler.add(CollectionCleanRewrite.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery(simple_add_query, "poliqarp");
         s.setCollection("(corpusSigle=BRZ14 & textClass=wissenschaft) | (corpusSigle=AZPR | textClass=freizeit)");
         String org = s.toJSON();
-        JsonNode node = JsonUtils.readTree(handler.process(org,
+        JsonNode node = JsonUtils.readTree(handler.processQuery(org,
                 User.UserFactory.getUser("test_user")));
         assertNotNull(node);
         assertEquals("koral:docGroup", node.at("/collection/@type").asText());
         assertEquals(2, node.at("/collection/operands").size());
         assertEquals("koral:doc", node.at("/collection/operands/0/@type")
                 .asText());
-        assertEquals("koral:doc", node.at("/collection/operands/0/@type").asText());
-        assertEquals("textClass", node.at("/collection/operands/0/key").asText());
-        assertEquals("wissenschaft", node.at("/collection/operands/0/value").asText());
-        assertEquals("koral:doc", node.at("/collection/operands/1/@type").asText());
-        assertEquals("textClass", node.at("/collection/operands/1/key").asText());
-        assertEquals("freizeit", node.at("/collection/operands/1/value").asText());
-        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type").asText());
+        assertEquals("koral:doc", node.at("/collection/operands/0/@type")
+                .asText());
+        assertEquals("textClass", node.at("/collection/operands/0/key")
+                .asText());
+        assertEquals("wissenschaft", node.at("/collection/operands/0/value")
+                .asText());
+        assertEquals("koral:doc", node.at("/collection/operands/1/@type")
+                .asText());
+        assertEquals("textClass", node.at("/collection/operands/1/key")
+                .asText());
+        assertEquals("freizeit", node.at("/collection/operands/1/value")
+                .asText());
+        assertEquals("koral:rewrite", node.at("/collection/rewrites/0/@type")
+                .asText());
     }
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
index 90bcc86..8c0f1f0 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/FoundryRewriteTest.java
@@ -63,7 +63,7 @@
         processor.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = processor.process(s.toJSON(), null);
+        String result = processor.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
         assertNotNull(node);
         assertFalse(node.at("/query/wrap/foundry").isMissingNode());
@@ -87,7 +87,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[pos=ADJA]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
@@ -112,7 +112,7 @@
         handler.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[pos=ADJA]", "poliqarp");
-        String result = handler.process(s.toJSON(), user);
+        String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
         UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
@@ -142,7 +142,7 @@
         handler.add(FoundryInject.class);
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = handler.process(s.toJSON(), user);
+        String result = handler.processQuery(s.toJSON(), user);
         JsonNode node = JsonUtils.readTree(result);
 
         UserDataDbIface dao = BeansFactory.getTypeFactory().getTypedBean(
@@ -170,7 +170,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[orth=laufe/i & base!=Lauf]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
@@ -189,7 +189,7 @@
         handler.insertBeans(helper().getContext());
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
 
         assertNotNull(node);
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
index 909f9c9..69e8ea7 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/IdRewriteTest.java
@@ -25,7 +25,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery(query, "poliqarp");
 
-        String value = handler.process(s.toJSON(), null);
+        String value = handler.processQuery(s.toJSON(), null);
         JsonNode result = JsonUtils.readTree(value);
 
         assertNotNull(result);
@@ -41,7 +41,7 @@
 
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[base=Haus]", "poliqarp");
-        String result = handler.process(s.toJSON(), null);
+        String result = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(result);
         assertNotNull(node);
         assertFalse(node.at("/query/wrap").isMissingNode());
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java
deleted file mode 100644
index ef0c10a..0000000
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/PostRewriteTest.java
+++ /dev/null
@@ -1,518 +0,0 @@
-package de.ids_mannheim.korap.resource.rewrite;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import de.ids_mannheim.korap.config.BeanConfigTest;
-import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.DocumentDao;
-import de.ids_mannheim.korap.resources.Document;
-import de.ids_mannheim.korap.utils.JsonUtils;
-import net.sf.ehcache.CacheManager;
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-/**
- * @author hanl
- * @date 12/11/2015
- */
-// todo: logging!
-public class PostRewriteTest extends BeanConfigTest {
-
-    @Override
-    public void initMethod () throws KustvaktException {
-
-    }
-
-
-    // otherwise cache will maintain values not relevant for other tests
-    @Before
-    public void before () {
-        CacheManager.getInstance().getCache("documents").removeAll();
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-        dao.truncate();
-    }
-
-
-    @Test
-    public void testPostRewriteNothingToDo () throws KustvaktException {
-        RewriteHandler ha = new RewriteHandler();
-        ha.insertBeans(helper().getContext());
-        assertEquals("Handler could not be added to rewriter instance!", true,
-                ha.add(DocMatchRewrite.class));
-
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-        try {
-            Document d = dao.findbyId("BRZ13_APR.00014", null);
-            assertNull(d);
-            String v = ha.process(RESULT, null);
-            assertEquals("results do not match", JsonUtils.readTree(RESULT),
-                    JsonUtils.readTree(v));
-        }
-        catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-
-    @Test
-    public void testPostRewriteRemoveDoc () {
-        DocumentDao dao = new DocumentDao(helper().getContext()
-                .getPersistenceClient());
-
-        Document doc = new Document("BRZ13_APR.00014");
-        doc.setDisabled(true);
-        try {
-            dao.storeResource(doc, null);
-        }
-        catch (KustvaktException e) {
-            return;
-        }
-
-        RewriteHandler ha = new RewriteHandler();
-        ha.insertBeans(helper().getContext());
-        assertEquals("Handler could not be added to rewriter instance!", true,
-                ha.add(DocMatchRewrite.class));
-
-        String v = ha.process(RESULT, null);
-
-        JsonNode node = JsonUtils.readTree(v);
-
-        assertNotEquals("Wrong DocID", "BRZ13_APR.00014",
-                node.at("/matches/1/docID"));
-
-        try {
-            dao.deleteResource(doc.getPersistentID(), null);
-            Document d = dao.findbyId(doc.getPersistentID(), null);
-            if (d != null)
-                System.out.println("IS SUPPOSED TO BE NULL! " + d);
-        }
-        catch (KustvaktException e) {
-            e.printStackTrace();
-            return;
-        }
-
-    }
-
-
-    @Test
-    public void testPath () {
-        String v = "{\n" + "    \"meta\": {\n" + "        \"count\": 25,\n"
-                + "        \"startIndex\": 0,\n"
-                + "        \"timeout\": 120000,\n" + "        \"context\": {\n"
-                + "            \"left\": [\n" + "                \"token\",\n"
-                + "                6\n" + "            ],\n"
-                + "            \"right\": [\n" + "                \"token\",\n"
-                + "                6\n" + "            ]\n" + "        }}}";
-        JsonNode n = JsonUtils.readTree(v);
-
-    }
-
-    private static final String RESULT = "{\n"
-            + "    \"meta\": {\n"
-            + "        \"count\": 25,\n"
-            + "        \"startIndex\": 0,\n"
-            + "        \"timeout\": 120000,\n"
-            + "        \"context\": {\n"
-            + "            \"left\": [\n"
-            + "                \"token\",\n"
-            + "                6\n"
-            + "            ],\n"
-            + "            \"right\": [\n"
-            + "                \"token\",\n"
-            + "                6\n"
-            + "            ]\n"
-            + "        },\n"
-            + "        \"fields\": [\n"
-            + "            \"textSigle\",\n"
-            + "            \"author\",\n"
-            + "            \"docSigle\",\n"
-            + "            \"title\",\n"
-            + "            \"pubDate\",\n"
-            + "            \"UID\",\n"
-            + "            \"corpusID\",\n"
-            + "            \"textClass\",\n"
-            + "            \"subTitle\",\n"
-            + "            \"layerInfos\",\n"
-            + "            \"ID\",\n"
-            + "            \"pubPlace\",\n"
-            + "            \"corpusSigle\"\n"
-            + "        ],\n"
-            + "        \"version\": \"unknown\",\n"
-            + "        \"benchmark\": \"0.204314141 s\",\n"
-            + "        \"totalResults\": 1755,\n"
-            + "        \"serialQuery\": \"tokens:tt/l:Wort\",\n"
-            + "        \"itemsPerPage\": 25\n"
-            + "    },\n"
-            + "    \"query\": {\n"
-            + "        \"@type\": \"koral:token\",\n"
-            + "        \"wrap\": {\n"
-            + "            \"@type\": \"koral:term\",\n"
-            + "            \"key\": \"Wort\",\n"
-            + "            \"layer\": \"lemma\",\n"
-            + "            \"match\": \"match:eq\",\n"
-            + "            \"foundry\": \"tt\",\n"
-            + "            \"rewrites\": [\n"
-            + "                {\n"
-            + "                    \"@type\": \"koral:rewrite\",\n"
-            + "                    \"src\": \"Kustvakt\",\n"
-            + "                    \"operation\": \"operation:injection\"\n"
-            + "                }\n"
-            + "            ]\n"
-            + "        }\n"
-            + "    },\n"
-            + "    \"matches\": [\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft familie-geschlecht\",\n"
-            + "            \"title\": \"Sexueller Missbrauch –„Das schreiende Kind steckt noch tief in mir“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>in ihrer Stimme schwingt bei diesem </span><mark>Wort</mark><span class=\\\"context-right\\\"> Sarkasmus mit. Bis man einen passenden<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00001-p454-455\",\n"
-            + "            \"docID\": \"BRZ13_APR.00001\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Leben dick und prall\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>der DLRG, ausgelassene Partys und markige </span><mark>Worte</mark><span class=\\\"context-right\\\"> des Dompredigers: „Ostern ist kein goethischer<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00014-p96-97\",\n"
-            + "            \"docID\": \"BRZ13_APR.00014\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft biographien-interviews kultur musik\",\n"
-            + "            \"title\": \"So wird es gemacht:\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>derfehlende Buchstabe.Gelingt es dir,das </span><mark>Wort</mark><span class=\\\"context-right\\\"> vervollständigen? Tipp: Probiere auch mal rückwärts<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00055-p19-20\",\n"
-            + "            \"docID\": \"BRZ13_APR.00055\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik ausland\",\n"
-            + "            \"title\": \"Südkorea droht mit Angriffen – USA rüsten auf\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>der Stunde. „Aus einem Krieg der </span><mark>Worte</mark><span class=\\\"context-right\\\"> darf kein echter Krieg werden“, sagte<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00076-p238-239\",\n"
-            + "            \"docID\": \"BRZ13_APR.00076\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Dauercamper kämpfen für ihren Platz\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>„Initiative Campingplatz Räbke“. „Als ich das </span><mark>Wort</mark><span class=\\\"context-right\\\"> Schließung gelesen habe, war ich richtig<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00200-p255-256\",\n"
-            + "            \"docID\": \"BRZ13_APR.00200\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Neue Aktionen lockten Besucher\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Jan Waldheim (CWG) unter den aufmunternden </span><mark>Worten</mark><span class=\\\"context-right\\\"> eines augenzwinkernden Axel Schnalke („Ein bisschen<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00210-p142-143\",\n"
-            + "            \"docID\": \"BRZ13_APR.00210\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>trotzdem nicht. Selten wurden so viele </span><mark>Worte</mark><span class=\\\"context-right\\\">, die der Autor hier lieber verschweigt<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p166-167\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>zudem nicht immer nur bei den </span><mark>Worten</mark><span class=\\\"context-right\\\"> geblieben) und dabei gleichzeitig soviel Charme<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p191-192\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"kultur musik\",\n"
-            + "            \"title\": \"Travestie – Helden in Strumpfhosen\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>bedeutet Travestie sich zu verkleiden, das </span><mark>Wort</mark><span class=\\\"context-right\\\"> stammt aus dem Französischen. Traditionell belegten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00253-p371-372\",\n"
-            + "            \"docID\": \"BRZ13_APR.00253\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"VfL kommt nicht vom Fleck\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>am internationalen Geschäft berechtigt. Mit anderen </span><mark>Worten</mark><span class=\\\"context-right\\\">: Die „Wölfe“ stecken im grauen Mittelmaß<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00260-p93-94\",\n"
-            + "            \"docID\": \"BRZ13_APR.00260\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Mensch, Mayer! Super Tor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>bekommst, ist das unbezahlbar – ein Bonus.“ </span><mark>Worte</mark><span class=\\\"context-right\\\">, die dem Torschützen weiteres Selbstvertrauen geben<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00275-p271-272\",\n"
-            + "            \"docID\": \"BRZ13_APR.00275\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Nur Gerücht? KHL-Klub will „Dshuni“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>und hakt das Thema ab.cb Kein </span><mark>Wort</mark><span class=\\\"context-right\\\"> zum Interesse aus Astana: Daniar Dshunussow.Foto<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00277-p163-164\",\n"
-            + "            \"docID\": \"BRZ13_APR.00277\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-02\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft biographien-interviews\",\n"
-            + "            \"title\": \"Das Leben ist nicht auf diese Erde beschränkt\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>1. Korinther 1,18 denken: Denn das </span><mark>Wort</mark><span class=\\\"context-right\\\"> vom Kreuz ist eine Torheit denen<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00520-p32-33\",\n"
-            + "            \"docID\": \"BRZ13_APR.00520\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>für die Profis am Dienstag klare </span><mark>Worte</mark><span class=\\\"context-right\\\"> vom Führungsduo. Von Thorsten Grunow Wolfsburg<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p17-18\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Minuten setzte es am Dienstagnachmittag klare </span><mark>Worte</mark><span class=\\\"context-right\\\"> für die kickende Belegschaft, die durchaus<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p60-61\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"sport fussball\",\n"
-            + "            \"title\": \"Allofs und Hecking knöpfensich die VfL-Profis vor\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Manager ist überzeugt, dass die klaren </span><mark>Worte</mark><span class=\\\"context-right\\\"> auf fruchtbaren Boden gefallen sind. „Ich<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_APR.00557-p235-236\",\n"
-            + "            \"docID\": \"BRZ13_APR.00557\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-04-03\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland politik ausland\",\n"
-            + "            \"title\": \"Zeitungsartikelzufällig deponiert?\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>erspart“, lautete die Schlagzeile – wobei das </span><mark>Wort</mark><span class=\\\"context-right\\\"> „erspart“ abgeschnitten war. Ein plumper Versuch<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07616-p31-32\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07616\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"„Philipp Rösler wackelt nicht“\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Vizekanzler bei all dem Jubel zu </span><mark>Wort</mark><span class=\\\"context-right\\\"> kommt. „Ein großartiger Tag“, sagt er<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07617-p177-178\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07617\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"freizeit-unterhaltung reisen\",\n"
-            + "            \"title\": \"Lanz gibt den charmanten, zurückhaltenden Gastgeber\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>er, als seine Assistentin ihm ins </span><mark>Wort</mark><span class=\\\"context-right\\\"> fiel. Dennoch holte das ungleiche Duo<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07621-p261-262\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07621\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Mundlos denkt über Rücktritt nach\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>räumte selbst ein, wie sarkastisch diese </span><mark>Worte</mark><span class=\\\"context-right\\\"> nach einer solchen Wahlnacht klingen mussten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07694-p192-193\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07694\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"BraunschweigGold – Hannover Blech\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>im Volksfreundhaus hört man kein schlechtes </span><mark>Wort</mark><span class=\\\"context-right\\\"> über den Kanzlerkandidaten Peer Steinbrück – und<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07695-p169-170\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07695\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"BraunschweigGold – Hannover Blech\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>Volksfreundhaus merklich steigen. Hier hat das </span><mark>Wort</mark><span class=\\\"context-right\\\"> von der Wahlparty bei Bier, Bockwurst<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07695-p266-267\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07695\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"staat-gesellschaft kirche\",\n"
-            + "            \"title\": \"Fernsehen überträgt Gottesdienst\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>schon mal von der Sendung „Das </span><mark>Wort</mark><span class=\\\"context-right\\\"> zum Sonntag“ gehört. Das sind Predigten<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07840-p37-38\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07840\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Wahlkrimi im Ratssaal\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\"><span class=\\\"more\\\"></span>ihre Konkurrentin Glosemeyer hatte sie warme </span><mark>Worte</mark><span class=\\\"context-right\\\"> übrig. „Für den ersten Anlauf eine<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07848-p147-148\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07848\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n"
-            + "        },\n"
-            + "        {\n"
-            + "            \"field\": \"tokens\",\n"
-            + "            \"textClass\": \"politik inland\",\n"
-            + "            \"title\": \"Warme Worte nach eiskaltem Wahlkampf\",\n"
-            + "            \"author\": \"\",\n"
-            + "            \"startMore\": true,\n"
-            + "            \"endMore\": true,\n"
-            + "            \"corpusID\": \"BRZ13\",\n"
-            + "            \"snippet\": \"<span class=\\\"context-left\\\">Warme </span><mark>Worte</mark><span class=\\\"context-right\\\"> nach eiskaltem Wahlkampf Die SPD feierte<span class=\\\"more\\\"></span></span>\",\n"
-            + "            \"matchID\": \"match-BRZ13!BRZ13_JAN.07850-p1-2\",\n"
-            + "            \"docID\": \"BRZ13_JAN.07850\",\n"
-            + "            \"UID\": 0,\n"
-            + "            \"pubDate\": \"2013-01-21\"\n" + "        }\n"
-            + "    ]\n" + "}";
-
-}
diff --git a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
index 15df2a9..112282c 100644
--- a/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/resource/rewrite/RewriteHandlerTest.java
@@ -39,7 +39,7 @@
         handler.insertBeans(helper().getContext());
         assertTrue(handler.add(FoundryInject.class));
         assertTrue(handler.add(DocMatchRewrite.class));
-        assertTrue(handler.add(CollectionCleanupFilter.class));
+        assertTrue(handler.add(CollectionCleanRewrite.class));
         assertTrue(handler.add(IdWriter.class));
     }
 
@@ -51,7 +51,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        handler.process(s.toJSON(), null);
+        handler.processQuery(s.toJSON(), null);
     }
 
 
@@ -62,7 +62,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), null);
+        String res = handler.processQuery(s.toJSON(), null);
         assertNotNull(res);
     }
 
@@ -74,7 +74,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), null);
+        String res = handler.processQuery(s.toJSON(), null);
         JsonNode node = JsonUtils.readTree(res);
         assertNotNull(node);
 
@@ -93,7 +93,7 @@
         QuerySerializer s = new QuerySerializer();
         s.setQuery("[(base=laufen | base=gehen) & tt/pos=VVFIN]", "poliqarp");
         assertTrue(handler.add(FoundryInject.class));
-        String res = handler.process(s.toJSON(), helper().getUser());
+        String res = handler.processQuery(s.toJSON(), helper().getUser());
         JsonNode node = JsonUtils.readTree(res);
         assertNotNull(node);
         assertEquals("tt_test",
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
index d7e33b9..d24cad1 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2HandlerTest.java
@@ -14,6 +14,7 @@
 import org.junit.Test;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 /**
  * @author hanl
@@ -48,14 +49,6 @@
     }
 
 
-    //    @AfterClass
-    //    public static void drop() throws KustvaktException {
-    //        assert handler != null;
-    //        handler.removeClient(info, helper().getUser());
-    //        helper().dropUser();
-    //        BeansFactory.closeApplication();
-    //    }
-
     @Test
     public void testStoreAuthorizationCodeThrowsNoException ()
             throws KustvaktException {
@@ -89,7 +82,7 @@
         assertNotNull("context is null", ctx);
 
         AuthCodeInfo c2 = handler.getAuthorization(codeInfo.getCode());
-        Assert.assertNull("clearing authorization failed", c2);
+        assertNull("clearing authorization failed", c2);
     }
 
 
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
index 5a604e2..3ba4f31 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/LightServiceTest.java
@@ -46,12 +46,11 @@
         assertEquals("13", node.at("/meta/count").asText());
     }
 
+
     @Test
-    public void testbuildAndPostQuery() {
-        ClientResponse response = resource()
-                .path(getAPIVersion())
-                .path("search")
-                .queryParam("q", "[orth=das]")
+    public void testbuildAndPostQuery () {
+        ClientResponse response = resource().path(getAPIVersion())
+                .path("search").queryParam("q", "[orth=das]")
                 .queryParam("ql", "poliqarp")
                 .queryParam("cq", "corpusSigle=WPD | corpusSigle=GOE")
                 .method("TRACE", ClientResponse.class);
@@ -62,9 +61,8 @@
         JsonNode node = JsonUtils.readTree(query);
         assertNotNull(node);
 
-        response = resource()
-                .path(getAPIVersion())
-                .path("search").post(ClientResponse.class, query);
+        response = resource().path(getAPIVersion()).path("search")
+                .post(ClientResponse.class, query);
 
         assertEquals(ClientResponse.Status.OK.getStatusCode(),
                 response.getStatus());
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
index 6a5ab99..039593e 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/full/ResourceServiceTest.java
@@ -42,6 +42,7 @@
 
         JsonNode node = JsonUtils.readTree(response.getEntity(String.class));
         assertNotNull(node);
+        System.out.println("NODE " + node);
         assertNotEquals(0, node.path("matches").size());
     }