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 a3921e3..8cd4d48 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
@@ -15,15 +15,13 @@
  */
 public class JsonGenerator {
 
-    ObjectMapper mapper;
-    AbstractSyntaxTree ast;
-    private Serializer serializer;
+    private ObjectMapper mapper;
+    private AbstractSyntaxTree ast;
     private org.slf4j.Logger log = LoggerFactory
             .getLogger(JsonGenerator.class);
 
     public JsonGenerator() {
         mapper = new ObjectMapper();
-        serializer = new Serializer();
     }
 
     /**
@@ -118,7 +116,7 @@
             throws IllegalArgumentException{
         if (ql.toLowerCase().equals("poliqarp")) {
             ast = new PoliqarpPlusTree(query);
-//		} else if (queryLanguage.equals("cosmas")) {
+//		} else if (ql.toLowerCase().equals("cosmas")) {
 //			ast = new CosmasTree(query);
         } else if (ql.toLowerCase().equals("poliqarpplus")) {
             ast = new PoliqarpPlusTree(query);
@@ -131,7 +129,7 @@
 
         try {
             requestMap.put("meta", metaQuery.raw());
-            requestMap = serializer.addParameters(requestMap, page, num,
+            requestMap = MetaQuery.addParameters(requestMap, page, num,
                     cli, cri, cls, crs);
             String res = mapper.writeValueAsString(requestMap);
             return res;
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
deleted file mode 100644
index 4b74ce4..0000000
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaCollectionSerializer.java
+++ /dev/null
@@ -1,143 +0,0 @@
-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;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author hanl
- * @date 04/12/2013
- */
-@Deprecated
-public class MetaCollectionSerializer {
-
-    public String meta1 = "{\n" +
-            "            \"@type\": \"korap:meta-filter\",\n" +
-            "            \"@id\": \"korap-filter#id-23\",\n" +
-            "            \"@value\": {\n" +
-            "                \"@type\": \"korap:term\",\n" +
-            "                \"@value\": \"wissenschaft\"\n" +
-            "            }\n" +
-            "        }\n";
-    public String meta2 = "{\n" +
-            "        \"@type\": \"korap:meta-filter\",\n" +
-            "        \"@id\": \"korap-filter#id-24\",\n" +
-            "        \"@value\": {\n" +
-            "            \"@type\": \"korap:group\",\n" +
-            "            \"relation\": \"and\",\n" +
-            "            \"operands\": [\n" +
-            "                {\n" +
-            "                    \"@type\": \"korap:term\",\n" +
-            "                    \"@field\": \"korap:field#pubPlace\",\n" +
-            "                    \"@value\": \"Erfurt\"\n" +
-            "                },\n" +
-            "                {\n" +
-            "                    \"@type\": \"korap:term\",\n" +
-            "                    \"@field\": \"korap:field#author\",\n" +
-            "                    \"@value\": \"Hesse\"\n" +
-            "                }\n" +
-            "            ]\n" +
-            "        }\n" +
-            "    }\n";
-    private MetaTypes types;
-    private ObjectMapper mapper;
-    private String meta3 = "{\n" +
-            "            \"@type\": \"korap:meta-extend\",\n" +
-            "            \"@id\": \"korap-filter#id-25\",\n" +
-            "            \"@value\": {\n" +
-            "                \"@type\": \"korap:group\",\n" +
-            "                \"relation\": \"and\",\n" +
-            "                \"operands\": [\n" +
-            "                    {\n" +
-            "                        \"@type\": \"korap:group\",\n" +
-            "                        \"relation\": \"comment: other values can be 'since','until' in combination with a simple korap:term\",\n" +
-            "                        \"relation\": \"between\",\n" +
-            "                        \"@field\": \"korap:field#pubDate\",\n" +
-            "                        \"operands\": [\n" +
-            "                            {\n" +
-            "                                \"@type\": \"korap:date\",\n" +
-            "                                \"@value\": \"comment: either long value or String representation '2013-04-29'\",\n" +
-            "                                \"@value\": \"2011\"\n" +
-            "                            },\n" +
-            "                            {\n" +
-            "                                \"@type\": \"korap:date\",\n" +
-            "                                \"@value\": \"2013\"\n" +
-            "                            }\n" +
-            "                        ]\n" +
-            "                    },\n" +
-            "                    {\n" +
-            "                        \"@type\": \"korap:term\",\n" +
-            "                        \"@field\": \"korap:field#textClass\",\n" +
-            "                        \"@value\": \"freizeit\"\n" +
-            "                    }\n" +
-            "                ]\n" +
-            "            }\n" +
-            "        }";
-    private Map<String, Map> tester;
-
-    public MetaCollectionSerializer() {
-        this.types = new MetaTypes();
-        this.mapper = new ObjectMapper();
-        this.tester = tester();
-    }
-
-    //resources must be ordered: 0 without parent, 1 has 0 as parent, etc.
-    public List<Map> serializeResource(List<String> r_queries) throws IOException {
-        JsonFactory factory = mapper.getFactory();
-        List parids = new ArrayList<>();
-        for (String query : r_queries) {
-            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<>();
-
-        parents.put(id, cursor.get("query"));
-        if (cursor.get("parent") != null && !cursor.get("parent").isEmpty())
-            parents.putAll(getParents(cursor.get("parent")));
-        return parents;
-    }
-
-    //todo: connection to database module!
-    public Map<String, String> getResource(String id) {
-        return tester.get(id);
-    }
-
-    private Map<String, Map> tester() {
-        Map<String, Map> l = new HashMap<>();
-        Map<String, String> s = new HashMap<>();
-        s.put("id", "23");
-        s.put("parent", "");
-        s.put("query", meta1);
-
-        Map<String, String> s2 = new HashMap<>();
-        s2.put("id", "24");
-        s2.put("parent", "23");
-        s2.put("query", meta2);
-
-        Map<String, String> s3 = new HashMap<>();
-        s3.put("id", "25");
-        s3.put("parent", "24");
-        s3.put("query", meta3);
-        l.put("23", s);
-        l.put("24", s2);
-        l.put("25", s3);
-        return l;
-    }
-
-
-}
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
index 310c5e4..aad96b6 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuery.java
@@ -23,7 +23,6 @@
     private List<Map> rq;
     private List<Map> mfil;
     private List<Map> mext;
-    private Multimap<Integer, Integer> track;
 
     public MetaQuery() {
         this.serialzer = new ObjectMapper();
@@ -32,7 +31,25 @@
         this.mext = new ArrayList<>();
         this.factory = serialzer.getFactory();
         this.types = new MetaTypes();
-        this.track = ArrayListMultimap.create();
+    }
+
+    public static Map addParameters(Map request, int page, int num, String cli, String cri,
+                                    int cls, int crs) {
+        Map ctx = new LinkedHashMap();
+        List left = new ArrayList();
+        left.add(cli);
+        left.add(cls);
+        List right = new ArrayList();
+        right.add(cri);
+        right.add(crs);
+        ctx.put("left", left);
+        ctx.put("right", right);
+
+        request.put("startPage", page);
+        request.put("count", num);
+        request.put("context", ctx);
+
+        return request;
     }
 
     public MetaQuery addResource(String query) {
@@ -54,6 +71,7 @@
         return this;
     }
 
+    // map can only have one key, value pair. thus, text class can only be added once. Multiple types are not possible!
     public MetaQuery addMetaFilter(Map<String, String> queries) {
         //single is redundant!
         boolean single = true;
@@ -162,7 +180,6 @@
             value.add(group);
         }
 
-
         for (int i = idx; i < proc.length; i++) {
             if (proc[i] != null) {
                 Map term1 = types.createTerm(proc[i], "korap:date");
@@ -181,8 +198,6 @@
                 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;
     }
 
@@ -230,27 +245,6 @@
         this.rq.clear();
         this.mfil.clear();
         this.mext.clear();
-        this.track.clear();
-    }
-
-    @Deprecated
-    //todo: ordering irrelevant
-    private List<Map> joinO() {
-        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> join() {
@@ -268,6 +262,7 @@
 
     /**
      * returns the meta query only and does not contain parent dependencies
+     *
      * @return
      */
     public String stringify() {
@@ -286,6 +281,7 @@
     /**
      * returns the List<Map> that contains all the meta queries and resource queries
      * added to the meta query container
+     *
      * @return
      */
     public List<Map> raw() {
@@ -310,5 +306,18 @@
         }
     }
 
+    private Multimap resEq(String queries) {
+        Multimap qmap = ArrayListMultimap.create();
+        String[] spl = queries.split(" AND ");
+        for (String query : spl) {
+            String[] q = query.split(":");
+            String attr = q[0];
+            String val = q[1];
+            qmap.put(attr, val);
+        }
+        return qmap;
+
+    }
+
 
 }
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
deleted file mode 100644
index 5cca176..0000000
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/MetaQuerySerializer.java
+++ /dev/null
@@ -1,219 +0,0 @@
-package de.ids_mannheim.korap.query.serialize;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * serializes a map of meta queries to JSON-LD. Currently this only works for simple mode queries (simple AND relation, except for date ranges)
- * Expert mode requires a full blown parser (since different combinations of OR and AND relations are possible)
- * also normalizes dates to year-month-day
- * <p/>
- * <p/>
- * User: hanl
- * Date: 11/14/13
- * Time: 2:03 PM
- */
-@Deprecated
-public class MetaQuerySerializer {
-
-
-    private String metaString = "{\n" +
-            "    \"meta\": [\n" +
-            "        {\n" +
-            "            \"@type\": \"korap:meta-filter\",\n" +
-            "            \"@value\": {\n" +
-            "                \"@type\": \"korap:group\",\n" +
-            "                \"relation\": \"and\",\n" +
-            "                \"operands\": [\n" +
-            "                    {\n" +
-            "                        \"@type\": \"korap:term\",\n" +
-            "                        \"field\": \"korap:field#author\",\n" +
-            "                        \"@value\": \"Goethe\"\n" +
-            "                    },\n" +
-            "                    {\n" +
-            "                        \"@type\": \"korap:group\",\n" +
-            "                        \"field\": \"korap:field#pubDate\",\n" +
-            "                        \"relation\": \"between\",\n" +
-            "                        \"operands\": [\n" +
-            "                            {\n" +
-            "                                \"@type\": \"korap:date\",\n" +
-            "                                \"@value\": \"2013-12-5\"\n" +
-            "                            },\n" +
-            "                            {\n" +
-            "                                \"@type\": \"korap:date\",\n" +
-            "                                \"@value\": \"2013-12-5\"\n" +
-            "                            }\n" +
-            "                        ]\n" +
-            "                    }\n" +
-            "                ]\n" +
-            "            }\n" +
-            "        }\n" +
-            "    ]\n" +
-            "}";
-    private ObjectMapper mapper;
-    private MetaTypes types;
-
-    public MetaQuerySerializer() {
-        this.mapper = new ObjectMapper();
-        this.types = new MetaTypes();
-    }
-
-    // construct pubdate range query as "pubDate:'<date>' ~ pubDate:'<date>'"
-    //todo: how to handle regex types?
-    // only handles AND relation between query attributes and values!
-    // value pair : pubdate=<date>, pubPlace=<place>, etc.
-    public List<Map> serializeQueries(Map<String, String> queries, TYPE type) {
-        //single is redundant!
-        boolean extend, single = true; //single = true;
-        boolean multypes = queries.keySet().size() > 1;
-        List<Map> metavalue = new ArrayList<>();
-        String def_key = null;
-        if (queries.size() > 1)
-            single = false;
-        switch (type) {
-            case EXTEND:
-                extend = true;
-                break;
-            default:
-                extend = false;
-                break;
-        }
-
-        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;
-            }
-
-//            if (queries.get(key).contains("~")) {
-//                dr = queries.get(key).split("~");
-//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
-//                Map td = types.createTerm(dr[1].trim(), "korap:date");
-//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-//                value.add(dg);
-//                continue;
-//            } else if (queries.get(key).contains(">")) {
-//                dr = queries.get(key).split(">");
-//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
-//                Map td = types.createTerm(dr[1].trim(), "korap:date");
-//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-//                value.add(dg);
-//                continue;
-//            } else if (queries.get(key).contains("<")) {
-//                dr = queries.get(key).split("<");
-//                Map fd = types.createTerm(dr[0].trim(), "korap:date");
-//                Map td = types.createTerm(dr[1].trim(), "korap:date");
-//                Map dg = types.createGroup("between", key, Arrays.asList(fd, td));
-//                value.add(dg);
-//                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) {
-            if (extend)
-                Collections.addAll(metavalue, types.createMetaExtend((Map) value.get(0)));
-            else
-                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)
-                Collections.addAll(metavalue, types.createMetaExtend(group));
-            else
-                Collections.addAll(metavalue, types.createMetaFilter(group));
-        }
-        return metavalue;
-    }
-
-    //fixme: only allows for one until and since entry!!
-    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 JsonNode jsonify(Map<String, String> queries) {
-        List s = serializeQueries(queries, TYPE.FILTER);
-        return mapper.valueToTree(s);
-    }
-
-    //todo: resource id must be added!
-    public String stringify(Map<String, String> queries, TYPE type) throws IOException {
-        Map f = new HashMap();
-        f.put("meta", serializeQueries(queries, type));
-        return mapper.writeValueAsString(f);
-    }
-
-
-    public enum TYPE {
-        EXTEND, FILTER
-    }
-
-
-}
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
deleted file mode 100644
index f800e68..0000000
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Serializer.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package de.ids_mannheim.korap.query.serialize;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * @author hanl
- * @date 05/12/2013
- */
-@Deprecated
-public class Serializer {
-
-
-    private MetaQuerySerializer qs;
-    private MetaCollectionSerializer cs;
-    private ObjectMapper mapper;
-
-
-    public Serializer() {
-        this.qs = new MetaQuerySerializer();
-        this.cs = new MetaCollectionSerializer();
-        this.mapper = new ObjectMapper();
-    }
-
-    public String serializeToMeta(List m_queries) throws JsonProcessingException {
-        Map metas = new HashMap();
-        metas.put("meta", m_queries);
-        return mapper.writeValueAsString(metas);
-    }
-
-    public String stringify(Object object) throws JsonProcessingException {
-        return mapper.writeValueAsString(object);
-    }
-
-    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);
-    }
-
-    public Map addParameters(Map request, int page, int num, String cli, String cri,
-                             int cls, int crs) {
-        Map ctx = new LinkedHashMap();
-        List left = new ArrayList();
-        left.add(cli);
-        left.add(cls);
-        List right = new ArrayList();
-        right.add(cri);
-        right.add(crs);
-        ctx.put("left", left);
-        ctx.put("right", right);
-
-        request.put("startPage", page);
-        request.put("count", num);
-        request.put("context", ctx);
-
-        return request;
-
-    }
-
-}
diff --git a/src/test/java/MetaQuerySerializationTest.java b/src/test/java/MetaQuerySerializationTest.java
index b32b8f6..4c3b355 100644
--- a/src/test/java/MetaQuerySerializationTest.java
+++ b/src/test/java/MetaQuerySerializationTest.java
@@ -1,14 +1,17 @@
 import com.fasterxml.jackson.core.JsonGenerationException;
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonMappingException;
-import de.ids_mannheim.korap.query.serialize.*;
+import de.ids_mannheim.korap.query.serialize.JsonGenerator;
+import de.ids_mannheim.korap.query.serialize.MetaQuery;
 import org.joda.time.DateTime;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
 
 import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * @author hanl
@@ -18,15 +21,6 @@
 @RunWith(JUnit4.class)
 public class MetaQuerySerializationTest {
 
-    private MetaQuerySerializer querySerializer;
-    private MetaCollectionSerializer collSerializer;
-    private Serializer ser;
-
-    public MetaQuerySerializationTest() {
-        querySerializer = new MetaQuerySerializer();
-        collSerializer = new MetaCollectionSerializer();
-        ser = new Serializer();
-    }
 
     @Test
     public void test() throws IOException {
@@ -34,16 +28,17 @@
         j.put("author", "Goethe");
         j.put("pubPlace", "Erfurt");
         j.put("textClass", "wissenschaft");
-        String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
-//        System.out.println("value reference " + s);
+        MetaQuery qu = new MetaQuery().addMetaFilter(j);
+        System.out.println("value reference " + qu.stringify());
+        System.out.println();
     }
 
     @Test
     public void testSingle() throws IOException {
         Map<String, String> j = new HashMap();
         j.put("textClass", "wissenschaft");
-        String s = querySerializer.stringify(j, MetaQuerySerializer.TYPE.FILTER);
-        System.out.println("------ TEXT SINGLE " + s);
+        MetaQuery query = new MetaQuery().addMetaFilter("textClass", "wissenschaft");
+        System.out.println("------ TEXT SINGLE " + query.stringify());
         System.out.println();
     }
 
@@ -53,8 +48,8 @@
         queries.put("pubDate", String.valueOf(new DateTime().getMillis()) + "~"
                 + String.valueOf(new DateTime().getMillis() + 2));
         queries.put("author", "Goethe");
-        String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
-        System.out.println("value until/since : " + f);
+        MetaQuery query = new MetaQuery().addMetaFilter(queries);
+        System.out.println("value until/since : " + query.stringify());
         System.out.println();
     }
 
@@ -63,8 +58,8 @@
         Map<String, String> queries = new LinkedHashMap<>();
         queries.put("pubDate", ">" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Hesse");
-        String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
-        System.out.println("value until : " + f);
+        MetaQuery query = new MetaQuery().addMetaFilter(queries);
+        System.out.println("value until : " + query.stringify());
         System.out.println();
     }
 
@@ -73,8 +68,8 @@
         Map<String, String> queries = new LinkedHashMap<>();
         queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Kafka");
-        String f = querySerializer.stringify(queries, MetaQuerySerializer.TYPE.FILTER);
-        System.out.println("value since : " + f);
+        MetaQuery query = new MetaQuery().addMetaFilter(queries);
+        System.out.println("value since : " + query.stringify());
         System.out.println();
     }
 
@@ -117,14 +112,11 @@
         Map<String, String> queries = new LinkedHashMap<>();
         queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Kafka");
-        List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
+        MetaQuery query = new MetaQuery().addMetaFilter(queries);
 
-        queries.clear();
-        queries.put("author", "Hesse");
+        query.addMetaExtend("author", "Hesse");
 
-        List f = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.EXTEND);
-        s.addAll(f);
-        System.out.println("--- ALL " + s);
+        System.out.println("--- ALL " + query.stringify());
         System.out.println();
 
     }
@@ -134,94 +126,49 @@
         Map<String, String> queries = new LinkedHashMap<>();
         queries.put("pubDate", "<" + String.valueOf(new DateTime().getMillis()));
         queries.put("author", "Kafka");
-        List s = querySerializer.serializeQueries(queries, MetaQuerySerializer.TYPE.FILTER);
-        System.out.println("array repres " + ser.serializeToMeta(s));
+        MetaQuery q = new MetaQuery().addMetaExtend(queries);
+        System.out.println("array repres " + q.toMeta());
         System.out.println();
     }
 
     @Test
     public void testCollections() throws IOException {
-        Map<String, String> query = new LinkedHashMap<>();
-        Serializer ser = new Serializer();
-        query.put("corpusID", "A00");
-        List<Map> l = ser.serializeQueries(query, MetaQuerySerializer.TYPE.FILTER);
-        query.clear();
-        query.put("corpusID", "A01");
-        List<Map> u = ser.serializeQueries(query, MetaQuerySerializer.TYPE.EXTEND);
-        l.addAll(u);
-        String val = ser.stringify(l);
-        System.out.println("results " + val);
+        MetaQuery q = new MetaQuery().addMetaFilter("corpusID", "A00");
+        q.addMetaExtend("corpusID", "A01");
+
+        System.out.println("results stringified " + q.stringify());
+        System.out.println("results to meta" + q.toMeta());
         System.out.println();
-
-
-        String meta = ser.queryToMeta(val);
-
-        System.out.println("meta query " + meta);
-//        List<String> list = new ArrayList<>();
-//        list.add(val);
-//        List s = collSerializer.serializeResource(list);
-        System.out.println("printable list ");
-        System.out.println();
-
     }
 
+    /**
+     * asserts equality. input should be equal to output,
+     * since there is no other metadata added to the meta query
+     *
+     * @throws IOException
+     */
     @Test
     public void testResources() throws IOException {
         String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
-        List s = new ArrayList();
-        s.add(meta);
-        List fin = ser.serializeResources(s);
-
-        String string = ser.serializeToMeta(fin);
-        System.out.println("meta string " + string);
-
+        MetaQuery q = new MetaQuery().addResource(meta);
+        org.junit.Assert.assertEquals("String should be empty", "", q.stringify());
+        System.out.println("meta string " + q.toMeta());
+        org.junit.Assert.assertEquals(meta, q.toMeta());
     }
 
     @Test
     public void testA00() throws IOException {
-        Map<String, String> query = new LinkedHashMap<>();
-        Serializer ser = new Serializer();
-        query.put("corpusID", "A00");
-        List<Map> l = ser.serializeQueries(query, MetaQuerySerializer.TYPE.FILTER);
-        query.clear();
-        query.put("corpusID", "A01");
-        List<Map> u = ser.serializeQueries(query, MetaQuerySerializer.TYPE.EXTEND);
-        l.addAll(u);
-        String val = ser.stringify(l);
-        List s = new ArrayList();
-        s.add(val);
-
-        List fin = ser.serializeResources(s);
-        System.out.println("A00 meta: " + fin);
-
+        MetaQuery q = new MetaQuery().addMetaExtend("corpusID", "A00").addMetaExtend("corpusID", "A01");
+        System.out.println("A meta: " + q.stringify());
+        System.out.println();
     }
 
-
     @Test
     public void testnewMetaQuery() throws IOException {
-        Map<String, String> qu = new LinkedHashMap<>();
-        Serializer ser = new Serializer();
-        qu.put("corpusID", "A00");
-        List<Map> l = ser.serializeQueries(qu, MetaQuerySerializer.TYPE.FILTER);
-        qu.clear();
-        qu.put("corpusID", "A01");
-        List<Map> u = ser.serializeQueries(qu, MetaQuerySerializer.TYPE.EXTEND);
-        l.addAll(u);
-        String val = ser.stringify(l);
-        List s = new ArrayList();
-        s.add(val);
-
-        List fin = ser.serializeResources(s);
-
-
-        System.out.println("=======   METAQUERY TESTING BEGIN =======");
-
-        MetaQuery query = new MetaQuery();
-        query.addMetaFilter("textClass", "wissenschaft");
-        query.addResources(s);
-        System.out.println("query "+ query.toMeta());
-        System.out.println("string "+ query.stringify());
-        System.out.println("=======   METAQUERY TESTING END =======");
+        String meta = "[{\"@type\":\"korap:meta-filter\",\"@value\":{\"@type\":\"korap:term\",\"@field\":\"korap:field#corpusID\",\"@value\":\"WPD\"}}]";
+        MetaQuery q = new MetaQuery().addResource(meta);
+        q.addMetaFilter("textClass", "wissenschaft");
+        System.out.println("meta string " + q.toMeta());
     }
 
 }
