usersettings test
diff --git a/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java b/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
index 6563563..30f8e2f 100644
--- a/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
+++ b/src/main/java/de/ids_mannheim/korap/config/JWTSigner.java
@@ -41,28 +41,25 @@
         this(secret, new URL(issuer), 72 * 60 * 60);
     }
 
-    public SignedJWT createJWT(User user, Map<String, Object> attr) {
+    public SignedJWT createJWT(User user, Map<String, String> attr) {
         return signContent(user, attr, defaultttl);
     }
 
-    public SignedJWT signContent(User user, Map<String, Object> attr, int ttl) {
+    public SignedJWT signContent(User user, Map<String, String> attr, int ttl) {
         String scopes;
 
         JWTClaimsSet cs = new JWTClaimsSet();
         cs.setIssuerClaim(this.issuer.toString());
 
-        if ((scopes = (String) attr.get(Attributes.SCOPES)) != null) {
-            Map<String, Object> claims = Scopes
-                    .mapOpenIDConnectScopes(scopes, user.getDetails());
-            cs.setCustomClaims(claims);
-            cs.setCustomClaim(Attributes.SCOPES,
-                    ((String) attr.get(Attributes.SCOPES)).toLowerCase());
+        if ((scopes = attr.get(Attributes.SCOPES)) != null) {
+            Scopes claims = Scopes.mapScopes(scopes, user.getDetails());
+            cs.setCustomClaims(claims.toMap());
         }
 
         cs.setSubjectClaim(user.getUsername());
         if (attr.get(Attributes.CLIENT_ID) != null)
             cs.setAudienceClaim(
-                    new String[] { (String) attr.get(Attributes.CLIENT_ID) });
+                    new String[] { attr.get(Attributes.CLIENT_ID) });
         cs.setExpirationTimeClaim(
                 TimeUtils.getNow().plusSeconds(ttl).getMillis());
         SignedJWT signedJWT = new SignedJWT(new JWSHeader(JWSAlgorithm.HS256),
@@ -163,7 +160,7 @@
         c.setExpirationTime(
                 signedJWT.getJWTClaimsSet().getExpirationTimeClaim());
         c.setToken(idtoken);
-        c.setParameters(signedJWT.getJWTClaimsSet().getCustomClaims());
+        c.addParams(signedJWT.getJWTClaimsSet().getCustomClaims());
         return c;
     }
 
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 ba271f0..5b961f8 100644
--- a/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
+++ b/src/main/java/de/ids_mannheim/korap/config/KustvaktConfiguration.java
@@ -26,10 +26,10 @@
 @Getter
 public class KustvaktConfiguration {
 
-    public static final Map<String, Object> KUSTVAKT_USER = new HashMap<>();
+    public static final Map<String, String> KUSTVAKT_USER = new HashMap<>();
 
     static {
-        KUSTVAKT_USER.put(Attributes.ID, 1);
+        KUSTVAKT_USER.put(Attributes.ID, "1");
         KUSTVAKT_USER.put(Attributes.USERNAME, "kustvakt");
         KUSTVAKT_USER.put(Attributes.PASSWORD, "kustvakt2015");
         KUSTVAKT_USER.put(Attributes.EMAIL, "kustvakt@ids-mannheim.de");
diff --git a/src/main/java/de/ids_mannheim/korap/config/Scopes.java b/src/main/java/de/ids_mannheim/korap/config/Scopes.java
index 22567ac..63a3f07 100644
--- a/src/main/java/de/ids_mannheim/korap/config/Scopes.java
+++ b/src/main/java/de/ids_mannheim/korap/config/Scopes.java
@@ -2,6 +2,7 @@
 
 import de.ids_mannheim.korap.user.Attributes;
 import de.ids_mannheim.korap.user.UserDetails;
+import de.ids_mannheim.korap.utils.JsonUtils;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -29,13 +30,12 @@
     private static final Enum[] SERVICE_DEFAULTS = { Scope.account,
             Scope.preferences, Scope.search, Scope.queries };
 
-    public static Map<String, Object> getProfileScopes(
-            Map<String, Object> values) {
-        Map<String, Object> r = new HashMap<>();
+    public static Scopes getProfileScopes(Map<String, Object> values) {
+        Scopes r = new Scopes();
         for (String key : profile) {
             Object v = values.get(key);
             if (v != null)
-                r.put(key, v);
+                r._values.put(key, v);
         }
         return r;
     }
@@ -47,26 +47,44 @@
      * @return
      */
     //todo: test
-    public static Enum[] mapScopes(String scopes) {
+    public static Scope[] mapScopes(String scopes) {
         List<Enum> s = new ArrayList<>();
         for (String value : scopes.split(" "))
             s.add(Scope.valueOf(value.toLowerCase()));
-        return (Enum[]) s.toArray(new Enum[s.size()]);
+        return s.toArray(new Scope[s.size()]);
     }
 
-    public static Map<String, Object> mapOpenIDConnectScopes(String scopes,
-            UserDetails details) {
-        Map<String, Object> m = new HashMap<>();
+    public static Scopes mapScopes(String scopes, UserDetails details) {
+        Scopes m = new Scopes();
+        Map<String, Object> det = details.toMap();
         if (scopes != null && !scopes.isEmpty()) {
-            scopes = scopes.toLowerCase();
-            if (scopes.contains(Scope.email.toString()))
-                m.put(Attributes.EMAIL, details.getEmail());
+            Scope[] scopearr = mapScopes(scopes);
+            for (Scope s : scopearr) {
+                Object v = det.get(s.toString());
+                if (v != null)
+                    m._values.put(s.toString(), v);
+            }
             if (scopes.contains(Scope.profile.toString()))
-                m.putAll(Scopes.getProfileScopes(details.toMap()));
+                m._values.putAll(Scopes.getProfileScopes(det)._values);
+            m._values.put(Attributes.SCOPES, scopes);
         }
         return m;
     }
 
+    private Map<String, Object> _values;
 
+    private Scopes() {
+        this._values = new HashMap<>();
+    }
+
+    public String toEntity() {
+        if (this._values.isEmpty())
+            return "";
+        return JsonUtils.toJSON(this._values);
+    }
+
+    public Map<String, Object> toMap() {
+        return new HashMap<>(this._values);
+    }
 
 }
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java b/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
index d6d57bf..b2fa818 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/CollectionDao.java
@@ -164,6 +164,18 @@
         }
     }
 
+    @Override
+    public int size() throws KustvaktException {
+        final String sql = "select count(*) from coll_store;";
+        try {
+            return this.jdbcTemplate
+                    .queryForObject(sql, new HashMap<String, Object>(),
+                            Integer.class);
+        }catch (DataAccessException e) {
+            throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
+        }
+    }
+
     //todo: adjust to resource id input (batch operation!)
     // fixme: test
     public List<VirtualCollection> getResources(Collection<Object> resources,
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java b/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
index 57b0014..ccc9409 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/DocumentDao.java
@@ -222,4 +222,9 @@
             throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
         }
     }
+
+    @Override
+    public int size() throws KustvaktException {
+        return -1;
+    }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
index 067abda..03d1b87 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/EntityDao.java
@@ -93,9 +93,8 @@
         }catch (DataAccessException e) {
             jlog.error("Could not update user settings for user: " + settings
                     .getUserID(), e);
-            throw new dbException(settings.getUserID(), "userSettings",
+            throw new dbException(settings.getUserID(), "user_settings",
                     StatusCodes.DB_UPDATE_FAILED, settings.toString());
-            //            throw new KorAPException(e, StatusCodes.CONNECTION_ERROR);
         }
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java b/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java
index 4f6b9e3..6161cdb 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/JDBCClient.java
@@ -47,16 +47,18 @@
 
     @Override
     public boolean checkDatabase() {
+        int size;
         NamedParameterJdbcTemplate tmp = this.getSource();
         try {
-            // todo: use a table that doesnt change!!!!!
-            tmp.queryForObject("select count(id) from korap_users limit 1;",
+            // uses flyway schema table to determine of schema was applied succesfully
+            size = tmp.queryForObject(
+                    "select count(*) from schema_version limit 10;",
                     new HashMap<String, Object>(), Integer.class);
         }catch (Exception e) {
             System.out.println("No database schema found!");
             return false;
         }
-        return true;
+        return size > 0;
     }
 
     @Override
diff --git a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
index 0aeeaac..53f3a3b 100644
--- a/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
+++ b/src/main/java/de/ids_mannheim/korap/handlers/ResourceDao.java
@@ -185,4 +185,9 @@
             throw new KustvaktException(StatusCodes.CONNECTION_ERROR);
         }
     }
+
+    @Override
+    public int size() throws KustvaktException {
+        return -1;
+    }
 }
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 82d6737..13f29f6 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationIface.java
@@ -11,7 +11,7 @@
     TokenContext getUserStatus(String authToken) throws
             KustvaktException;
 
-    TokenContext createUserSession(User user, Map<String, Object> attr)
+    TokenContext createUserSession(User user, Map<String, String> attr)
             throws KustvaktException;
 
     void removeUserSession(String token) throws KustvaktException;
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 f0df181..1d2f9cd 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/AuthenticationManagerIface.java
@@ -43,18 +43,18 @@
     public abstract User getUser(String username) throws KustvaktException;
 
     public abstract User authenticate(int type, String username,
-            String password, Map<String, Object> attributes)
+            String password, Map<String, String> attributes)
             throws KustvaktException;
 
     public abstract TokenContext createTokenContext(User user,
-            Map<String, Object> attr, String provider_key)
+            Map<String, String> attr, String provider_key)
             throws KustvaktException;
 
     public abstract void logout(TokenContext context) throws KustvaktException;
 
     public abstract void lockAccount(User user) throws KustvaktException;
 
-    public abstract User createUserAccount(Map<String, Object> attributes,
+    public abstract User createUserAccount(Map<String, String> attributes,
             boolean conf_required) throws KustvaktException;
 
     public abstract boolean updateAccount(User user) throws KustvaktException;
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/EncryptionIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/EncryptionIface.java
index b591911..6101861 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/EncryptionIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/EncryptionIface.java
@@ -68,7 +68,7 @@
 
     public String validateEmail(String email) throws KustvaktException;
 
-    public Map<String, Object> validateMap(Map<String, Object> map)
+    public Map<String, String> validateMap(Map<String, String> map)
             throws KustvaktException;
 
     public String validateString(String input) throws KustvaktException;
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java b/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java
index c21d941..7b8c58a 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/db/PersistenceClient.java
@@ -43,7 +43,7 @@
         this.schema = schema;
     }
 
-    public abstract boolean checkDatabase() throws Exception;
+    public abstract boolean checkDatabase();
 
     public abstract void createDatabase() throws IOException;
 
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java b/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
index e509b61..cfa4c99 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/db/ResourceOperationIface.java
@@ -41,4 +41,6 @@
 
     int deleteAll() throws KustvaktException;
 
+    int size() throws KustvaktException;
+
 }
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 9f412b1..f5679c8 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
@@ -96,7 +96,7 @@
     }
 
     @Override
-    public Map<String, Object> validateMap(Map<String, Object> map)
+    public Map<String, String> validateMap(Map<String, String> map)
             throws KustvaktException {
         return null;
     }
diff --git a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/KustvaktEncryption.java b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/KustvaktEncryption.java
index 47c3033..ee8b49b 100644
--- a/src/main/java/de/ids_mannheim/korap/interfaces/defaults/KustvaktEncryption.java
+++ b/src/main/java/de/ids_mannheim/korap/interfaces/defaults/KustvaktEncryption.java
@@ -25,7 +25,6 @@
 import java.security.SecureRandom;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 
 public class KustvaktEncryption implements EncryptionIface {
@@ -280,27 +279,27 @@
     }
 
     @Override
-    public Map<String, Object> validateMap(Map<String, Object> map)
+    public Map<String, String> validateMap(Map<String, String> map)
             throws KustvaktException {
-        Map<String, Object> safeMap = new HashMap<>();
+        Map<String, String> safeMap = new HashMap<>();
         if (map != null) {
-            for (Map.Entry<String, Object> entry : map.entrySet()) {
-                Object value = null;
-                if (entry.getValue() instanceof String) {
-                    value = validateString((String) entry.getValue());
+            for (Map.Entry<String, String> entry : map.entrySet()) {
+                //                String value = null;
+                //                if (entry.getValue() instanceof String) {
+                String value = validateString(entry.getValue());
 
-                }else if (entry.getValue() instanceof List) {
-                    List list = (List) entry.getValue();
-                    for (Object v : list) {
-                        if (v instanceof String)
-                            validateString((String) v);
-                    }
-
-                    if (((List) entry.getValue()).size() == 1)
-                        value = list.get(0);
-                    else
-                        value = list;
-                }
+                //                }else if (entry.getValue() instanceof List) {
+                //                    List list = (List) entry.getValue();
+                //                    for (Object v : list) {
+                //                        if (v instanceof String)
+                //                            validateString((String) v);
+                //                    }
+                //
+                //                    if (((List) entry.getValue()).size() == 1)
+                //                        value = list.get(0);
+                //                    else
+                //                        value = list;
+                //                }
                 safeMap.put(entry.getKey(), value);
             }
         }
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyBuilder.java b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyBuilder.java
index 4fb533b..06af664 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyBuilder.java
@@ -11,6 +11,8 @@
 import de.ids_mannheim.korap.security.SecurityPolicy;
 import de.ids_mannheim.korap.user.User;
 
+import java.util.Arrays;
+
 /**
  * @author hanl
  * @date 14/04/2014
@@ -128,26 +130,21 @@
         if (this.rel == null)
             this.rel = Relation.AND;
 
+        System.out.println("CREATING RESOURCES " + Arrays.asList(resources));
+        System.out.println("RESOURCES LENGTH " + resources.length);
         for (int idx = 0; idx < this.resources.length; idx++) {
-            if (parents[idx] != null)
-                resources[idx].setParentID(parents[idx].getPersistentID());
-            SecurityManager manager = SecurityManager
-                    .register(resources[idx], user);
+            try {
+                System.out.println("ITERATING OVER ARRAY " + idx);
+                if (parents[idx] != null)
+                    resources[idx].setParentID(parents[idx].getPersistentID());
+                System.out.println("RUNNING REGISTERING SERVICE ON RESOURCE "
+                        + resources[idx]);
+                SecurityManager manager = SecurityManager
+                        .register(resources[idx], user);
 
-            if (rel.equals(Relation.AND)) {
-                SecurityPolicy policy = new SecurityPolicy()
-                        .setConditions(this.conditions)
-                        .setTarget(resources[idx]).addPermission(permissions)
-                        .setCreator(this.user.getId());
-
-                if (this.context != null)
-                    policy.setContext(this.context);
-
-                manager.addPolicy(policy);
-
-            }else if (rel.equals(Relation.OR)) {
-                for (PolicyCondition c : this.conditions) {
-                    SecurityPolicy policy = new SecurityPolicy().addCondition(c)
+                if (rel.equals(Relation.AND)) {
+                    SecurityPolicy policy = new SecurityPolicy()
+                            .setConditions(this.conditions)
                             .setTarget(resources[idx])
                             .addPermission(permissions)
                             .setCreator(this.user.getId());
@@ -155,18 +152,35 @@
                     if (this.context != null)
                         policy.setContext(this.context);
 
-                    //                    if (this.settings != null) {
-                    //                        ParameterSettingsHandler settings = this.settings
-                    //                                .get(c.getSpecifier());
-                    //                        if (settings != null) {
-                    //                            // fixme: context setting overlap!
-                    //                            policy.setContext(settings.getContext());
-                    //                            manager.addPolicy(policy, settings.getParameters());
-                    //                            continue;
-                    //                        }
-                    //                    }
                     manager.addPolicy(policy);
+
+                }else if (rel.equals(Relation.OR)) {
+                    for (PolicyCondition c : this.conditions) {
+                        SecurityPolicy policy = new SecurityPolicy()
+                                .addCondition(c).setTarget(resources[idx])
+                                .addPermission(permissions)
+                                .setCreator(this.user.getId());
+
+                        if (this.context != null)
+                            policy.setContext(this.context);
+
+                        //todo: ???
+                        //                    if (this.settings != null) {
+                        //                        ParameterSettingsHandler settings = this.settings
+                        //                                .get(c.getSpecifier());
+                        //                        if (settings != null) {
+                        //                            // fixme: context setting overlap!
+                        //                            policy.setContext(settings.getContext());
+                        //                            manager.addPolicy(policy, settings.getParameters());
+                        //                            continue;
+                        //                        }
+                        //                    }
+                        manager.addPolicy(policy);
+                    }
                 }
+            }catch (KustvaktException e) {
+                System.out.println("IF ERROR, LET OTHER RESOURCES RUN ANYWAY!");
+                e.printStackTrace();
             }
         }
     }
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
index 378f087..57c6fe2 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/PolicyDao.java
@@ -686,6 +686,7 @@
                 // that as checkup (may also be manageable via triggers)
                 //                if (this.jdbcTemplate
                 //                        .queryForObject(select, param, Integer.class) == 0)
+                System.out.println("PARAMETER MAP " + param.getValues());
                 sources[idx] = param;
             }
 
@@ -694,8 +695,11 @@
             return this.jdbcTemplate.batchUpdate(insert, sources);
         }catch (DataAccessException e) {
             jlog.error("Operation (INSERT) not possible for '{}' for user '{}'",
-                    condition.toString(), usernames);
-            throw new KustvaktException(e, StatusCodes.CONNECTION_ERROR);
+                    condition.toString(), usernames, e);
+            throw new KustvaktException(
+                    "Operation (INSERT) not possible for '" + condition
+                            .toString() + "' for user '" + usernames + "'", e,
+                    StatusCodes.CONNECTION_ERROR);
         }
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java b/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
index 8fe09ad..f3226ec 100644
--- a/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
+++ b/src/main/java/de/ids_mannheim/korap/security/ac/SecurityManager.java
@@ -277,7 +277,7 @@
 
                 jlog.info("Creating Access Control structure for resource '"
                         + resource.getPersistentID() + "@" + resource.getId()
-                        + "'");
+                        + "', name: " + resource.getName());
                 // storing resource is called twice. first when this is register and later in idsbootstrap to create cstorage entry. how to unify this?
                 ResourceOperationIface iface = p.handlers
                         .get(resource.getClass());
@@ -379,6 +379,11 @@
             }
         }
         this.policies[0].add(policy);
+        try {
+            Thread.sleep(5);
+        }catch (InterruptedException e) {
+            e.printStackTrace();
+        }
     }
 
     public void deletePolicies()
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/APIAuthentication.java b/src/main/java/de/ids_mannheim/korap/security/auth/APIAuthentication.java
index 13e383d..d59e503 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/APIAuthentication.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/APIAuthentication.java
@@ -11,10 +11,9 @@
 import de.ids_mannheim.korap.user.TokenContext;
 import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.utils.StringUtils;
+import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
 
 import java.text.ParseException;
 import java.util.Map;
@@ -25,6 +24,9 @@
 public class APIAuthentication implements AuthenticationIface {
 
     private JWTSigner signedToken;
+    private Cache invalided = CacheManager.getInstance()
+            .getCache("id_tokens_inv");
+    private Cache id_tokens = CacheManager.getInstance().getCache("id_tokens");
 
     public APIAuthentication(KustvaktConfiguration bconfig) {
         KustvaktConfiguration config = bconfig;
@@ -32,22 +34,31 @@
                 config.getIssuer(), config.getTokenTTL());
     }
 
-    @Cacheable(value = "id_tokens", key = "#authToken")
+    //    @Cacheable(value = "id_tokens", key = "#authToken")
+    // todo: test
     @Override
     public TokenContext getUserStatus(String authToken)
             throws KustvaktException {
-        try {
-            authToken = StringUtils.stripTokenType(authToken);
-            TokenContext c = signedToken.getTokenContext(authToken);
-            c.setTokenType(Attributes.API_AUTHENTICATION);
-            return c;
-        }catch (JOSEException | ParseException e) {
-            throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT);
-        }
+        TokenContext context;
+        Element e = id_tokens.get(authToken);
+        Element ein = invalided.get(authToken);
+        if (e == null && ein == null) {
+            try {
+                authToken = StringUtils.stripTokenType(authToken);
+                context = signedToken.getTokenContext(authToken);
+                context.setTokenType(Attributes.API_AUTHENTICATION);
+            }catch (JOSEException | ParseException ex) {
+                throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT);
+            }
+        }else if (ein == null) {
+            context = (TokenContext) e.getObjectValue();
+        }else
+            throw new KustvaktException(StatusCodes.EXPIRED);
+        return context;
     }
 
     @Override
-    public TokenContext createUserSession(User user, Map<String, Object> attr)
+    public TokenContext createUserSession(User user, Map<String, String> attr)
             throws KustvaktException {
         TokenContext c = new TokenContext();
         c.setUsername(user.getUsername());
@@ -59,17 +70,18 @@
         }
         c.setTokenType(Attributes.API_AUTHENTICATION);
         c.setToken(jwt.serialize());
-        CacheManager.getInstance().getCache("id_tokens")
-                .put(new Element(c.getToken(), c));
+        id_tokens.put(new Element(c.getToken(), c));
 
         return c;
     }
 
     // todo: cache and set expiration to token expiration. if token in that cache, it is not to be used anymore!
-    @CacheEvict(value = "id_tokens", key = "#token")
+    // fixme: dont use annotations but function calls
+    //    @CacheEvict(value = "id_tokens", key = "#token")
     @Override
     public void removeUserSession(String token) throws KustvaktException {
         // invalidate token!
+        invalided.put(new Element(token, null));
     }
 
     @Override
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/BasicHttpAuth.java b/src/main/java/de/ids_mannheim/korap/security/auth/BasicHttpAuth.java
index fda1e9f..4470a30 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/BasicHttpAuth.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/BasicHttpAuth.java
@@ -3,6 +3,7 @@
 import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.config.Scopes;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.interfaces.AuthenticationIface;
 import de.ids_mannheim.korap.interfaces.EncryptionIface;
 import de.ids_mannheim.korap.interfaces.db.EntityHandlerIface;
@@ -73,13 +74,14 @@
 
     // not supported!
     @Override
-    public TokenContext createUserSession(User user, Map<String, Object> attr)
+    public TokenContext createUserSession(User user, Map<String, String> attr)
             throws KustvaktException {
         return null;
     }
 
     @Override
     public void removeUserSession(String token) throws KustvaktException {
+        throw new KustvaktException(StatusCodes.NOT_SUPPORTED);
     }
 
     @Override
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 854c81d..4576435 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
@@ -74,8 +74,8 @@
                     "token type not defined or found", "token_type");
 
         TokenContext context = provider.getUserStatus(token);
-        if (!matchStatus(host, useragent, context))
-            provider.removeUserSession(token);
+        //        if (!matchStatus(host, useragent, context))
+        //            provider.removeUserSession(token);
         return context;
     }
 
@@ -127,7 +127,7 @@
      * @throws KustvaktException
      */
     public User authenticate(int type, String username, String password,
-            Map<String, Object> attributes) throws KustvaktException {
+            Map<String, String> attributes) throws KustvaktException {
         User user;
         switch (type) {
             case 1:
@@ -145,7 +145,7 @@
     }
 
     @CachePut(value = "users", key = "#user.getUsername()")
-    public TokenContext createTokenContext(User user, Map<String, Object> attr,
+    public TokenContext createTokenContext(User user, Map<String, String> attr,
             String provider_key) throws KustvaktException {
         AuthenticationIface provider = getProvider(provider_key,
                 Attributes.API_AUTHENTICATION);
@@ -156,12 +156,13 @@
         TokenContext context = provider.createUserSession(user, attr);
         if (context == null)
             throw new KustvaktException(StatusCodes.NOT_SUPPORTED);
-        context.setUserAgent((String) attr.get(Attributes.USER_AGENT));
+        context.setUserAgent(attr.get(Attributes.USER_AGENT));
         context.setHostAddress(Attributes.HOST);
         return context;
     }
 
     //todo: test
+    @Deprecated
     private boolean matchStatus(String host, String useragent,
             TokenContext context) {
         if (host.equals(context.getHostAddress())) {
@@ -171,7 +172,7 @@
         return false;
     }
 
-    private User authenticateShib(Map<String, Object> attributes)
+    private User authenticateShib(Map<String, String> attributes)
             throws KustvaktException {
         // todo use persistent id, since eppn is not unique
         String eppn = (String) attributes.get(Attributes.EPPN);
@@ -192,8 +193,8 @@
 
     //todo: what if attributes null?
     private User authenticate(String username, String password,
-            Map<String, Object> attr) throws KustvaktException {
-        Map<String, Object> attributes = crypto.validateMap(attr);
+            Map<String, String> attr) throws KustvaktException {
+        Map<String, String> attributes = crypto.validateMap(attr);
         String safeUS;
         User unknown;
         // just to make sure that the plain password does not appear anywhere in the logs!
@@ -310,7 +311,8 @@
                     null);
 
             if (provider == null) {
-
+                //todo:
+                return;
             }
             provider.removeUserSession(context.getToken());
         }catch (KustvaktException e) {
@@ -455,9 +457,9 @@
      * @throws KustvaktException
      */
     //fixme: remove clientinfo object (not needed), use json representation to get stuff
-    public User createUserAccount(Map<String, Object> attributes,
+    public User createUserAccount(Map<String, String> attributes,
             boolean conf_required) throws KustvaktException {
-        Map<String, Object> safeMap = crypto.validateMap(attributes);
+        Map<String, String> safeMap = crypto.validateMap(attributes);
         if (safeMap.get(Attributes.USERNAME) == null || ((String) safeMap
                 .get(Attributes.USERNAME)).isEmpty())
             throw new KustvaktException(StatusCodes.ILLEGAL_ARGUMENT,
@@ -504,11 +506,11 @@
     }
 
     //todo:
-    private ShibUser createShibbUserAccount(Map<String, Object> attributes)
+    private ShibUser createShibbUserAccount(Map<String, String> attributes)
             throws KustvaktException {
         jlog.debug("creating shibboleth user account for user attr: {}",
                 attributes);
-        Map<String, Object> safeMap = crypto.validateMap(attributes);
+        Map<String, String> safeMap = crypto.validateMap(attributes);
 
         //todo eppn non-unique.join with idp or use persistent_id as username identifier
         ShibUser user = User.UserFactory
@@ -517,7 +519,7 @@
                         (String) safeMap.get(Attributes.CN));
         user.setAffiliation((String) safeMap.get(Attributes.EDU_AFFIL));
         UserDetails det = UserDetails
-                .newDetailsIterator(new HashMap<String, Object>());
+                .newDetailsIterator(new HashMap<String, String>());
         user.setDetails(det);
         user.setSettings(new UserSettings());
         user.setAccountCreation(TimeUtils.getNow().getMillis());
diff --git a/src/main/java/de/ids_mannheim/korap/security/auth/OpenIDconnectAuthentication.java b/src/main/java/de/ids_mannheim/korap/security/auth/OpenIDconnectAuthentication.java
index 3f0ebe4..a1871c9 100644
--- a/src/main/java/de/ids_mannheim/korap/security/auth/OpenIDconnectAuthentication.java
+++ b/src/main/java/de/ids_mannheim/korap/security/auth/OpenIDconnectAuthentication.java
@@ -44,9 +44,9 @@
     }
 
     @Override
-    public TokenContext createUserSession(User user, Map<String, Object> attr)
+    public TokenContext createUserSession(User user, Map<String, String> attr)
             throws KustvaktException {
-        String cl_secret = (String) attr.get(Attributes.CLIENT_SECRET);
+        String cl_secret = attr.get(Attributes.CLIENT_SECRET);
         if (cl_secret == null)
             throw new KustvaktException(StatusCodes.REQUEST_INVALID);
         attr.remove(cl_secret);
diff --git a/src/main/java/de/ids_mannheim/korap/user/TokenContext.java b/src/main/java/de/ids_mannheim/korap/user/TokenContext.java
index e07cdda..9eeff3a 100644
--- a/src/main/java/de/ids_mannheim/korap/user/TokenContext.java
+++ b/src/main/java/de/ids_mannheim/korap/user/TokenContext.java
@@ -6,8 +6,10 @@
 import lombok.AccessLevel;
 import lombok.Data;
 import lombok.Getter;
+import lombok.Setter;
 import org.joda.time.DateTime;
 
+import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
@@ -17,7 +19,7 @@
  * @date 27/01/2014
  */
 @Data
-public class TokenContext implements java.security.Principal {
+public class TokenContext implements java.security.Principal, Serializable {
 
     /**
      * session relevant data. Are never persisted into a database
@@ -30,7 +32,8 @@
     private boolean secureRequired;
 
     @Getter(AccessLevel.PRIVATE)
-    private Map<String, Object> parameters;
+    @Setter(AccessLevel.PRIVATE)
+    private Map<String, String> parameters;
     private String hostAddress;
     private String userAgent;
 
@@ -51,7 +54,7 @@
         return m;
     }
 
-    public Map<String, Object> params() {
+    public Map<String, String> params() {
         return new HashMap<>(parameters);
     }
 
@@ -68,6 +71,11 @@
         this.parameters.put(key, value);
     }
 
+    public void addParams(Map<String, Object> map) {
+        for (Map.Entry<String, Object> e : map.entrySet())
+            this.parameters.put(e.getKey(), String.valueOf(e.getValue()));
+    }
+
     public void removeContextParameter(String key) {
         this.parameters.remove(key);
     }
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserDetails.java b/src/main/java/de/ids_mannheim/korap/user/UserDetails.java
index d76790e..4051436 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserDetails.java
+++ b/src/main/java/de/ids_mannheim/korap/user/UserDetails.java
@@ -40,29 +40,29 @@
         setPrivateUsage(true);
     }
 
-    public static UserDetails newDetailsIterator(Map<String, Object> d) {
+    public static UserDetails newDetailsIterator(Map<String, String> d) {
         UserDetails details = new UserDetails();
-        Map<String, Object> detailMap = new CaseInsensitiveMap(d);
+        Map<String, String> detailMap = new CaseInsensitiveMap(d);
 
         if (!detailMap.isEmpty()) {
-            details.setFirstName((String) detailMap.get(Attributes.FIRSTNAME));
-            details.setLastName((String) detailMap.get(Attributes.LASTNAME));
-            details.setPhone((String) detailMap.get(Attributes.PHONE));
-            details.setEmail((String) detailMap.get(Attributes.EMAIL));
-            details.setGender((String) detailMap.get(Attributes.GENDER));
-            details.setAddress((String) detailMap.get(Attributes.ADDRESS));
-            details.setCountry((String) detailMap.get(Attributes.COUNTRY));
-            details.setInstitution(
-                    (String) detailMap.get(Attributes.INSTITUTION));
+            details.setFirstName(detailMap.get(Attributes.FIRSTNAME));
+            details.setLastName(detailMap.get(Attributes.LASTNAME));
+            details.setPhone(detailMap.get(Attributes.PHONE));
+            details.setEmail(detailMap.get(Attributes.EMAIL));
+            details.setGender(detailMap.get(Attributes.GENDER));
+            details.setAddress(detailMap.get(Attributes.ADDRESS));
+            details.setCountry(detailMap.get(Attributes.COUNTRY));
+            details.setInstitution(detailMap.get(Attributes.INSTITUTION));
             details.setPrivateUsage(
                     detailMap.get(Attributes.PRIVATE_USAGE) == null ?
                             true :
-                            (Boolean) detailMap.get(Attributes.PRIVATE_USAGE));
+                            Boolean.valueOf(
+                                    detailMap.get(Attributes.PRIVATE_USAGE)));
         }
         return details;
     }
 
-    public void updateDetails(Map<String, Object> d) {
+    public void updateDetails(Map<String, String> d) {
         Map<String, Object> detailMap = new CaseInsensitiveMap(d);
 
         if (!detailMap.isEmpty()) {
diff --git a/src/main/java/de/ids_mannheim/korap/user/UserSettings.java b/src/main/java/de/ids_mannheim/korap/user/UserSettings.java
index c16f617..7295505 100644
--- a/src/main/java/de/ids_mannheim/korap/user/UserSettings.java
+++ b/src/main/java/de/ids_mannheim/korap/user/UserSettings.java
@@ -196,29 +196,43 @@
     }
 
     public void updateStringSettings(Map<String, String> m) {
-        this.setFileNameForExport(m.get(Attributes.FILENAME_FOR_EXPORT));
+        if (m.get(Attributes.FILENAME_FOR_EXPORT) != null)
+            this.setFileNameForExport(m.get(Attributes.FILENAME_FOR_EXPORT));
         //        this.setItemForSimpleAnnotation(
         //                Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
-        this.setLeftContextItemForExport(
-                m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
-        this.setLeftContextSizeForExport(Integer.valueOf(
-                m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
-        this.setLocale(m.get(Attributes.LOCALE));
-        this.setLeftContextItem(m.get(Attributes.LEFT_CONTEXT_ITEM));
-        this.setLeftContextSize(
-                Integer.valueOf(m.get(Attributes.LEFT_CONTEXT_SIZE)));
-        this.setRightContextItem(m.get(Attributes.RIGHT_CONTEXT_ITEM));
-        this.setRightContextItemForExport(
-                m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
-        this.setRightContextSize(
-                Integer.valueOf(m.get(Attributes.RIGHT_CONTEXT_SIZE)));
-        this.setRightContextSizeForExport(Integer.valueOf(
-                m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
-        this.setSelectedCollection(m.get(Attributes.SELECTED_COLLECTION));
-        this.setQueryLanguage(m.get(Attributes.QUERY_LANGUAGE));
-        this.setPageLength(Integer.valueOf(m.get(Attributes.PAGE_LENGTH)));
-        this.setMetadataQueryExpertModus(
-                Boolean.valueOf(m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
+        if (m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT) != null)
+            this.setLeftContextItemForExport(
+                    m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
+        if (m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT) != null)
+            this.setLeftContextSizeForExport(Integer.valueOf(
+                    m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
+        if (m.get(Attributes.LOCALE) != null)
+            this.setLocale(m.get(Attributes.LOCALE));
+        if (m.get(Attributes.LEFT_CONTEXT_ITEM) != null)
+            this.setLeftContextItem(m.get(Attributes.LEFT_CONTEXT_ITEM));
+        if (m.get(Attributes.LEFT_CONTEXT_SIZE) != null)
+            this.setLeftContextSize(
+                    Integer.valueOf(m.get(Attributes.LEFT_CONTEXT_SIZE)));
+        if (m.get(Attributes.RIGHT_CONTEXT_ITEM) != null)
+            this.setRightContextItem(m.get(Attributes.RIGHT_CONTEXT_ITEM));
+        if (m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT) != null)
+            this.setRightContextItemForExport(
+                    m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
+        if (m.get(Attributes.RIGHT_CONTEXT_SIZE) != null)
+            this.setRightContextSize(
+                    Integer.valueOf(m.get(Attributes.RIGHT_CONTEXT_SIZE)));
+        if (m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT) != null)
+            this.setRightContextSizeForExport(Integer.valueOf(
+                    m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
+        if (m.get(Attributes.SELECTED_COLLECTION) != null)
+            this.setSelectedCollection(m.get(Attributes.SELECTED_COLLECTION));
+        if (m.get(Attributes.QUERY_LANGUAGE) != null)
+            this.setQueryLanguage(m.get(Attributes.QUERY_LANGUAGE));
+        if (m.get(Attributes.PAGE_LENGTH) != null)
+            this.setPageLength(Integer.valueOf(m.get(Attributes.PAGE_LENGTH)));
+        if (m.get(Attributes.METADATA_QUERY_EXPERT_MODUS) != null)
+            this.setMetadataQueryExpertModus(Boolean.valueOf(
+                    m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
         //        this.setSearchSettingsTab(
         //                Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
         //        this.setSelectedGraphType(
@@ -226,57 +240,85 @@
         //        this.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
         //        this.setSelectedViewForSearchResults(
         //                m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
-
-        this.setCollectData(
-                Boolean.valueOf(m.get(Attributes.COLLECT_AUDITING_DATA)));
-        this.setDefaultPOSfoundry(m.get(Attributes.DEFAULT_POS_FOUNDRY));
-        this.setDefaultLemmafoundry(m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
-        this.setDefaultConstfoundry(m.get(Attributes.DEFAULT_CONST_FOUNDRY));
-        this.setDefaultRelfoundry(m.get(Attributes.DEFAULT_REL_FOUNDRY));
+        if (m.get(Attributes.COLLECT_AUDITING_DATA) != null)
+            this.setCollectData(
+                    Boolean.valueOf(m.get(Attributes.COLLECT_AUDITING_DATA)));
+        if (m.get(Attributes.DEFAULT_POS_FOUNDRY) != null)
+            this.setDefaultPOSfoundry(m.get(Attributes.DEFAULT_POS_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_LEMMA_FOUNDRY) != null)
+            this.setDefaultLemmafoundry(
+                    m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_CONST_FOUNDRY) != null)
+            this.setDefaultConstfoundry(
+                    m.get(Attributes.DEFAULT_CONST_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_REL_FOUNDRY) != null)
+            this.setDefaultRelfoundry(m.get(Attributes.DEFAULT_REL_FOUNDRY));
     }
 
     public void updateObjectSettings(Map<String, Object> m) {
-        this.setFileNameForExport(
-                (String) m.get(Attributes.FILENAME_FOR_EXPORT));
+        if (m.get(Attributes.FILENAME_FOR_EXPORT) != null)
+            this.setFileNameForExport(
+                    (String) m.get(Attributes.FILENAME_FOR_EXPORT));
         //        this.setItemForSimpleAnnotation(
-        //                (Integer) m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION));
-        this.setLeftContextItemForExport(
-                (String) m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
-        this.setLeftContextSizeForExport(
-                (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT));
-        this.setLocale((String) m.get(Attributes.LOCALE));
-        this.setLeftContextItem((String) m.get(Attributes.LEFT_CONTEXT_ITEM));
-        this.setLeftContextSize((Integer) m.get(Attributes.LEFT_CONTEXT_SIZE));
-        this.setRightContextItem((String) m.get(Attributes.RIGHT_CONTEXT_ITEM));
-        this.setRightContextItemForExport(
-                (String) m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
-        this.setRightContextSize(
-                (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE));
-        this.setRightContextSizeForExport(
-                (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT));
-        this.setSelectedCollection(
-                (String) m.get(Attributes.SELECTED_COLLECTION));
-        this.setQueryLanguage((String) m.get(Attributes.QUERY_LANGUAGE));
-        this.setPageLength((Integer) m.get(Attributes.PAGE_LENGTH));
-        this.setMetadataQueryExpertModus(
-                (Boolean) m.get(Attributes.METADATA_QUERY_EXPERT_MODUS));
+        //                Integer.valueOf(m.get(Attributes.ITEM_FOR_SIMPLE_ANNOTATION)));
+        if (m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT) != null)
+            this.setLeftContextItemForExport(
+                    (String) m.get(Attributes.LEFT_CONTEXT_ITEM_FOR_EXPORT));
+        if (m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT) != null)
+            this.setLeftContextSizeForExport(Integer.valueOf(
+                    (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE_FOR_EXPORT)));
+        if (m.get(Attributes.LOCALE) != null)
+            this.setLocale((String) m.get(Attributes.LOCALE));
+        if (m.get(Attributes.LEFT_CONTEXT_ITEM) != null)
+            this.setLeftContextItem(
+                    (String) m.get(Attributes.LEFT_CONTEXT_ITEM));
+        if (m.get(Attributes.LEFT_CONTEXT_SIZE) != null)
+            this.setLeftContextSize(Integer.valueOf(
+                    (Integer) m.get(Attributes.LEFT_CONTEXT_SIZE)));
+        if (m.get(Attributes.RIGHT_CONTEXT_ITEM) != null)
+            this.setRightContextItem(
+                    (String) m.get(Attributes.RIGHT_CONTEXT_ITEM));
+        if (m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT) != null)
+            this.setRightContextItemForExport(
+                    (String) m.get(Attributes.RIGHT_CONTEXT_ITEM_FOR_EXPORT));
+        if (m.get(Attributes.RIGHT_CONTEXT_SIZE) != null)
+            this.setRightContextSize(Integer.valueOf(
+                    (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE)));
+        if (m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT) != null)
+            this.setRightContextSizeForExport(Integer.valueOf(
+                    (Integer) m.get(Attributes.RIGHT_CONTEXT_SIZE_FOR_EXPORT)));
+        if (m.get(Attributes.SELECTED_COLLECTION) != null)
+            this.setSelectedCollection(
+                    (String) m.get(Attributes.SELECTED_COLLECTION));
+        if (m.get(Attributes.QUERY_LANGUAGE) != null)
+            this.setQueryLanguage((String) m.get(Attributes.QUERY_LANGUAGE));
+        if (m.get(Attributes.PAGE_LENGTH) != null)
+            this.setPageLength((Integer) m.get(Attributes.PAGE_LENGTH));
+        if (m.get(Attributes.METADATA_QUERY_EXPERT_MODUS) != null)
+            this.setMetadataQueryExpertModus(Boolean.valueOf(
+                    (Boolean) m.get(Attributes.METADATA_QUERY_EXPERT_MODUS)));
         //        this.setSearchSettingsTab(
-        //                (Integer) m.get(Attributes.SEARCH_SETTINGS_TAB));
+        //                Integer.valueOf(m.get(Attributes.SEARCH_SETTINGS_TAB)));
         //        this.setSelectedGraphType(
-        //                (Integer) m.get(Attributes.SELECTED_GRAPH_TYPE));
-        //        this.setSelectedSortType((String) m.get(Attributes.SELECTED_SORT_TYPE));
+        //                Integer.valueOf(m.get(Attributes.SELECTED_GRAPH_TYPE)));
+        //        this.setSelectedSortType(m.get(Attributes.SELECTED_SORT_TYPE));
         //        this.setSelectedViewForSearchResults(
-        //                (String) m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
-
-        this.setCollectData((Boolean) m.get(Attributes.COLLECT_AUDITING_DATA));
-        this.setDefaultPOSfoundry(
-                (String) m.get(Attributes.DEFAULT_POS_FOUNDRY));
-        this.setDefaultLemmafoundry(
-                (String) m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
-        this.setDefaultConstfoundry(
-                (String) m.get(Attributes.DEFAULT_CONST_FOUNDRY));
-        this.setDefaultRelfoundry(
-                (String) m.get(Attributes.DEFAULT_REL_FOUNDRY));
+        //                m.get(Attributes.SELECTED_VIEW_FOR_SEARCH_RESULTS));
+        if (m.get(Attributes.COLLECT_AUDITING_DATA) != null)
+            this.setCollectData(
+                    (Boolean) m.get(Attributes.COLLECT_AUDITING_DATA));
+        if (m.get(Attributes.DEFAULT_POS_FOUNDRY) != null)
+            this.setDefaultPOSfoundry(
+                    (String) m.get(Attributes.DEFAULT_POS_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_LEMMA_FOUNDRY) != null)
+            this.setDefaultLemmafoundry(
+                    (String) m.get(Attributes.DEFAULT_LEMMA_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_CONST_FOUNDRY) != null)
+            this.setDefaultConstfoundry(
+                    (String) m.get(Attributes.DEFAULT_CONST_FOUNDRY));
+        if (m.get(Attributes.DEFAULT_REL_FOUNDRY) != null)
+            this.setDefaultRelfoundry(
+                    (String) m.get(Attributes.DEFAULT_REL_FOUNDRY));
     }
 
     //loadSubTypes from configuration?
@@ -294,7 +336,7 @@
         this.setRightContextSizeForExport(100);
         // persistent id for wikipedia!
         // fixme: deprecation warning!
-         this.setSelectedCollection(
+        this.setSelectedCollection(
                 "ZGU0ZTllNTFkYzc3M2VhZmViYzdkYWE2ODI5NDc3NTk4NGQ1YThhOTMwOTNhOWYxNWMwN2M3Y2YyZmE3N2RlNQ==");
         this.setQueryLanguage("COSMAS2");
         this.setPageLength(25);
diff --git a/src/main/java/de/ids_mannheim/korap/utils/SqlBuilder.java b/src/main/java/de/ids_mannheim/korap/utils/SqlBuilder.java
index 8b22d25..d3b5028 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/SqlBuilder.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/SqlBuilder.java
@@ -48,6 +48,8 @@
     }
 
     public SqlBuilder params(String... values) {
+        if (values.length != fields.length)
+            return this;
         if (this.buffer.lastIndexOf("INSERT INTO") != -1) {
             this.buffer.append(" (");
             for (int i = 0; i < this.fields.length; i++) {
diff --git a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
index e8a6311..560970d 100644
--- a/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
+++ b/src/main/java/de/ids_mannheim/korap/utils/UserPropertyReader.java
@@ -76,7 +76,7 @@
             user.setPassword(pass);
         }else {
             user = User.UserFactory.getUser(username);
-            Map<String, Object> vals = new HashMap<>();
+            Map<String, String> vals = new HashMap<>();
             for (Map.Entry e : p.entrySet()) {
                 String key = e.getKey().toString().split("\\.", 2)[1];
                 vals.put(key, e.getValue().toString());
diff --git a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
index 880c9d9..8bdfb7d 100644
--- a/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
+++ b/src/main/java/de/ids_mannheim/korap/web/KustvaktBaseServer.java
@@ -5,7 +5,9 @@
 import com.sun.jersey.spi.container.servlet.ServletContainer;
 import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.config.KustvaktClassLoader;
+import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.web.service.BootupInterface;
 import lombok.Getter;
 import lombok.Setter;
@@ -28,6 +30,7 @@
 public class KustvaktBaseServer {
 
     public static void main(String[] args) throws Exception {
+        KustvaktConfiguration.loadLog4jLogger();
         KustvaktBaseServer server = new KustvaktBaseServer();
         KustvaktArgs kargs = server.readAttributes(args);
 
@@ -38,7 +41,7 @@
 
         kargs.setRootPackages(
                 new String[] { "de.ids_mannheim.korap.web.service.light" });
-        server.runPreStart();
+
         server.startServer(kargs);
     }
 
@@ -69,40 +72,50 @@
                     System.out.println(b.toString());
                     System.out.println();
                     break;
+                case "--init":
+                    kargs.init = true;
+                    break;
             }
         }
         return kargs;
     }
 
-    public static void runPreStart() {
+    public void runPreStart() {
         Set<Class<? extends BootupInterface>> set = KustvaktClassLoader
                 .loadSubTypes(BootupInterface.class);
 
         List<BootupInterface> list = new ArrayList<>(set.size());
 
-        for (Class cl : set) {
-            BootupInterface iface;
-            try {
-                iface = (BootupInterface) cl.newInstance();
-                if (iface.position() == -1 | iface.position() > set.size())
-                    list.add(iface);
-                else
-                    list.add(0, iface);
-            }catch (InstantiationException | IllegalAccessException e) {
-                continue;
+        PersistenceClient client = BeanConfiguration.getBeans()
+                .getPersistenceClient();
+        if (client.checkDatabase()) {
+            for (Class cl : set) {
+                BootupInterface iface;
+                try {
+                    iface = (BootupInterface) cl.newInstance();
+                    if (iface.position() == -1 | iface.position() > set.size())
+                        list.add(iface);
+                    else
+                        list.add(0, iface);
+                }catch (InstantiationException | IllegalAccessException e) {
+                    continue;
+                }
             }
-        }
-        System.out.println("Found boot loading interfaces: " + list);
-        for (BootupInterface iface : list) {
-            try {
-                iface.load();
-            }catch (KustvaktException e) {
-                // don't do anything!
+            System.out.println("Found boot loading interfaces: " + list);
+            for (BootupInterface iface : list) {
+                try {
+                    iface.load();
+                }catch (KustvaktException e) {
+                    // don't do anything!
+                }
             }
         }
     }
 
     protected void startServer(KustvaktArgs kargs) {
+        if (kargs.init)
+            runPreStart();
+
         if (kargs.port == -1)
             kargs.setPort(
                     BeanConfiguration.getBeans().getConfiguration().getPort());
@@ -161,6 +174,7 @@
         private int port;
         private SslContextFactory sslContext;
         private String[] rootPackages;
+        private boolean init;
 
         public KustvaktArgs() {
             this.port = -1;
@@ -168,6 +182,7 @@
             this.debug = false;
             this.config = null;
             this.properties = null;
+            this.init = false;
         }
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
index a4d753a..2982c8a 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/CollectionLoader.java
@@ -20,51 +20,52 @@
 
     @Override
     public void load() throws KustvaktException {
-        int uid = (Integer) KustvaktConfiguration.KUSTVAKT_USER
-                .get(Attributes.ID);
+        if (BeanConfiguration.hasContext()) {
+            CollectionDao dao = new CollectionDao(
+                    BeanConfiguration.getBeans().getPersistenceClient());
 
-        User user = User.UserFactory
-                .toUser(KustvaktConfiguration.KUSTVAKT_USER);
+            int uid = Integer.valueOf(
+                    KustvaktConfiguration.KUSTVAKT_USER.get(Attributes.ID));
 
-        //todo: load default collections!
-        CollectionQueryBuilder3 bui = new CollectionQueryBuilder3();
-        bui.addQuery("creationDate since 1775");
+            User user = User.UserFactory
+                    .toUser(KustvaktConfiguration.KUSTVAKT_USER);
 
-        VirtualCollection c1 = ResourceFactory
-                .createCollection("Weimarer Werke", bui.toJSON(), uid);
-        c1.setDescription("Goethe-Werke in Weimar (seit 1775)");
+            //todo: load default collections!
+            CollectionQueryBuilder3 bui = new CollectionQueryBuilder3();
+            bui.addQuery("creationDate since 1775");
 
-        bui = new CollectionQueryBuilder3();
-        bui.addQuery("textType = Aphorismus");
+            VirtualCollection c1 = ResourceFactory
+                    .createCollection("Weimarer Werke", bui.toJSON(), uid);
+            c1.setDescription("Goethe-Werke in Weimar (seit 1775)");
 
-        VirtualCollection c2 = ResourceFactory
-                .createCollection("Aphorismen", bui.toJSON(), uid);
-        c2.setDescription("Aphorismentexte Goethes");
+            bui = new CollectionQueryBuilder3();
+            bui.addQuery("textType = Aphorismus");
 
-        bui = new CollectionQueryBuilder3();
-        bui.addQuery("title ~ \"Werther\"");
+            VirtualCollection c2 = ResourceFactory
+                    .createCollection("Aphorismen", bui.toJSON(), uid);
+            c2.setDescription("Aphorismentexte Goethes");
 
-        VirtualCollection c3 = ResourceFactory
-                .createCollection("Werther", bui.toJSON(), uid);
-        c3.setDescription("Goethe - Die Leiden des jungen Werther");
+            bui = new CollectionQueryBuilder3();
+            bui.addQuery("title ~ \"Werther\"");
 
-        CollectionDao dao = new CollectionDao(
-                BeanConfiguration.getBeans().getPersistenceClient());
+            VirtualCollection c3 = ResourceFactory
+                    .createCollection("Werther", bui.toJSON(), uid);
+            c3.setDescription("Goethe - Die Leiden des jungen Werther");
 
-        dao.storeResource(c1, user);
-        dao.storeResource(c2, user);
-        dao.storeResource(c3, user);
+            dao.storeResource(c1, user);
+            dao.storeResource(c2, user);
+            dao.storeResource(c3, user);
 
-        PolicyBuilder b = new PolicyBuilder(user);
-        b.setPermissions(Permissions.PERMISSIONS.ALL);
-        b.setResources(c1, c2, c3);
-        b.setConditions("public");
-        b.create();
-
+            PolicyBuilder b = new PolicyBuilder(user);
+            b.setPermissions(Permissions.PERMISSIONS.ALL);
+            b.setResources(c1, c2, c3);
+            b.setConditions("public");
+            b.create();
+        }
     }
 
     @Override
     public int position() {
-        return 1;
+        return -1;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
index 29dc462..2a76686 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/PolicyLoader.java
@@ -26,35 +26,37 @@
 
     @Override
     public void load() throws KustvaktException {
-        PersistenceClient cl = BeanConfiguration.getBeans()
-                .getPersistenceClient();
-        Set<ResourceOperationIface> ifaces = new HashSet<>();
-        ifaces.add(new ResourceDao(cl));
-        ifaces.add(new CollectionDao(cl));
+        if (BeanConfiguration.hasContext()) {
+            PersistenceClient cl = BeanConfiguration.getBeans()
+                    .getPersistenceClient();
+            Set<ResourceOperationIface> ifaces = new HashSet<>();
+            ifaces.add(new ResourceDao(cl));
+            ifaces.add(new CollectionDao(cl));
 
-        SecurityManager.setProviders(new PolicyDao(cl),
-                BeanConfiguration.getBeans().getEncryption(), ifaces);
-        ResourceFinder.setProviders(new PolicyDao(cl));
+            SecurityManager.setProviders(new PolicyDao(cl),
+                    BeanConfiguration.getBeans().getEncryption(), ifaces);
+            ResourceFinder.setProviders(new PolicyDao(cl));
 
-        User user = User.UserFactory
-                .toUser(KustvaktConfiguration.KUSTVAKT_USER);
-        PolicyBuilder builder = new PolicyBuilder(user);
-        builder.addCondition("public");
-        builder.setResources(new Corpus("GOE", user.getId()));
-        builder.setPermissions(Permissions.PERMISSIONS.ALL);
-        builder.create();
+            User user = User.UserFactory
+                    .toUser(KustvaktConfiguration.KUSTVAKT_USER);
+            PolicyBuilder builder = new PolicyBuilder(user);
+            builder.addCondition("public");
+            builder.setResources(new Corpus("GOE", user.getId()));
+            builder.setPermissions(Permissions.PERMISSIONS.ALL);
+            builder.create();
 
-        // redundant if user is the user who created the condition for the resource
-        //        try {
-        //            ConditionManagement cm = new ConditionManagement(user);
-        ////            cm.addUser(user.getUsername(), new PolicyCondition("public"), true);
-        //        }catch (KustvaktException e) {
-        //            e.printStackTrace();
-        //        }
+            // redundant if user is the user who created the condition for the resource
+            //        try {
+            //            ConditionManagement cm = new ConditionManagement(user);
+            ////            cm.addUser(user.getUsername(), new PolicyCondition("public"), true);
+            //        }catch (KustvaktException e) {
+            //            e.printStackTrace();
+            //        }
+        }
     }
 
     @Override
     public int position() {
-        return -1;
+        return 1;
     }
 }
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java b/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
index 898b303..04ecd95 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/UserLoader.java
@@ -3,7 +3,6 @@
 import de.ids_mannheim.korap.config.BeanConfiguration;
 import de.ids_mannheim.korap.config.KustvaktConfiguration;
 import de.ids_mannheim.korap.exceptions.KustvaktException;
-import de.ids_mannheim.korap.handlers.EntityDao;
 
 /**
  * @author hanl
@@ -12,14 +11,7 @@
 public class UserLoader implements BootupInterface {
     @Override
     public void load() throws KustvaktException {
-        boolean r = BeanConfiguration.hasContext();
-        if (r) {
-            EntityDao dao = new EntityDao(
-                    BeanConfiguration.getBeans().getPersistenceClient());
-
-            if (dao.size() > 0)
-                return;
-
+        if (BeanConfiguration.hasContext()) {
             BeanConfiguration.getBeans().getAuthenticationManager()
                     .createUserAccount(KustvaktConfiguration.KUSTVAKT_USER,
                             false);
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
index a357c67..f53c816 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/AuthService.java
@@ -72,7 +72,6 @@
         return Response.ok(JsonUtils.toJSON(m)).build();
     }
 
-
     // fixme: moved to user
     @GET
     @Path("status")
@@ -109,10 +108,9 @@
         if (values[0].equalsIgnoreCase("null") | values[1]
                 .equalsIgnoreCase("null"))
             // is actual an invalid request
-            throw KustvaktResponseHandler
-                    .throwit(StatusCodes.REQUEST_INVALID);
+            throw KustvaktResponseHandler.throwit(StatusCodes.REQUEST_INVALID);
 
-        Map<String, Object> attr = new HashMap<>();
+        Map<String, String> attr = new HashMap<>();
         if (scopes != null && !scopes.isEmpty())
             attr.put(Attributes.SCOPES, scopes);
         attr.put(Attributes.HOST, host);
@@ -175,10 +173,9 @@
 
         if (values[0].equalsIgnoreCase("null") | values[1]
                 .equalsIgnoreCase("null"))
-            throw KustvaktResponseHandler
-                    .throwit(StatusCodes.REQUEST_INVALID);
+            throw KustvaktResponseHandler.throwit(StatusCodes.REQUEST_INVALID);
 
-        Map<String, Object> attr = new HashMap<>();
+        Map<String, String> attr = new HashMap<>();
         attr.put(Attributes.HOST, host);
         attr.put(Attributes.USER_AGENT, agent);
         TokenContext context;
@@ -207,7 +204,7 @@
         // the shibfilter decrypted the values
         // define default provider for returned access token strategy?!
 
-        Map<String, Object> attr = new HashMap<>();
+        Map<String, String> attr = new HashMap<>();
         attr.put(Attributes.HOST, host);
         attr.put(Attributes.USER_AGENT, agent);
 
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
index a73ec3a..11fc0b3 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/OAuthService.java
@@ -137,7 +137,7 @@
         // json format with scope callback parameter
         // todo: add other scopes as well!
         return Response.ok(JsonUtils.toJSON(Scopes
-                .mapOpenIDConnectScopes(scopes, user.getDetails()))).build();
+                .mapScopes(scopes, user.getDetails()))).build();
     }
 
     @GET
@@ -172,7 +172,7 @@
             @Context SecurityContext context,
             @HeaderParam(ContainerRequest.USER_AGENT) String agent,
             @HeaderParam(ContainerRequest.HOST) String host,
-            MultivaluedMap<String, Object> form)
+            MultivaluedMap<String, String> form)
             throws OAuthSystemException, URISyntaxException {
         // user needs to be authenticated to this service!
         TokenContext c = (TokenContext) context.getUserPrincipal();
@@ -184,7 +184,7 @@
                     new MD5Generator());
             User user;
 
-            Map<String, Object> attr = new HashMap<>();
+            Map<String, String> attr = new HashMap<>();
             attr.put(Attributes.HOST, host);
             attr.put(Attributes.USER_AGENT, agent);
             attr.put(Attributes.USERNAME, c.getUsername());
@@ -436,7 +436,7 @@
                         .entity(res.getBody()).build();
             }
 
-            Map<String, Object> attr = new HashMap<>();
+            Map<String, String> attr = new HashMap<>();
             attr.put(Attributes.HOST, host);
             attr.put(Attributes.USER_AGENT, agent);
             attr.put(Attributes.SCOPES,
diff --git a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
index dceb241..1b162dd 100644
--- a/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
+++ b/src/main/java/de/ids_mannheim/korap/web/service/full/UserService.java
@@ -12,7 +12,6 @@
 import de.ids_mannheim.korap.interfaces.AuthenticationManagerIface;
 import de.ids_mannheim.korap.user.*;
 import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.utils.KustvaktLogger;
 import de.ids_mannheim.korap.utils.StringUtils;
 import de.ids_mannheim.korap.utils.TimeUtils;
 import de.ids_mannheim.korap.web.KustvaktServer;
@@ -23,6 +22,7 @@
 import de.ids_mannheim.korap.web.utils.FormRequestWrapper;
 import de.ids_mannheim.korap.web.utils.KustvaktResponseHandler;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.*;
 import javax.ws.rs.core.*;
@@ -37,10 +37,9 @@
 @ResourceFilters({ PiwikFilter.class })
 public class UserService {
 
-    private static Logger error = KustvaktLogger
-            .getLogger(KustvaktLogger.ERROR_LOG);
-    private static Logger jlog = KustvaktLogger
-            .getLogger(KustvaktLogger.SECURITY_LOG);
+    private static Logger jlog = LoggerFactory.getLogger(UserService.class);
+    //    private static Logger jlog = KustvaktLogger
+    //            .getLogger(KustvaktLogger.SECURITY_LOG);
     private AuthenticationManagerIface controller;
 
     private
@@ -60,8 +59,8 @@
     public Response signUp(
             @HeaderParam(ContainerRequest.USER_AGENT) String agent,
             @HeaderParam(ContainerRequest.HOST) String host,
-            @Context Locale locale, MultivaluedMap form_values) {
-        Map<String, Object> wrapper = FormRequestWrapper
+            @Context Locale locale, MultivaluedMap<String, String> form_values) {
+        Map<String, String> wrapper = FormRequestWrapper
                 .toMap(form_values, true);
 
         wrapper.put(Attributes.HOST, host);
@@ -183,7 +182,7 @@
             builder.append(Attributes.QUERY_PARAM_USER).append("=")
                     .append(username);
         }catch (KustvaktException e) {
-            error.error("Eoxception encountered!", e);
+            jlog.error("Eoxception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
 
@@ -204,7 +203,7 @@
         try {
             controller.resetPassword(uri, username, passphrase);
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             return Response.notModified().build();
         }
         return Response.ok().build();
@@ -228,10 +227,8 @@
         }catch (KustvaktException e) {
             throw KustvaktResponseHandler.throwit(e);
         }
-        Map m = Scopes.mapOpenIDConnectScopes(scopes, user.getDetails());
-        m.put("scopes", scopes);
-
-        return Response.ok(JsonUtils.toJSON(m)).build();
+        Scopes m = Scopes.mapScopes(scopes, user.getDetails());
+        return Response.ok(m.toEntity()).build();
     }
 
     @GET
@@ -247,7 +244,7 @@
             controller.getUserSettings(user);
 
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
         return Response.ok(JsonUtils.toJSON(user.getSettings().toObjectMap()))
@@ -261,9 +258,9 @@
     @ResourceFilters({ AuthFilter.class, DefaultFilter.class,
             PiwikFilter.class })
     public Response updateSettings(@Context SecurityContext context,
-            @Context Locale locale, MultivaluedMap<String, Object> form) {
+            @Context Locale locale, MultivaluedMap<String, String> form) {
         TokenContext ctx = (TokenContext) context.getUserPrincipal();
-        Map<String, Object> settings = FormRequestWrapper.toMap(form, false);
+        Map<String, String> settings = FormRequestWrapper.toMap(form, false);
 
         try {
             User user = controller.getUser(ctx.getUsername());
@@ -274,12 +271,13 @@
             //            SecurityManager.findbyId(us.getDefaultLemmafoundry(), user, Foundry.class);
             //            SecurityManager.findbyId(us.getDefaultPOSfoundry(), user, Foundry.class);
             //            SecurityManager.findbyId(us.getDefaultRelfoundry(), user, Foundry.class);
-            us.updateObjectSettings(settings);
+            us.updateStringSettings(settings);
+
             controller.updateUserSettings(user, us);
             if (user.isDemo())
                 return Response.notModified().build();
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
 
@@ -298,7 +296,7 @@
             user = controller.getUser(ctx.getUsername());
             controller.getUserDetails(user);
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
 
@@ -314,7 +312,7 @@
             @Context Locale locale, MultivaluedMap form) {
         TokenContext ctx = (TokenContext) context.getUserPrincipal();
 
-        Map<String, Object> wrapper = FormRequestWrapper.toMap(form, true);
+        Map<String, String> wrapper = FormRequestWrapper.toMap(form, true);
 
         try {
             User user = controller.getUser(ctx.getUsername());
@@ -324,7 +322,7 @@
             if (user.isDemo())
                 return Response.notModified().build();
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
 
@@ -379,7 +377,7 @@
             //                        resources.toArray(new UserQuery[resources.size()]));
             //            }
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
         return Response.ok(JsonUtils.toJSON(add)).build();
@@ -396,7 +394,7 @@
                 return Response.notModified().build();
             controller.deleteAccount(user);
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
         return Response.ok().build();
@@ -418,7 +416,7 @@
             //todo:
             queryStr = "";
         }catch (KustvaktException e) {
-            error.error("Exception encountered!", e);
+            jlog.error("Exception encountered!", e);
             throw KustvaktResponseHandler.throwit(e);
         }
         return Response.ok(queryStr).build();
diff --git a/src/main/java/de/ids_mannheim/korap/web/utils/FormRequestWrapper.java b/src/main/java/de/ids_mannheim/korap/web/utils/FormRequestWrapper.java
index 6a07ba3..b688ab0 100644
--- a/src/main/java/de/ids_mannheim/korap/web/utils/FormRequestWrapper.java
+++ b/src/main/java/de/ids_mannheim/korap/web/utils/FormRequestWrapper.java
@@ -16,7 +16,7 @@
  */
 public class FormRequestWrapper extends HttpServletRequestWrapper {
 
-    private MultivaluedMap<String, Object> form;
+    private MultivaluedMap<String, String> form;
 
     /**
      * Constructs a request object wrapping the given request.
@@ -25,7 +25,7 @@
      * @throws IllegalArgumentException if the request is null
      */
     public FormRequestWrapper(HttpServletRequest request,
-            MultivaluedMap<String, Object> form) {
+            MultivaluedMap<String, String> form) {
         super(request);
         this.form = form;
     }
@@ -48,7 +48,7 @@
         return values;
     }
 
-    public Map<String, Object> singleValueMap() {
+    public Map<String, String> singleValueMap() {
         return toMap(this.form, false);
     }
 
@@ -57,13 +57,14 @@
      *               in value list and returns the result
      * @return key/value map
      */
-    public static Map<String, Object> toMap(MultivaluedMap<String, Object> form,
+    public static Map<String, String> toMap(MultivaluedMap<String, String> form,
             boolean strict) {
-        HashMap<String, Object> map = new HashMap<>();
+        HashMap<String, String> map = new HashMap<>();
         for (String key : form.keySet()) {
             if (strict && form.get(key).size() > 1)
                 continue;
             map.put(key, form.getFirst(key));
+
         }
         return map;
     }
@@ -73,7 +74,7 @@
     }
 
     public void put(String key, String... values) {
-        this.form.put(key, Arrays.<Object>asList(values));
+        this.form.put(key, Arrays.<String>asList(values));
     }
 
 }
diff --git a/src/main/resources/ehcache.xml b/src/main/resources/ehcache.xml
index 34f478c..4259339 100644
--- a/src/main/resources/ehcache.xml
+++ b/src/main/resources/ehcache.xml
@@ -2,6 +2,8 @@
          xsi:noNamespaceSchemaLocation='http://ehcache.org/ehcache.xsd'>
     <defaultCache eternal='true' overflowToDisk='false'/>
     <!--maxBytesLocalHeap="200M"-->
+    <diskStore path="./cache_store"/>
+
     <cache name="documents"
            timeToIdleSeconds="172800"
            eternal='false'
@@ -16,10 +18,19 @@
            overflowToDisk='false'/>
     <cache name='id_tokens'
            timeToIdleSeconds="172800"
-           eternal='false'
+           eternal='true'
+           maxElementsOnDisk="10000000"
            memoryStoreEvictionPolicy="LRU"
            maxEntriesLocalHeap="50"
-           overflowToDisk='false'/>
+           overflowToDisk='true'/>
+    <cache name='id_tokens_inv'
+           timeToIdleSeconds="322800"
+           eternal='true'
+           maxElementsOnDisk="10000000"
+           memoryStoreEvictionPolicy="LRU"
+           maxEntriesLocalHeap="50"
+           overflowToDisk='true'/>
+
     <cache name='auth_codes'
            timeToIdleSeconds="600"
            eternal='false'
diff --git a/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
index b8e0973..925a350 100644
--- a/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
+++ b/src/test/java/de/ids_mannheim/korap/config/ConfigTest.java
@@ -1,12 +1,19 @@
 package de.ids_mannheim.korap.config;
 
 import de.ids_mannheim.korap.exceptions.KustvaktException;
+import de.ids_mannheim.korap.handlers.CollectionDao;
+import de.ids_mannheim.korap.resources.VirtualCollection;
+import de.ids_mannheim.korap.security.ac.ResourceFinder;
+import de.ids_mannheim.korap.user.User;
 import de.ids_mannheim.korap.utils.ServiceVersion;
 import de.ids_mannheim.korap.utils.TimeUtils;
 import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 
+import java.util.Set;
+
 /**
  * @author hanl
  * @date 02/09/2015
@@ -18,10 +25,33 @@
         BeanConfiguration.closeApplication();
     }
 
-
-    @Test
+    @Before
     public void create() {
         BeanConfiguration.loadClasspathContext("default-config.xml");
+        //        PersistenceClient cl = BeanConfiguration.getBeans()
+        //                .getPersistenceClient();
+        //        Set<ResourceOperationIface> ifaces = new HashSet<>();
+        //        ifaces.add(new ResourceDao(cl));
+        //        ifaces.add(new CollectionDao(cl));
+        //
+        //        SecurityManager.setProviders(new PolicyDao(cl),
+        //                BeanConfiguration.getBeans().getEncryption(), ifaces);
+        //        ResourceFinder.setProviders(new PolicyDao(cl));
+        TestHelper.runBootInterfaces();
+    }
+
+    @Test
+    public void testCollectionLoader() throws KustvaktException {
+        CollectionDao dao = new CollectionDao(
+                BeanConfiguration.getBeans().getPersistenceClient());
+        int size = dao.size();
+        Assert.assertNotEquals("Is not supposed to be zero", size, 0);
+        Assert.assertEquals("wrong size", size, 3);
+
+        Set<VirtualCollection> set = ResourceFinder.search(User.UserFactory
+                        .toUser(KustvaktConfiguration.KUSTVAKT_USER),
+                VirtualCollection.class);
+        System.out.println("RESULTING SET: " + set);
     }
 
     @Test
diff --git a/src/test/java/de/ids_mannheim/korap/config/UserTestHelper.java b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
similarity index 65%
rename from src/test/java/de/ids_mannheim/korap/config/UserTestHelper.java
rename to src/test/java/de/ids_mannheim/korap/config/TestHelper.java
index 91bc3fe..2d599f1 100644
--- a/src/test/java/de/ids_mannheim/korap/config/UserTestHelper.java
+++ b/src/test/java/de/ids_mannheim/korap/config/TestHelper.java
@@ -5,6 +5,7 @@
 import de.ids_mannheim.korap.interfaces.db.PersistenceClient;
 import de.ids_mannheim.korap.user.Attributes;
 import de.ids_mannheim.korap.user.User;
+import de.ids_mannheim.korap.web.service.BootupInterface;
 import org.junit.Assert;
 import org.springframework.jdbc.core.RowCallbackHandler;
 import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -19,12 +20,12 @@
  * @author hanl
  * @date 16/10/2015
  */
-public class UserTestHelper {
+public class TestHelper {
 
     private static final String[] credentials = new String[] { "test1",
             "testPass2015" };
 
-    public static boolean setup() {
+    public static boolean setupUser() {
         boolean r = BeanConfiguration.hasContext();
         if (r) {
             EntityHandlerIface dao = BeanConfiguration.getBeans()
@@ -46,7 +47,7 @@
         return r;
     }
 
-    public static boolean drop() {
+    public static boolean dropUser() {
         boolean r = BeanConfiguration.hasContext();
         if (r) {
             EntityHandlerIface dao = BeanConfiguration.getBeans()
@@ -61,7 +62,7 @@
         return r;
     }
 
-    public static boolean truncateAll() {
+    public static boolean truncateAllUsers() {
         boolean r = BeanConfiguration.hasContext();
         if (r) {
             String sql = "SELECT Concat('TRUNCATE TABLE ', TABLE_NAME) FROM INFORMATION_SCHEMA.TABLES";
@@ -85,11 +86,46 @@
         return r;
     }
 
-    public static final String[] getCredentials() {
+    public static final String[] getUserCredentials() {
         return Arrays.copyOf(credentials, 2);
     }
 
-    private UserTestHelper() {
+
+    public static void runBootInterfaces() {
+        Set<Class<? extends BootupInterface>> set = KustvaktClassLoader
+                .loadSubTypes(BootupInterface.class);
+
+        List<BootupInterface> list = new ArrayList<>(set.size());
+
+        PersistenceClient client = BeanConfiguration.getBeans()
+                .getPersistenceClient();
+        if (client.checkDatabase()) {
+            for (Class cl : set) {
+                BootupInterface iface;
+                try {
+                    iface = (BootupInterface) cl.newInstance();
+                    if (iface.position() == -1 | iface.position() > set.size())
+                        list.add(iface);
+                    else
+                        list.add(0, iface);
+                }catch (InstantiationException | IllegalAccessException e) {
+                    continue;
+                }
+            }
+            System.out.println("Found boot loading interfaces: " + list);
+            for (BootupInterface iface : list) {
+                try {
+                    iface.load();
+                }catch (KustvaktException e) {
+                    // don't do anything!
+                }
+            }
+        }
+    }
+
+
+
+    private TestHelper() {
     }
 
 }
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
index f45108a..1356a58 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/KustvaktResourceServiceTest.java
@@ -3,10 +3,10 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.ClientResponse;
 import de.ids_mannheim.korap.config.BeanConfiguration;
+import de.ids_mannheim.korap.config.TestHelper;
 import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
 import de.ids_mannheim.korap.user.Attributes;
 import de.ids_mannheim.korap.utils.JsonUtils;
-import de.ids_mannheim.korap.web.KustvaktBaseServer;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -24,7 +24,7 @@
                 "de.ids_mannheim.korap.web.filter",
                 "de.ids_mannheim.korap.web.utils");
 
-        KustvaktBaseServer.runPreStart();
+        TestHelper.runBootInterfaces();
     }
 
     @AfterClass
diff --git a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
index 0afd8ee..576eee0 100644
--- a/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
+++ b/src/test/java/de/ids_mannheim/korap/web/service/OAuth2EndpointTest.java
@@ -3,7 +3,7 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.sun.jersey.api.client.ClientResponse;
 import de.ids_mannheim.korap.config.BeanConfiguration;
-import de.ids_mannheim.korap.config.UserTestHelper;
+import de.ids_mannheim.korap.config.TestHelper;
 import de.ids_mannheim.korap.security.auth.BasicHttpAuth;
 import de.ids_mannheim.korap.user.Attributes;
 import de.ids_mannheim.korap.utils.JsonUtils;
@@ -21,7 +21,7 @@
 
     @AfterClass
     public static void close() {
-        UserTestHelper.drop();
+        TestHelper.dropUser();
         BeanConfiguration.closeApplication();
     }
 
@@ -32,8 +32,8 @@
                 "de.ids_mannheim.korap.web.filter",
                 "de.ids_mannheim.korap.web.utils");
 
-        UserTestHelper.setup();
-        credentials = UserTestHelper.getCredentials();
+        TestHelper.setupUser();
+        credentials = TestHelper.getUserCredentials();
     }
 
 //    @Test