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 99b4372..9ae312b 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
@@ -3,6 +3,7 @@
 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.config.QueryBuilderUtil;
 import de.ids_mannheim.korap.exceptions.KorAPException;
 import de.ids_mannheim.korap.exceptions.StatusCodes;
 import de.ids_mannheim.korap.query.serialize.MetaQueryBuilder;
@@ -10,7 +11,6 @@
 import de.ids_mannheim.korap.resource.RewriteProcessor;
 import de.ids_mannheim.korap.utils.CollectionQueryBuilder;
 import de.ids_mannheim.korap.utils.KorAPLogger;
-import de.ids_mannheim.korap.utils.StringUtils;
 import de.ids_mannheim.korap.web.ClientsHandler;
 import de.ids_mannheim.korap.web.SearchKrill;
 import de.ids_mannheim.korap.web.TRACE;
@@ -20,7 +20,7 @@
 import javax.ws.rs.*;
 import javax.ws.rs.core.*;
 import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 /**
@@ -76,16 +76,13 @@
         QuerySerializer ss = new QuerySerializer().setQuery(q, ql, v);
 
         MetaQueryBuilder meta = new MetaQueryBuilder();
-        if (pageIndex != null)
-            meta.addEntry("startIndex", pageIndex);
+        meta.addEntry("startIndex", pageIndex);
         if (pageIndex == null && startPage != null)
             meta.addEntry("startPage", startPage);
-        if (pageLength != null)
-            meta.addEntry("count", pageLength);
-        if (context != null)
-            meta.setSpanContext(context);
+        meta.addEntry("count", pageLength);
+        meta.setSpanContext(context);
         meta.addEntry("cutOff", cutoff);
-        ss.addMeta(meta);
+        ss.setMeta(meta);
         //todo: test this
         ss.setCollection(cq);
         return Response.ok(processor.process(ss.toJSON())).build();
@@ -122,12 +119,12 @@
 
         String result;
         QuerySerializer serializer = new QuerySerializer().setQuery(q, ql, v);
-        MetaQueryBuilder meta = new MetaQueryBuilder();
-        meta.fillMeta(pageIndex, pageInteger, pageLength, ctx, cutoff);
+        MetaQueryBuilder meta = QueryBuilderUtil
+                .defaultMetaBuilder(pageIndex, pageInteger, pageLength, ctx,
+                        cutoff);
+        serializer.setMeta(meta);
         // fixme: should only apply to CQL queries per default!
         //        meta.addEntry("itemsPerResource", 1);
-        serializer.addMeta(meta);
-
         if (cq != null)
             serializer.setCollection(cq);
 
@@ -191,13 +188,15 @@
         KustvaktConfiguration.BACKENDS eng = BeanConfiguration
                 .getConfiguration().chooseBackend(engine);
         raw = raw == null ? false : raw;
-        MetaQueryBuilder meta = new MetaQueryBuilder();
+        MetaQueryBuilder meta = QueryBuilderUtil
+                .defaultMetaBuilder(pageIndex, pageInteger, pageLength, ctx,
+                        cutoff);
         if (!raw) {
             QuerySerializer s = new QuerySerializer().setQuery(query, ql, v);
-            meta.fillMeta(pageIndex, pageInteger, pageLength, ctx, cutoff);
+
             // should only apply to CQL queries
             //                meta.addEntry("itemsPerResource", 1);
-            s.addMeta(meta);
+            s.setMeta(meta);
             query = processor.process(s.toJSON());
         }
         String result;
@@ -242,7 +241,7 @@
         return Response.ok(stats).build();
     }
 
-    //fixme: only allowed for corpus?!
+
     @GET
     @Path("/corpus/{id}/{docid}/{rest}/matchInfo")
     public Response getMatchInfo(@PathParam("id") String id,
@@ -250,46 +249,24 @@
             @QueryParam("foundry") Set<String> foundries,
             @QueryParam("layer") Set<String> layers,
             @QueryParam("spans") Boolean spans) {
-        spans = spans != null ? spans : false;
         String matchid = searchKrill.getMatchId(id, docid, rest);
+        List<String> f_list = null;
+        List<String> l_list = null;
+        if (layers != null && !layers.isEmpty())
+            l_list = new ArrayList<>(layers);
 
-        if (layers == null || layers.isEmpty())
-            layers = new HashSet<>();
+        if (foundries != null && !foundries.isEmpty() && !foundries
+                .contains("*"))
+            f_list = new ArrayList<>(foundries);
 
         boolean match_only = foundries == null || foundries.isEmpty();
-
         String results;
-        // fixme: checks for policy matching
-        // fixme: currently disabled, due to mishab in foundry/layer spec
-        // fixme:
-        if (foundries != null && foundries.size() > 1000) {
-            Set<String> f_list = new HashSet<>();
-            Set<String> l_list = new HashSet<>();
+        if (match_only)
+            results = searchKrill.getMatch(matchid);
+        else
+            results = searchKrill
+                    .getMatch(matchid, f_list, l_list, spans, false, true);
 
-            for (String spl : new ArrayList<>(foundries)) {
-
-                String[] sep = StringUtils.splitAnnotations(spl);
-                if (spl != null) {
-                    f_list.add(sep[0]);
-                    l_list.add(sep[1]);
-                }
-                results = searchKrill
-                        .getMatch(matchid, new ArrayList<>(f_list),
-                                new ArrayList<>(l_list), spans, false, true);
-            }
-        }
-        try {
-            if (!match_only)
-                results = searchKrill
-                        .getMatch(matchid, new ArrayList<>(foundries),
-                                new ArrayList<>(layers), spans, false, true);
-            else
-                results = searchKrill.getMatch(matchid);
-        }catch (Exception e) {
-            KorAPLogger.ERROR_LOGGER.error("Exception encountered!", e);
-            throw KustvaktResponseHandler
-                    .throwit(StatusCodes.ILLEGAL_ARGUMENT, e.getMessage(), "");
-        }
         return Response.ok(results).build();
     }
 }
