diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
index a582540..243a4d7 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/JsonGenerator.java
@@ -126,10 +126,7 @@
         }
         Map<String, Object> requestMap = ast.getRequestMap();
         try {
-            List meta_re = serializer.serializeResources(parents);
-
-//            JsonNode node = mapper.valueToTree(parents);
-//            JsonNode arr = node.get("meta");
+            List<Map> meta_re = serializer.serializeResources(parents);
             requestMap.put("meta", meta_re);
             requestMap = serializer.addParameters(requestMap, page, num,
                     cli, cri, cls, crs);
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
index bd55641..4b74ce4 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
@@ -1,5 +1,8 @@
 package de.ids_mannheim.korap.query.serialize;
 
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.IOException;
@@ -12,6 +15,7 @@
  * @author hanl
  * @date 04/12/2013
  */
+@Deprecated
 public class MetaCollectionSerializer {
 
     public String meta1 = "{\n" +
@@ -85,15 +89,19 @@
     }
 
     //resources must be ordered: 0 without parent, 1 has 0 as parent, etc.
-    public List<ArrayList> serializeResource(List<String> r_queries) throws IOException {
+    public List<Map> serializeResource(List<String> r_queries) throws IOException {
+        JsonFactory factory = mapper.getFactory();
         List parids = new ArrayList<>();
         for (String query : r_queries) {
-            ArrayList m = mapper.readValue(query, ArrayList.class);
-            parids.add(m);
+            JsonParser jp = factory.createParser(query);
+            JsonNode m = jp.readValueAsTree();
+            for (JsonNode n : m)
+                parids.add(mapper.treeToValue(n, Map.class));
         }
         return parids;
     }
 
+    @Deprecated
     private Map<String, String> getParents(String id) {
         Map<String, String> cursor = getResource(id);
         Map<String, String> parents = new HashMap<>();
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
new file mode 100644
index 0000000..3547d82
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
@@ -0,0 +1,286 @@
+package de.ids_mannheim.korap.query.serialize;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Multimap;
+
+import java.io.IOException;
+import java.util.*;
+
+/**
+ * @author hanl
+ * @date 06/12/2013
+ */
+public class MetaQuery {
+
+    private JsonFactory factory;
+    private MetaTypes types;
+    private ObjectMapper serialzer;
+    private List<Map> rq;
+    private List<Map> mfil;
+    private List<Map> mext;
+    private Multimap<Integer, Integer> track;
+
+    public MetaQuery() {
+        this.serialzer = new ObjectMapper();
+        this.rq = new ArrayList<>();
+        this.mfil = new ArrayList<>();
+        this.mext = new ArrayList<>();
+        this.factory = serialzer.getFactory();
+        this.types = new MetaTypes();
+        this.track = ArrayListMultimap.create();
+    }
+
+    public MetaQuery addResource(String query) throws IOException {
+        JsonParser jp = factory.createParser(query);
+        JsonNode m = jp.readValueAsTree();
+        for (JsonNode n : m)
+            this.rq.add(serialzer.treeToValue(n, Map.class));
+        return this;
+    }
+
+    public MetaQuery addResources(List<String> queries) throws IOException {
+        for (String query : queries) {
+            JsonParser jp = factory.createParser(query);
+            JsonNode m = jp.readValueAsTree();
+            for (JsonNode n : m)
+                this.rq.add(serialzer.treeToValue(n, Map.class));
+        }
+        return this;
+    }
+
+    public MetaQuery addMetaFilter(Map<String, String> queries) {
+        //single is redundant!
+        boolean single = true;
+        boolean multypes = queries.keySet().size() > 1;
+        String def_key = null;
+        if (queries.size() > 1)
+            single = false;
+
+        List value = new ArrayList<>();
+        List<String> dates = new ArrayList<>();
+        for (String key : queries.keySet()) {
+            if (!multypes)
+                def_key = key;
+            if (queries.get(key).contains("~") | queries.get(key).contains(">") |
+                    queries.get(key).contains("<")) {
+                dates.add(queries.get(key));
+                continue;
+            }
+
+            Map term;
+            term = types.createTerm(key, null, queries.get(key).trim(), null);
+            value.add(term);
+        }
+
+        String[] proc = processDates(dates);
+        int idx = 3;
+        if (proc[0] != null && proc[0].equals("r")) {
+            Map term1 = types.createTerm(proc[1], "korap:date");
+            Map term2 = types.createTerm(proc[2], "korap:date");
+            Map group = types.createGroup("between", "pubDate", Arrays.asList(term1, term2));
+            value.add(group);
+        } else if (proc[1] != null) {
+            Map term1 = types.createTerm(proc[1], "korap:date");
+            Map group = types.createGroup("since", "pubDate", Arrays.asList(term1));
+            value.add(group);
+        } else if (proc[2] != null) {
+            Map term1 = types.createTerm(proc[2], "korap:date");
+            Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
+            value.add(group);
+        }
+
+
+        for (int i = idx; i < proc.length; i++) {
+            if (proc[i] != null) {
+                Map term1 = types.createTerm(proc[i], "korap:date");
+                Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
+                value.add(group);
+            }
+        }
+
+        // todo: missing: - takes only one resource, but resources can be chained!
+        if (single)
+            Collections.addAll(this.mfil, types.createMetaFilter((Map) value.get(0)));
+        else {
+            Map group;
+            if (!multypes)
+                group = types.createGroup("and", def_key, value);
+            else
+                group = types.createGroup("and", null, value);
+            Collections.addAll(this.mfil, types.createMetaFilter(group));
+        }
+        return this;
+    }
+
+    public MetaQuery addMetaExtend(Map<String, String> queries) {
+        //single is redundant!
+        boolean single = true;
+        boolean multypes = queries.keySet().size() > 1;
+
+        //!an extend to a non-existing filter is not possible
+        if (this.mfil.isEmpty())
+            throw new IllegalArgumentException("Extending Query " +
+                    "cannot be added before Filter!");
+
+        String def_key = null;
+        if (queries.size() > 1)
+            single = false;
+
+        List value = new ArrayList<>();
+        List<String> dates = new ArrayList<>();
+        for (String key : queries.keySet()) {
+            if (!multypes)
+                def_key = key;
+            if (queries.get(key).contains("~") | queries.get(key).contains(">") |
+                    queries.get(key).contains("<")) {
+                dates.add(queries.get(key));
+                continue;
+            }
+            value.add(types.createTerm(key, null, queries.get(key).trim(), null));
+        }
+
+        String[] proc = processDates(dates);
+        int idx = 3;
+        if (proc[0] != null && proc[0].equals("r")) {
+            Map term1 = types.createTerm(proc[1], "korap:date");
+            Map term2 = types.createTerm(proc[2], "korap:date");
+            Map group = types.createGroup("between", "pubDate", Arrays.asList(term1, term2));
+            value.add(group);
+        } else if (proc[1] != null) {
+            Map term1 = types.createTerm(proc[1], "korap:date");
+            Map group = types.createGroup("since", "pubDate", Arrays.asList(term1));
+            value.add(group);
+        } else if (proc[2] != null) {
+            Map term1 = types.createTerm(proc[2], "korap:date");
+            Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
+            value.add(group);
+        }
+
+
+        for (int i = idx; i < proc.length; i++) {
+            if (proc[i] != null) {
+                Map term1 = types.createTerm(proc[i], "korap:date");
+                Map group = types.createGroup("until", "pubDate", Arrays.asList(term1));
+                value.add(group);
+            }
+        }
+        // todo: missing: - takes only one resource, but resources can be chained!
+        if (single)
+            Collections.addAll(this.mext, types.createMetaExtend((Map) value.get(0)));
+        else {
+            Map group;
+            if (!multypes)
+                group = types.createGroup("and", def_key, value);
+            else
+                group = types.createGroup("and", null, value);
+            Collections.addAll(this.mext, types.createMetaExtend(group));
+        }
+        track.put(this.mfil.size() - 1, this.mext.size() - 1);
+
+        return this;
+    }
+
+    public MetaQuery addMetaFilter(String attr, String val) {
+        Map y = new HashMap<>();
+        y.put(attr, val);
+        return addMetaFilter(y);
+    }
+
+    public MetaQuery addMetaExtend(String attr, String val) {
+        Map y = new HashMap<>();
+        y.put(attr, val);
+        return addMetaExtend(y);
+    }
+
+    private String[] processDates(List<String> dates) {
+        if (dates.isEmpty())
+            return new String[3];
+        boolean range = false;
+        String[] el = new String[dates.size() + 3];
+        int idx = 3;
+        for (String value : dates) {
+            if (value.contains("<")) {
+                String[] sp = value.split("<");
+                el[1] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
+            } else if (value.contains(">")) {
+                String[] sp = value.split(">");
+                el[2] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
+            } else if (value.contains("~")) {
+                range = true;
+                String[] sp = value.split("~");
+                el[1] = types.formatDate(Long.valueOf(sp[0]), MetaTypes.YMD);
+                el[2] = types.formatDate(Long.valueOf(sp[1]), MetaTypes.YMD);
+            } else {
+                el[idx] = types.formatDate(Long.valueOf(value), MetaTypes.YMD);
+                idx++;
+            }
+        }
+        if (range)
+            el[0] = "r";
+        return el;
+    }
+
+    public void clear() {
+        this.rq.clear();
+        this.mfil.clear();
+    }
+
+    @Deprecated
+    //todo: ordering irrelevant
+    private List<Map> join() {
+        List<Map> cursor = new ArrayList<>(this.rq);
+        List<Map> copy = new ArrayList<>();
+        if (!this.mext.isEmpty()) {
+            for (int idx = 0; idx < this.mfil.size(); idx++) {
+                copy.add(idx, this.mfil.get(idx));
+                if (!this.track.get(idx).isEmpty()) {
+                    Collection<Integer> ext = this.track.get(idx);
+                    for (Integer i : ext)
+                        copy.add(this.mext.get(i));
+                }
+            }
+        } else
+            copy = this.mfil;
+        cursor.addAll(copy);
+        return cursor;
+    }
+
+    private List<Map> join2() {
+        List<Map> cursor = new ArrayList<>(this.rq);
+        cursor.addAll(this.mfil);
+        cursor.addAll(this.mext);
+        return cursor;
+    }
+
+    public String stringify() {
+        try {
+            return serialzer.writeValueAsString(join2());
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+    public JsonNode jsonify() {
+        return serialzer.valueToTree(join2());
+    }
+
+    public String toMeta() {
+        Map meta = new LinkedHashMap();
+        meta.put("meta", join2());
+
+        try {
+            return serialzer.writeValueAsString(meta);
+        } catch (JsonProcessingException e) {
+            e.printStackTrace();
+            return "";
+        }
+    }
+
+
+}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
index ba0cd8a..5cca176 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
@@ -16,6 +16,7 @@
  * Date: 11/14/13
  * Time: 2:03 PM
  */
+@Deprecated
 public class MetaQuerySerializer {
 
 
@@ -68,7 +69,7 @@
         //single is redundant!
         boolean extend, single = true; //single = true;
         boolean multypes = queries.keySet().size() > 1;
-        List<Map> metavalue;
+        List<Map> metavalue = new ArrayList<>();
         String def_key = null;
         if (queries.size() > 1)
             single = false;
@@ -150,21 +151,22 @@
         // todo: missing: - takes only one resource, but resources can be chained!
         if (single) {
             if (extend)
-                metavalue = Arrays.asList(types.createMetaExtend((Map) value.get(0)));
+                Collections.addAll(metavalue, types.createMetaExtend((Map) value.get(0)));
             else
-                metavalue = Arrays.asList(types.createMetaFilter((Map) value.get(0)));
+                Collections.addAll(metavalue, types.createMetaFilter((Map) value.get(0)));
         } else {
             Map group;
             if (!multypes)
                 group = types.createGroup("and", def_key, value);
             else
                 group = types.createGroup("and", null, value);
+            //                metavalue = Arrays.asList(types.createMetaExtend(group));
             if (extend)
-                metavalue = Arrays.asList(types.createMetaExtend(group));
+                Collections.addAll(metavalue, types.createMetaExtend(group));
             else
-                metavalue = Arrays.asList(types.createMetaFilter(group));
+                Collections.addAll(metavalue, types.createMetaFilter(group));
         }
-        return new ArrayList<>(metavalue);
+        return metavalue;
     }
 
     //fixme: only allows for one until and since entry!!
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
index 8edf09d..f800e68 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
@@ -10,6 +10,7 @@
  * @author hanl
  * @date 05/12/2013
  */
+@Deprecated
 public class Serializer {
 
 
@@ -30,14 +31,21 @@
         return mapper.writeValueAsString(metas);
     }
 
-    public String stringify(List m_queries) throws JsonProcessingException {
-        return mapper.writeValueAsString(m_queries);
+    public String stringify(Object object) throws JsonProcessingException {
+        return mapper.writeValueAsString(object);
     }
 
-    public List<ArrayList> serializeResources(List<String> r_queries) throws IOException {
+    public List<Map> serializeResources(List<String> r_queries) throws IOException {
         return cs.serializeResource(r_queries);
     }
 
+    public String queryToMeta(String s) throws IOException {
+        Map f = new HashMap();
+        List e = mapper.readValue(s, ArrayList.class);
+        f.put("meta", e);
+        return mapper.writeValueAsString(f);
+    }
+
     public List<Map> serializeQueries(Map<String, String> queries, MetaQuerySerializer.TYPE type) {
         return qs.serializeQueries(queries, type);
     }
