query rewrite at rest endpoints
diff --git a/Kustvakt-core.iml b/Kustvakt-core.iml
index 9b63e7d..d5feea2 100644
--- a/Kustvakt-core.iml
+++ b/Kustvakt-core.iml
@@ -13,54 +13,14 @@
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="library" name="Maven: com.sun.jersey:jersey-bundle:1.8" level="project" />
     <orderEntry type="library" name="Maven: javax.ws.rs:jsr311-api:1.1.1" level="project" />
-    <orderEntry type="module" module-name="KorAP-graphDB" />
-    <orderEntry type="library" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
-    <orderEntry type="library" name="Maven: com.google.guava:guava:13.0.1" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-analyzers-common:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-highlighter:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-memory:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queries:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queryparser:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-sandbox:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: jakarta-regexp:jakarta-regexp:1.4" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:4.7.0" level="project" />
-    <orderEntry type="library" name="Maven: org.json:json:20131018" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-graphviz:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-cypher:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.10.2" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-graph-matching:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-graph-algo:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.3.1" level="project" />
-    <orderEntry type="library" name="Maven: org.parboiled:parboiled-scala_2.10:1.1.6" level="project" />
-    <orderEntry type="library" name="Maven: org.parboiled:parboiled-core:1.1.6" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.3.1" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.3.1" level="project" />
-    <orderEntry type="library" name="Maven: org.codehaus.groovy:groovy-all:2.1.8" level="project" />
-    <orderEntry type="library" name="Maven: org.antlr:antlr4:4.1" level="project" />
-    <orderEntry type="library" name="Maven: org.antlr:ST4:4.0.7" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-kernel:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1" level="project" />
-    <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.solr:solr-solrj:4.6.0" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.zookeeper:zookeeper:3.4.5" level="project" />
-    <orderEntry type="library" name="Maven: org.noggit:noggit:0.5" level="project" />
-    <orderEntry type="library" scope="RUNTIME" name="Maven: org.codehaus.woodstox:wstx-asl:3.2.7" level="project" />
-    <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-server:9.0.5.v20130815" level="project" />
-    <orderEntry type="library" name="Maven: org.eclipse.jetty.orbit:javax.servlet:3.0.0.v201112011016" level="project" />
-    <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-http:9.0.5.v20130815" level="project" />
-    <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-util:9.0.5.v20130815" level="project" />
-    <orderEntry type="library" name="Maven: org.eclipse.jetty:jetty-io:9.0.5.v20130815" level="project" />
-    <orderEntry type="library" name="Maven: commons-cli:commons-cli:20040117.000000" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:neo4j-rest-graphdb:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-jaxrs:1.9.7" level="project" />
-    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.7" level="project" />
-    <orderEntry type="library" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.7" level="project" />
-    <orderEntry type="library" name="Maven: org.neo4j:server-api:2.0.0-M06" level="project" />
-    <orderEntry type="library" name="Maven: commons-configuration:commons-configuration:1.6" level="project" />
-    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
-    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils-core:1.8.0" level="project" />
-    <orderEntry type="library" name="Maven: commons-digester:commons-digester:1.8.1" level="project" />
-    <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.0" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.5" level="project" />
+    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
+    <orderEntry type="library" name="Maven: log4j:apache-log4j-extras:1.2.17" level="project" />
+    <orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
+    <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
+    <orderEntry type="library" name="Maven: org.projectlombok:lombok:0.11.8" level="project" />
+    <orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
     <orderEntry type="library" name="Maven: KorAP-modules:Koral:0.2" level="project" />
     <orderEntry type="library" name="Maven: org.antlr:antlr4-runtime:4.1" level="project" />
     <orderEntry type="library" name="Maven: org.abego.treelayout:org.abego.treelayout.core:1.0.1" level="project" />
@@ -87,9 +47,15 @@
     <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-container-default:1.0-alpha-9-stable-1" level="project" />
     <orderEntry type="library" name="Maven: classworlds:classworlds:1.1-alpha-2" level="project" />
     <orderEntry type="library" name="Maven: org.codehaus.plexus:plexus-compiler-api:2.2" level="project" />
+    <orderEntry type="library" name="Maven: org.antlr:antlr4:4.1" level="project" />
+    <orderEntry type="library" name="Maven: org.antlr:ST4:4.0.7" level="project" />
     <orderEntry type="library" name="Maven: org.antlr:antlr-runtime:3.5" level="project" />
     <orderEntry type="library" name="Maven: org.antlr:stringtemplate:3.2.1" level="project" />
     <orderEntry type="library" name="Maven: antlr:antlr:2.7.7" level="project" />
+    <orderEntry type="library" name="Maven: com.google.guava:guava:15.0" level="project" />
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.3.3" level="project" />
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.3.3" level="project" />
+    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.3.3" level="project" />
     <orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
     <orderEntry type="library" name="Maven: org.z3950.zing:cql-java:1.12" level="project" />
     <orderEntry type="library" name="Maven: com.sun.jersey:jersey-grizzly2:1.8" level="project" />
@@ -118,9 +84,14 @@
     <orderEntry type="library" name="Maven: commons-codec:commons-codec:1.7" level="project" />
     <orderEntry type="library" name="Maven: net.jcip:jcip-annotations:1.0" level="project" />
     <orderEntry type="library" name="Maven: net.minidev:json-smart:1.1.1" level="project" />
-    <orderEntry type="module" module-name="KorAP-lucene-index" />
+    <orderEntry type="library" name="Maven: de.ids_mannheim.korap:Krill:0.52" level="project" />
+    <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.5" level="project" />
     <orderEntry type="library" name="Maven: c3p0:c3p0:0.9.1.2" level="project" />
-    <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-core:4.10.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queryparser:4.10.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-queries:4.10.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-sandbox:4.10.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.lucene:lucene-analyzers-common:4.10.3" level="project" />
     <orderEntry type="library" name="Maven: net.sf.jsr107cache:jsr107cache:1.0" level="project" />
     <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-grizzly2-http:2.15" level="project" />
     <orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.4.0-b06" level="project" />
@@ -154,7 +125,9 @@
     <orderEntry type="library" scope="PROVIDED" name="Maven: com.jayway.restassured:rest-assured:2.4.0" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.groovy:groovy:2.3.7" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: org.codehaus.groovy:groovy-xml:2.3.7" level="project" />
-    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpmime:4.3.6" level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.3.6" level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.3.3" level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpmime:4.3.6" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: org.ccil.cowan.tagsoup:tagsoup:1.2.1" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: com.jayway.restassured:json-path:2.4.0" level="project" />
@@ -162,16 +135,6 @@
     <orderEntry type="library" scope="PROVIDED" name="Maven: com.jayway.restassured:rest-assured-common:2.4.0" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: com.jayway.restassured:xml-path:2.4.0" level="project" />
     <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
-    <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
-    <orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.5" level="project" />
-    <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
-    <orderEntry type="library" name="Maven: log4j:apache-log4j-extras:1.2.17" level="project" />
-    <orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
-    <orderEntry type="library" name="Maven: org.projectlombok:lombok:0.11.8" level="project" />
-    <orderEntry type="library" name="Maven: joda-time:joda-time:2.2" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.3.3" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.3.3" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.3.3" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-core:4.0.5.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.3" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-context:4.0.5.RELEASE" level="project" />
@@ -182,5 +145,16 @@
     <orderEntry type="library" name="Maven: aopalliance:aopalliance:1.0" level="project" />
     <orderEntry type="library" name="Maven: org.springframework:spring-aspects:4.0.5.RELEASE" level="project" />
     <orderEntry type="library" name="Maven: org.aspectj:aspectjweaver:1.7.4" level="project" />
+    <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.1" level="project" />
+    <orderEntry type="library" name="Maven: org.scala-lang:scala-library:2.10.2" level="project" />
+    <orderEntry type="module-library" scope="TEST">
+      <library>
+        <CLASSES>
+          <root url="jar://$APPLICATION_HOME_DIR$/plugins/testng/lib/testng.jar!/" />
+        </CLASSES>
+        <JAVADOC />
+        <SOURCES />
+      </library>
+    </orderEntry>
   </component>
 </module>
\ No newline at end of file
diff --git a/config/users.c b/config/users.c
deleted file mode 100644
index fa66a23..0000000
--- a/config/users.c
+++ /dev/null
@@ -1,16 +0,0 @@
-korap.lastname=KorAP
-korap.password=korap123
-
-admin.password=admin
-
-MichaelHanl.password=schnurtzl
-MichaelHanl.lastname=Hanl
-MichaelHanl.firstname=Michael
-MichaelHanl.address=I7, 68159 Mannheim
-MichaelHanl.email=hanl@ids-mannheim.de
-
-ids_tdot.password=tdot
-ids_tdot.lastname=IDS
-ids_tdot.address=R5 6-13, Mannheim
-ids_tdot.email=hanl@ids-mannheim.de
-
diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 511bdaa..3054681 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -1,13 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>

 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

-  <parent>

-    <artifactId>KorAP-core-modules</artifactId>

-    <groupId>KorAP-modules</groupId>

-    <version>1.1</version>

-  </parent>

   <modelVersion>4.0.0</modelVersion>

+  <groupId>de.ids_mannheim.korap</groupId>

   <artifactId>Kustvakt-core</artifactId>

+  <name>Kustvakt core</name>

   <version>0.2</version>

+  <description>Kustvakt core, basic rest api for testing purposes and default

+        interfaces</description>

   <build>

     <plugins>

       <plugin>

@@ -104,6 +103,14 @@
           <groupId>org.codehaus.groovy</groupId>

         </exclusion>

         <exclusion>

+          <artifactId>httpclient</artifactId>

+          <groupId>org.apache.httpcomponents</groupId>

+        </exclusion>

+        <exclusion>

+          <artifactId>httpmime</artifactId>

+          <groupId>org.apache.httpcomponents</groupId>

+        </exclusion>

+        <exclusion>

           <artifactId>hamcrest-library</artifactId>

           <groupId>org.hamcrest</groupId>

         </exclusion>

diff --git a/pom.xml b/pom.xml
index 6353c82..32c1e9b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,14 +2,15 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <parent>
-        <artifactId>KorAP-core-modules</artifactId>
-        <groupId>KorAP-modules</groupId>
-        <version>1.1</version>
-    </parent>
     <modelVersion>4.0.0</modelVersion>
+    <groupId>de.ids_mannheim.korap</groupId>
     <artifactId>Kustvakt-core</artifactId>
     <version>0.2</version>
+    <packaging>jar</packaging>
+    <name>Kustvakt core</name>
+    <description>Kustvakt core, basic rest api for testing purposes and default
+        interfaces
+    </description>
     <properties>
         <maven.compiler.source>1.7</maven.compiler.source>
         <maven.compiler.target>1.7</maven.compiler.target>
@@ -104,31 +105,39 @@
             <version>1.8</version>
         </dependency>
         <dependency>
-            <groupId>KorAP-graphDB</groupId>
-            <artifactId>KorAP-graphDB</artifactId>
-            <version>1.0-SNAPSHOT</version>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.antlr</groupId>
-                    <artifactId>antlr4-runtime</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.jersey.core</groupId>
-                    <artifactId>jersey-client</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.jersey.containers</groupId>
-                    <artifactId>jersey-container-grizzly2-http</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.jersey.core</groupId>
-                    <artifactId>jersey-common</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.glassfish.jersey.core</groupId>
-                    <artifactId>jersey-server</artifactId>
-                </exclusion>
-            </exclusions>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <version>1.7.5</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>apache-log4j-extras</artifactId>
+            <version>1.2.17</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.11</version>
+        </dependency>
+        <dependency>
+            <groupId>org.projectlombok</groupId>
+            <artifactId>lombok</artifactId>
+            <version>0.11.8</version>
+        </dependency>
+        <dependency>
+            <groupId>joda-time</groupId>
+            <artifactId>joda-time</artifactId>
+            <version>2.2</version>
         </dependency>
         <dependency>
             <groupId>KorAP-modules</groupId>
@@ -160,7 +169,7 @@
         <dependency>
             <groupId>de.ids_mannheim.korap</groupId>
             <artifactId>Krill</artifactId>
-            <version>0.51</version>
+            <version>0.52</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.xerial</groupId>
@@ -185,6 +194,69 @@
             <version>2.4.0</version>
             <scope>provided</scope>
         </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-core</artifactId>
+            <version>4.0.5.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context</artifactId>
+            <version>4.0.5.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-context-support</artifactId>
+            <version>4.0.5.RELEASE</version>
+        </dependency>
+
+        <!-- apparently this order prevents the spring schemas from being overriden in META-INF/spring.schemas, thus must stay like this
+        -->
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <version>4.0.5.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aspects</artifactId>
+            <version>4.0.5.RELEASE</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-collections</groupId>
+            <artifactId>commons-collections</artifactId>
+            <version>3.2.1</version>
+        </dependency>
+        <!--
+        not part of public release
+        <dependency>
+            <groupId>KorAP-graphDB</groupId>
+            <artifactId>KorAP-graphDB</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.antlr</groupId>
+                    <artifactId>antlr4-runtime</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.core</groupId>
+                    <artifactId>jersey-client</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.containers</groupId>
+                    <artifactId>jersey-container-grizzly2-http</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.core</groupId>
+                    <artifactId>jersey-common</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.glassfish.jersey.core</groupId>
+                    <artifactId>jersey-server</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        -->
     </dependencies>
 
 </project>
diff --git a/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java b/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java
index 4daf76c..30d08f1 100644
--- a/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/AuditingHandler.java
@@ -1,8 +1,15 @@
 package de.ids_mannheim.korap.config;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 /**
  * @author hanl
  * @date 17/06/2015
  */
-public class AuditingHandler {
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface AuditingHandler {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java b/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java
index 74a3a11..d712490 100644
--- a/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/AuthenticationHandler.java
@@ -4,5 +4,5 @@
  * @author hanl
  * @date 17/06/2015
  */
-public class AuthenticationHandler {
+public @interface AuthenticationHandler {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
index f4b72b1..7f53159 100644
--- a/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/BeanConfiguration.java
@@ -1,13 +1,10 @@
 package de.ids_mannheim.korap.config;
 
 import de.ids_mannheim.korap.interfaces.AuditingIface;
-import de.ids_mannheim.korap.plugins.PluginManager;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.FileSystemXmlApplicationContext;
 
-import java.net.URL;
-
 /**
  * User: hanl
  * Date: 10/9/13
@@ -18,28 +15,17 @@
     private static final String config_file = "default-config.xml";
 
     private static ApplicationContext context = null;
-    private static PluginManager plugins;
 
-    private static void loadPlugins() {
-        plugins = new PluginManager();
-        plugins.loadPluginInterfaces();
-    }
-
-    public static void loadContext() {
-        URL url = BeanConfiguration.class.getClassLoader()
-                .getResource(config_file);
-        if (url != null && context == null)
+    public static void loadClasspathContext(String... files) {
+        if (context == null && files == null)
             context = new ClassPathXmlApplicationContext(config_file);
+        else if (context == null)
+            context = new ClassPathXmlApplicationContext(files);
     }
 
-    public static void loadContext(String filepath) {
-        if (filepath == null)
-            loadContext();
-        else {
-            if (context == null)
-                context = new FileSystemXmlApplicationContext(
-                        "file:" + filepath);
-        }
+    public static void loadFileContext(String filepath) {
+        if (context == null)
+            context = new FileSystemXmlApplicationContext("file:" + filepath);
     }
 
     public static <T extends KustvaktConfiguration> T getConfiguration() {
diff --git a/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java b/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java
index cab7f6d..b0a28ac 100644
--- a/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/EncryptionHandler.java
@@ -4,5 +4,5 @@
  * @author hanl
  * @date 18/06/2015
  */
-public class EncryptionHandler {
+public @interface EncryptionHandler {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
index de4748e..4cc7f12 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktClassLoader.java
@@ -2,6 +2,7 @@
 
 import org.reflections.Reflections;
 
+import java.lang.annotation.Annotation;
 import java.util.Set;
 
 /**
@@ -23,4 +24,9 @@
     public static <T> Set<Class<? extends T>> load(Class<T> iface) {
         return reflections.getSubTypesOf(iface);
     }
+
+    public static Set<Class<?>> loadFromAnnotation(
+            Class<? extends Annotation> annotation) {
+        return reflections.getTypesAnnotatedWith(annotation);
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
index 52ac3c7..3b089d4 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -7,6 +7,7 @@
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -14,6 +15,7 @@
 
 /**
  * if configuration class is extended, load method should be overriden
+ *
  * @author hanl
  * @date 05/02/2014
  */
@@ -23,21 +25,29 @@
 
     private final Logger jlog = KorAPLogger
             .initiate(KustvaktConfiguration.class);
+    private String indexDir;
+    private int port;
+    // todo: make exclusive so that the containg languages can really only be used then
+    private List<String> queryLanguages;
 
-    // deprec?!
-    private final BACKENDS DEFAULT_ENGINE = BACKENDS.LUCENE;
     private int maxhits;
 
-    private int port;
     private int returnhits;
     private String serverHost;
-    private String indexDir;
 
-    private List<String> queryLanguages;
     private String host;
 
     private URL issuer;
 
+    private String default_pos;
+    private String default_lemma;
+    private String default_surface;
+    private String default_dep;
+    private String default_const;
+
+    // deprec?!
+    private final BACKENDS DEFAULT_ENGINE = BACKENDS.LUCENE;
+
     /**
      * loading of the properties and mapping to parameter variables
      *
@@ -61,13 +71,42 @@
         for (String querylang : qls)
             queryLanguages.add(querylang.trim().toUpperCase());
         //        issuer = new URL(korap.getProperty("korap.issuer", ""));
+
+        default_const = korap.getProperty("kustvakt.default.const", "mate");
+        default_dep = korap.getProperty("kustvakt.default.dep", "mate");
+        default_lemma = korap.getProperty("kustvakt.default.lemma", "tt");
+        default_pos = korap.getProperty("kustvakt.default.pos", "tt");
+        default_surface = korap
+                .getProperty("kustvakt.default.opennlp", "opennlp");
+
         return korap;
     }
 
+    /**
+     * set properties
+     *
+     * @param props
+     */
     public void setProperties(Properties props) {
         this.load(props);
     }
 
+    /**
+     * properties can be overloaded after spring init
+     *
+     * @param stream
+     */
+    public void setProperties(InputStream stream) {
+        try {
+            Properties p = new Properties();
+            p.load(stream);
+            this.load(p);
+        }catch (IOException e) {
+            e.printStackTrace();
+        }
+
+    }
+
     public BACKENDS chooseBackend(String value) {
         if (value == null || value.equals("null"))
             return DEFAULT_ENGINE;
diff --git a/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java b/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java
index b0c473b..2944aa1 100644
--- a/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/PluginHandler.java
@@ -1,8 +1,78 @@
 package de.ids_mannheim.korap.config;
 
+import de.ids_mannheim.korap.interfaces.AuditingIface;
+import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
+import de.ids_mannheim.korap.interfaces.EncryptionIface;
+import de.ids_mannheim.korap.interfaces.EntityHandlerIface;
+
+import java.lang.annotation.Annotation;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
 /**
  * @author hanl
  * @date 17/06/2015
  */
 public class PluginHandler {
+
+    private static Map<Class<? extends Annotation>, Class> interfaces;
+    private Map<Class<? extends Annotation>, Object> plugins;
+
+    // add resource handler annotation
+    static {
+        interfaces = new HashMap<>();
+        interfaces.put(AuditingHandler.class, AuditingIface.class);
+        interfaces.put(UserDbHandler.class, EntityHandlerIface.class);
+        interfaces.put(AuthenticationHandler.class,
+                AuthenticationManagerIface.class);
+        interfaces.put(EncryptionHandler.class, EncryptionIface.class);
+        //todo:
+        interfaces.put(ResourceHandler.class, ResourceHandler.class);
+    }
+
+    public PluginHandler() {
+        this.plugins = new HashMap<>();
+        this.load();
+    }
+
+    public void load() {
+        for (Map.Entry<Class<? extends Annotation>, Class> en : new HashSet<>(
+                interfaces.entrySet())) {
+            Set<Class<?>> set = KustvaktClassLoader
+                    .loadFromAnnotation(en.getKey());
+            if (set.size() > 1)
+                throw new UnsupportedOperationException(
+                        "handler declaration not unique!");
+            else if (set.size() == 0)
+                interfaces.remove(en.getKey());
+        }
+    }
+
+    public void addInterface(Class<? extends Annotation> anno, Class<?> iface) {
+        interfaces.put(anno, iface);
+    }
+
+    public void registerPlugin(Object ob) {
+        for (Map.Entry<Class<? extends Annotation>, Class> en : interfaces
+                .entrySet()) {
+            if (en.getValue().isInstance(ob))
+                this.plugins.put(en.getKey(), ob);
+        }
+    }
+
+    public Object getPluginInstance(Class<? extends Annotation> anno) {
+        Object o = this.plugins.get(anno);
+        if (o == null)
+            return new NullPointerException(
+                    "no plugin defined for type " + anno.toString());
+        return o;
+    }
+
+    @Override
+    public String toString() {
+        System.out.println("PRINT INTERFACES " + interfaces.toString());
+        return plugins.toString();
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java b/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java
index d93e4f0..2d24c8b 100644
--- a/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java
+++ b/src/main/java/de/ids_mannheim/korap/config/ProtectedResource.java
@@ -4,5 +4,5 @@
  * @author hanl
  * @date 18/06/2015
  */
-public class ProtectedResource {
+public @interface ProtectedResource {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java b/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java
index c354a01..aae143f 100644
--- a/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/ResourceHandler.java
@@ -4,5 +4,5 @@
  * @author hanl
  * @date 18/06/2015
  */
-public class ResourceHandler {
+public @interface ResourceHandler {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java b/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java
index 73fcc56..304f16c 100644
--- a/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java
+++ b/src/main/java/de/ids_mannheim/korap/config/UserDbHandler.java
@@ -1,8 +1,15 @@
 package de.ids_mannheim.korap.config;
 
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
 /**
  * @author hanl
  * @date 17/06/2015
  */
-public class UserDbHandler {
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface UserDbHandler {
 }
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/BaseException.java b/src/main/java/de/ids_mannheim/korap/exceptions/BaseException.java
index 408f591..66e1197 100644
--- a/src/main/java/de/ids_mannheim/korap/exceptions/BaseException.java
+++ b/src/main/java/de/ids_mannheim/korap/exceptions/BaseException.java
@@ -7,6 +7,10 @@
 import java.util.List;
 
 /**
+ * Serves as base exception to allow auditing the exception.
+ * By extending the exception, different types of exceptions and ways of handling the audits can be created
+ * (database, service, etc.)
+ *
  * @author hanl
  * @date 29/01/2014
  */
@@ -17,7 +21,6 @@
     private Integer statusCode;
     private String entity;
 
-
     public BaseException(int code) {
         this.statusCode = code;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/exceptions/KorAPException.java b/src/main/java/de/ids_mannheim/korap/exceptions/KorAPException.java
index a050770..d3435f7 100644
--- a/src/main/java/de/ids_mannheim/korap/exceptions/KorAPException.java
+++ b/src/main/java/de/ids_mannheim/korap/exceptions/KorAPException.java
@@ -7,6 +7,8 @@
  * @author hanl
  * @date 11/12/2013
  */
+//fixme: redundant with baseexception
+@Deprecated
 @Setter
 @Getter
 public class KorAPException extends BaseException {
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/AuditingIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/AuditingIface.java
index 82bdd55..873f435 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/AuditingIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuditingIface.java
@@ -17,7 +17,7 @@
 public abstract class AuditingIface implements Runnable {
 
     protected static int BATCH_SIZE = 15;
-    protected final List<AuditRecord> records = new ArrayList<>(BATCH_SIZE + 5);
+    private final List<AuditRecord> records = new ArrayList<>(BATCH_SIZE + 5);
     private final List<AuditRecord> buffer = new ArrayList<>(BATCH_SIZE + 5);
 
     public abstract <T extends AuditRecord> List<T> retrieveRecords(
@@ -53,4 +53,8 @@
             addAndRun(rec);
     }
 
+    protected List<AuditRecord> getRecordsToSave() {
+        return this.records;
+    }
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java
index e02933e..600981f 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java
@@ -1,25 +1,22 @@
 package de.ids_mannheim.korap.interfaces;
 
 import de.ids_mannheim.korap.exceptions.KorAPException;
-import de.ids_mannheim.korap.ext.security.AccessLevel;
 import de.ids_mannheim.korap.user.TokenContext;
 import de.ids_mannheim.korap.user.User;
 
 import java.util.Map;
 
-public abstract class AuthenticationIface {
+public interface AuthenticationIface {
 
-    public abstract TokenContext getUserStatus(String authToken)
+    public TokenContext getUserStatus(String authToken) throws KorAPException;
+
+    public TokenContext createUserSession(User user, Map<String, Object> attr)
             throws KorAPException;
 
-    public abstract TokenContext createUserSession(User user,
-            Map<String, Object> attr) throws KorAPException;
+    public void removeUserSession(String token) throws KorAPException;
 
-    public abstract void removeUserSession(String token) throws KorAPException;
+    public TokenContext refresh(TokenContext context) throws KorAPException;
 
-    public abstract AccessLevel[] retrieveLevelAccess(String authToken)
-            throws KorAPException;
-
-    public abstract String getIdentifier();
+    public String getIdentifier();
 
 }
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
index a3fb44a..4021836 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
@@ -1,9 +1,11 @@
 package de.ids_mannheim.korap.interfaces;
 
+import de.ids_mannheim.korap.config.KustvaktClassLoader;
 import de.ids_mannheim.korap.exceptions.KorAPException;
 import de.ids_mannheim.korap.user.*;
 
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 
@@ -15,10 +17,23 @@
 
     private Map<String, AuthenticationIface> providers;
 
-    //todo: test if constr actually called
     public AuthenticationManagerIface() {
-        System.out.println("TEST CONSTRUCTOR CALL");
         this.providers = new HashMap<>();
+        loadProviders();
+    }
+
+    private void loadProviders() {
+        Set<Class<? extends AuthenticationIface>> set = KustvaktClassLoader
+                .load(AuthenticationIface.class);
+        Set<AuthenticationIface> set2 = new HashSet<>();
+        for (Class<? extends AuthenticationIface> i : set) {
+            try {
+                set2.add(i.newInstance());
+            }catch (InstantiationException | IllegalAccessException e) {
+                e.printStackTrace();
+            }
+        }
+        this.setProviders(set2);
     }
 
     public void setProviders(Set<AuthenticationIface> providers) {
@@ -35,14 +50,26 @@
         return iface;
     }
 
+    public abstract TokenContext getTokenStatus(String token, String host,
+            String useragent) throws KorAPException;
+
+    public abstract User getUser(String username) throws KorAPException;
+
     public abstract User authenticate(int type, String username,
             String password, Map<String, Object> attributes)
             throws KorAPException;
 
+    public abstract TokenContext createTokenContext(User user,
+            Map<String, Object> attr, String provider_key)
+            throws KorAPException;
+
     public abstract void logout(TokenContext context) throws KorAPException;
 
     public abstract void lockAccount(User user) throws KorAPException;
 
+    public abstract User createUserAccount(Map<String, Object> attributes)
+            throws KorAPException;
+
     public abstract boolean updateAccount(User user) throws KorAPException;
 
     public abstract boolean deleteAccount(User user) throws KorAPException;
@@ -57,4 +84,10 @@
 
     public abstract void updateUserSettings(User user, UserSettings settings)
             throws KorAPException;
+
+    public abstract Object[] validateResetPasswordRequest(String username,
+            String email) throws KorAPException;
+
+    public abstract void confirmRegistration(String uriFragment,
+            String username) throws KorAPException;
 }
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultAuditing.java b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultAuditing.java
index cb0eef7..27bb3a1 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultAuditing.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultAuditing.java
@@ -6,6 +6,10 @@
 import org.joda.time.DateTime;
 import org.joda.time.LocalDate;
 
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
 import java.util.List;
 
 /**
@@ -14,37 +18,51 @@
  */
 public class DefaultAuditing extends AuditingIface {
 
-    public DefaultAuditing() {
+    private FileOutputStream stream;
 
+    public DefaultAuditing() {
+        try {
+            File f = new File("logs");
+            f.mkdirs();
+            stream = new FileOutputStream(new File(f, "audit.log"));
+        }catch (FileNotFoundException e) {
+            e.printStackTrace();
+        }
     }
 
     @Override
     public <T extends AuditRecord> List<T> retrieveRecords(
             AuditRecord.CATEGORY category, DateTime day, DateTime until,
             boolean exact, int limit) {
-        return null;
+        throw new UnsupportedOperationException("operation not supported!");
     }
 
     @Override
     public <T extends AuditRecord> List<T> retrieveRecords(
             AuditRecord.CATEGORY category, User user, int limit) {
-        return null;
+        throw new UnsupportedOperationException("operation not supported!");
     }
 
     @Override
     public <T extends AuditRecord> List<T> retrieveRecords(LocalDate day,
             int hitMax) {
-        return null;
+        throw new UnsupportedOperationException("operation not supported!");
     }
 
     @Override
     public <T extends AuditRecord> List<T> retrieveRecords(String userID,
             LocalDate start, LocalDate end, int hitMax) {
-        return null;
+        throw new UnsupportedOperationException("operation not supported!");
     }
 
     @Override
     public void run() {
-        //todo: append to logging file or other auditing file
+        try {
+            for (AuditRecord r : getRecordsToSave())
+                stream.write((r.toString() + "\n").getBytes());
+            stream.flush();
+        }catch (IOException e) {
+            e.printStackTrace();
+        }
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultEncryption.java b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultEncryption.java
index 8c787db..64f3b5e 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultEncryption.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/DefaultEncryption.java
@@ -14,6 +14,7 @@
  * @author hanl
  * @date 05/06/2015
  */
+//todo: init!
 public class DefaultEncryption implements EncryptionIface {
 
     private SecureRandom randomizer;
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
index 4b31330..f5f339d 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerMapper.java
@@ -1,5 +1,7 @@
 package de.ids_mannheim.korap.resource;
 
+import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.user.UserSettings;
 
 /**
@@ -9,11 +11,15 @@
 public class LayerMapper {
 
     private UserSettings settings;
-    private ExtConfiguration config;
+    private KustvaktConfiguration config;
 
     public LayerMapper(UserSettings settings) {
         this.settings = settings;
-        this.config = ExtensionBeans.getConfiguration();
+        this.config = BeanConfiguration.getConfiguration();
+    }
+
+    public LayerMapper() {
+        this.config = BeanConfiguration.getConfiguration();
     }
 
     /**
diff --git a/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java
index 78fd005..71d30b1 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/LayerProcessor.java
@@ -1,8 +1,44 @@
 package de.ids_mannheim.korap.resource;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+import java.util.Iterator;
+
 /**
  * @author hanl
  * @date 19/06/2015
  */
-public class LayerProcessor {
+public class LayerProcessor extends NodeProcessor {
+
+    private LayerMapper mapper;
+
+    public LayerProcessor() {
+        this.mapper = new LayerMapper();
+    }
+
+    @Override
+    public JsonNode process(JsonNode node) {
+        if (node.at("/query/wrap/@type").asText().equals("koral:term")) {
+            JsonNode n = node.at("/query/wrap");
+            if (n.path("foundry").isMissingNode()) {
+                String layer = n.path("layer").asText();
+                ObjectNode obj = (ObjectNode) n;
+                obj.put("foundry", mapper.findFoundry(layer));
+            }
+        }else if (node.at("/query/wrap/@type").asText()
+                .equals("koral:termGroup")) {
+            Iterator<JsonNode> nodes = node.at("/query/wrap/operands")
+                    .elements();
+            while (nodes.hasNext()) {
+                JsonNode n = nodes.next();
+                if (n.path("foundry").isMissingNode()) {
+                    String layer = n.path("layer").asText();
+                    ObjectNode obj = (ObjectNode) n;
+                    obj.put("foundry", mapper.findFoundry(layer));
+                }
+            }
+        }
+        return node;
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java
index 4f27347..c7a9451 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/NodeProcessor.java
@@ -1,8 +1,13 @@
 package de.ids_mannheim.korap.resource;
 
+import com.fasterxml.jackson.databind.JsonNode;
+
 /**
  * @author hanl
  * @date 19/06/2015
  */
-public class NodeProcessor {
+public abstract class NodeProcessor {
+
+    public abstract JsonNode process(JsonNode node);
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java b/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java
index 9950266..6031261 100644
--- a/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/resource/RewriteProcessor.java
@@ -1,8 +1,41 @@
 package de.ids_mannheim.korap.resource;
 
+import com.fasterxml.jackson.databind.JsonNode;
+import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
+import de.ids_mannheim.korap.utils.JsonUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @author hanl
  * @date 19/06/2015
  */
 public class RewriteProcessor {
+
+    private KustvaktConfiguration config;
+    private List<NodeProcessor> processors;
+
+    public RewriteProcessor() {
+        this.config = BeanConfiguration.getConfiguration();
+        this.processors = new ArrayList<>();
+        addProcessor(new LayerProcessor());
+    }
+
+    public JsonNode process(JsonNode node) {
+        for (NodeProcessor p : this.processors)
+            node = p.process(node);
+        return node;
+    }
+
+    public String process(String json) {
+        JsonNode node = JsonUtils.readTree(json);
+        return JsonUtils.toJSON(process(node));
+    }
+
+    public void addProcessor(NodeProcessor processor) {
+        this.processors.add(processor);
+    }
+
 }
diff --git a/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java b/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
index 1217085..1b52306 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/CollectionQueryBuilder3.java
@@ -1,5 +1,7 @@
 package de.ids_mannheim.korap.utils;
 
+import de.ids_mannheim.korap.query.serialize.CollectionQueryProcessor;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -64,10 +66,9 @@
         List list = new ArrayList();
         if (!this.rq.isEmpty())
             list.addAll(this.rq);
-        System.out.println("RAW QUERY " + this.builder.toString());
-//        CollectionQueryProcessor tree = new CollectionQueryProcessor(this.verbose);
-//        tree.process(this.builder.toString());
-//        list.add(tree.getRequestMap());
+        CollectionQueryProcessor tree = new CollectionQueryProcessor(this.verbose);
+        tree.process(this.builder.toString());
+        list.add(tree.getRequestMap());
         return list;
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/web/Kustvakt.java b/src/main/java/de/ids_mannheim/korap/web/Kustvakt.java
index f9349e6..a8e4c94 100644
--- a/src/main/java/de/ids_mannheim/korap/web/Kustvakt.java
+++ b/src/main/java/de/ids_mannheim/korap/web/Kustvakt.java
@@ -6,6 +6,8 @@
 import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.utils.KorAPLogger;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
 
 /**
@@ -15,10 +17,17 @@
 public class Kustvakt {
 
     private static Integer PORT = -1;
+    private static String CONFIG = null;
 
     public static void main(String[] args) throws Exception {
         attributes(args);
-        BeanConfiguration.loadContext();
+        BeanConfiguration.loadClasspathContext();
+
+        if (CONFIG != null) {
+            BeanConfiguration.getConfiguration()
+                    .setProperties(new FileInputStream(new File(CONFIG)));
+
+        }
         grizzlyServer(PORT);
     }
 
@@ -44,6 +53,9 @@
                 case "--debug":
                     KorAPLogger.DEBUG = true;
                     break;
+                case "config":
+                    CONFIG = args[i + 1];
+                    break;
                 case "--port":
                     PORT = Integer.valueOf(args[i + 1]);
                     break;
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
index bd1be22..35e1c6b 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/LightService.java
@@ -1,18 +1,14 @@
 package de.ids_mannheim.korap.web.service;
 
-import com.fasterxml.jackson.core.JsonProcessingException;
 import com.sun.jersey.core.util.MultivaluedMapImpl;
 import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KorAPException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
-import de.ids_mannheim.korap.graphdb.collo.ColloQuery;
-import de.ids_mannheim.korap.graphdb.collo.Dependency;
-import de.ids_mannheim.korap.query.serialize.IdWriter;
 import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
 import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.resource.RewriteProcessor;
 import de.ids_mannheim.korap.utils.CollectionQueryBuilder;
-import de.ids_mannheim.korap.utils.JsonUtils;
 import de.ids_mannheim.korap.utils.KorAPLogger;
 import de.ids_mannheim.korap.utils.StringUtils;
 import de.ids_mannheim.korap.web.ClientsHandler;
@@ -25,13 +21,13 @@
 import javax.ws.rs.core.*;
 import java.util.ArrayList;
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 /**
  * @author hanl
  * @date 29/01/2014
  */
+//todd test functions
 @Path("v0.1" + "/")
 @Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
 public class LightService {
@@ -40,68 +36,19 @@
 
     private SearchLucene searchLucene;
     private ClientsHandler graphDBhandler;
+    private RewriteProcessor processor;
 
     public LightService() {
         this.searchLucene = new SearchLucene(
                 BeanConfiguration.getConfiguration().getIndexDir());
         UriBuilder builder = UriBuilder.fromUri("http://10.0.10.13").port(9997);
         this.graphDBhandler = new ClientsHandler(builder.build());
-    }
-
-    /**
-     * @param properties
-     * @param sfs
-     * @param limit
-     * @param query
-     * @param ql
-     * @param context
-     * @param foundry
-     * @param wPaths
-     * @return
-     */
-    //todo: add entry point where a json collection can be injected as well
-    @GET
-    @Path("colloc")
-    public Response getCollocationsAll(@QueryParam("props") String properties,
-            @QueryParam("sfskip") Integer sfs,
-            @QueryParam("sflimit") Integer limit, @QueryParam("q") String query,
-            @QueryParam("ql") String ql, @QueryParam("context") Integer context,
-            @QueryParam("foundry") String foundry,
-            @QueryParam("paths") Boolean wPaths) {
-        ColloQuery.ColloQueryBuilder builder;
-        String result;
-        try {
-            builder = new ColloQuery.ColloQueryBuilder();
-            QuerySerializer s = new QuerySerializer().setQuery(query, ql);
-            //todo: fix collectionbuilder
-            //        s.setDeprCollection(builder);
-            IdWriter writer = new IdWriter(s.toJSON()).process();
-            List collprops = JsonUtils.convertToList(properties);
-
-            if (context != null)
-                builder.context(context).collocateProps(collprops);
-            if (limit != null)
-                builder.surfaceLimit(limit);
-            if (sfs != null)
-                builder.surfaceSkip(sfs);
-            if (foundry != null)
-                builder.foundry(foundry);
-            builder.nodeQueryJS(writer.toJSON())
-                    .dep(new ArrayList<Dependency>()).withPaths(wPaths);
-
-            result = graphDBhandler
-                    .getResponse("distCollo", "q", builder.build().toJSON());
-        }catch (KorAPException e) {
-            throw KustvaktResponseHandler.throwit(e);
-        }catch (JsonProcessingException e) {
-            throw KustvaktResponseHandler.throwit(StatusCodes.ILLEGAL_ARGUMENT);
-        }
-        return Response.ok(result).build();
+        this.processor = new RewriteProcessor();
     }
 
     @POST
     @Path("colloc")
-    public Response getCollocatioBase(@QueryParam("q") String query) {
+    public Response getCollocationBase(@QueryParam("q") String query) {
         String result;
         try {
             result = graphDBhandler.getResponse("distCollo", "q", query);
@@ -111,6 +58,7 @@
         return Response.ok(result).build();
     }
 
+    // todo
     public Response postMatchFavorite() {
         return Response.ok().build();
     }
@@ -140,7 +88,7 @@
         ss.addMeta(meta);
         //todo: test this
         ss.setCollection(cq);
-        return Response.ok(ss.toJSON()).build();
+        return Response.ok(processor.process(ss.toJSON())).build();
     }
 
     @POST
@@ -149,11 +97,10 @@
             String jsonld) {
         KustvaktConfiguration.BACKENDS eng = BeanConfiguration
                 .getConfiguration().chooseBackend(engine);
-
+        jsonld = processor.process(jsonld);
         // todo: should be possible to add the meta part to the query serialization
         jlog.info("Serialized search: {}", jsonld);
 
-        // todo: Security Parsing and rewrite
         // fixme: to use the systemarchitecture pointcut thingis, searchlucene must be injected via
         String result = searchLucene.search(jsonld);
         KorAPLogger.QUERY_LOGGER.trace("The result set: {}", result);
@@ -181,8 +128,7 @@
         //        meta.addEntry("itemsPerResource", 1);
         serializer.addMeta(meta);
 
-        // policy rewrite!
-        String query = serializer.toJSON();
+        String query = processor.process(serializer.toJSON());
         jlog.info("the serialized query {}", query);
 
         if (eng.equals(KustvaktConfiguration.BACKENDS.NEO4J)) {
@@ -248,7 +194,7 @@
             // should only apply to CQL queries
             //                meta.addEntry("itemsPerResource", 1);
             s.addMeta(meta);
-            query = s.toJSON();
+            query = processor.process(s.toJSON());
         }
         String result;
         try {
@@ -326,7 +272,6 @@
                 results = searchLucene
                         .getMatch(matchid, new ArrayList<>(f_list),
                                 new ArrayList<>(l_list), spans, false, true);
-
             }
         }
         try {
diff --git a/src/main/java/de/ids_mannheim/korap/web/utils/FormWrapper.java b/src/main/java/de/ids_mannheim/korap/web/utils/FormWrapper.java
index b1dad85..913c848 100644
--- a/src/main/java/de/ids_mannheim/korap/web/utils/FormWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/web/utils/FormWrapper.java
@@ -6,10 +6,11 @@
 import java.util.Map;
 
 /**
- * @author hanl
- * @date 18/05/2015
  * Helper class to wrapp multivaluedmap into a hashmap. Depending on the strict parameter,
  * list values are retained in the resulting wrapper map.
+ *
+ * @author hanl
+ * @date 18/05/2015
  */
 public class FormWrapper extends HashMap<String, Object> {
 
diff --git a/src/main/resources/default-config.xml b/src/main/resources/default-config.xml
index 7e3c557..f0c380f 100644
--- a/src/main/resources/default-config.xml
+++ b/src/main/resources/default-config.xml
@@ -8,8 +8,6 @@
                             http://www.springframework.org/schema/util/spring-util-4.0.xsd">
 
 
-    <!--<context:property-placeholder location="classpath:kustvakt.conf"/>-->
-
     <util:properties id="props" location="classpath:kustvakt.conf"/>
 
     <bean id="auditingProvider"
diff --git a/src/test/java/RewriteTest.java b/src/test/java/RewriteTest.java
index 70bf72a..db33a1a 100644
--- a/src/test/java/RewriteTest.java
+++ b/src/test/java/RewriteTest.java
@@ -1,6 +1,58 @@
+import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.query.serialize.QuerySerializer;
+import de.ids_mannheim.korap.resource.LayerMapper;
+import de.ids_mannheim.korap.resource.RewriteProcessor;
+import de.ids_mannheim.korap.utils.CollectionQueryBuilder3;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 /**
  * @author hanl
  * @date 18/06/2015
  */
 public class RewriteTest {
+
+    private static String simple_add_query = "[pos=ADJA]";
+    private static String simple_rewrite_query = "[base=Haus]";
+    private static String complex_rewrite_query = "<c=INFC>";
+    private static String complex_rewrite_query2 = "[orth=laufe/i & base!=Lauf]";
+
+    public RewriteTest() {
+
+    }
+
+    @BeforeClass
+    public static void init() {
+        BeanConfiguration.loadFileContext(
+                "/Users/hanl/Projects/KorAP-project/KorAP-modules/Kustvakt-core/src/main/resources/default-config.xml");
+    }
+
+    @Test
+    public void testQuery() {
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery(simple_add_query, "poliqarp");
+        System.out.println("query " + s.toJSON());
+
+        CollectionQueryBuilder3 b = new CollectionQueryBuilder3();
+        b.add("textClass=politik & corpusID=WPD");
+        System.out.println("collection query " + b.toJSON());
+    }
+
+    @Test
+    public void testLayerMapper() {
+        LayerMapper m = new LayerMapper();
+        System.out.println("foundry " + m.findFoundry("lemma"));
+        System.out.println("foundry " + m.findFoundry("surface"));
+        System.out.println("foundry " + m.findFoundry("pos"));
+    }
+
+    @Test
+    public void testRewrite() {
+        RewriteProcessor processor = new RewriteProcessor();
+
+        QuerySerializer s = new QuerySerializer();
+        s.setQuery(complex_rewrite_query2, "poliqarp");
+        System.out.println("query " + s.toJSON());
+        System.out.println("finished node " + processor.process(s.toJSON()));
+    }
 }