diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
index 7b101a9..8a0a260 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AbstractQueryProcessor.java
@@ -2,7 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -19,40 +19,41 @@
  * JSON-LD tree for that query.
  * 
  * @author Joachim Bingel (bingel@ids-mannheim.de)
+ * @author Eliza Margaretha (margaretha@ids-mannheim.de)
  * @version 0.3.0
  * @since 0.1.0
  */
 public abstract class AbstractQueryProcessor {
 
-    Logger log;
+    protected Logger log;
     /**
      * The query string.
      */
-    String query;
+    protected String query;
     /**
      * Top-level map representing the whole request.
      */
-    LinkedHashMap<String, Object> requestMap = new LinkedHashMap<String, Object>();
+    protected Map<String, Object> requestMap = new HashMap<String, Object>();
     /**
      * Keeps track of open node categories.
      */
-    LinkedList<String> openNodeCats = new LinkedList<String>();
+    protected LinkedList<String> openNodeCats = new LinkedList<String>();
     /**
      * Keeps track of all visited nodes in a tree.
      */
-    List<ParseTree> visited = new ArrayList<ParseTree>();
+    protected List<ParseTree> visited = new ArrayList<ParseTree>();
     /**
      * Keeps track of active object, used for inserting new KoralQuery
      * objects
      * into last created objects.
      */
-    LinkedList<Map<String, Object>> objectStack = new LinkedList<Map<String, Object>>();
+    protected LinkedList<Map<String, Object>> objectStack = new LinkedList<Map<String, Object>>();
     /**
      * Keeps track of how many objects there are to pop after every
      * recursion
      * of {@link #processNode(ParseTree)}
      */
-    LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
+    protected LinkedList<Integer> objectsToPop = new LinkedList<Integer>();
     /**
      * If true, print debug statements
      */
@@ -62,34 +63,34 @@
      * Contains error arrays, consisting of an error code and a
      * message.
      */
-    private ArrayList<List<Object>> errors = new ArrayList<List<Object>>();
+    private List<List<Object>> errors = new ArrayList<List<Object>>();
     /**
      * Contains warning arrays, consisting of a warning code
      * (optional) and a
      * message.
      */
-    private ArrayList<List<Object>> warnings = new ArrayList<List<Object>>();
+    private List<List<Object>> warnings = new ArrayList<List<Object>>();
     /**
      * Contains other messages.
      */
-    private ArrayList<List<Object>> messages = new ArrayList<List<Object>>();
+    private List<List<Object>> messages = new ArrayList<List<Object>>();
     /**
      * Virtual collection queries.
      */
-    private LinkedHashMap<String, Object> collection = new LinkedHashMap<String, Object>();
+    private Object collection = new HashMap<String, Object>();
     /**
      * Holds information on displaying directives.
      */
-    private LinkedHashMap<String, Object> meta = new LinkedHashMap<String, Object>();
+    private Map<String, Object> meta = new HashMap<String, Object>();
     /**
      * Indicates which classes are to be highlighted in KWIC view.
      */
-    private ArrayList<Integer> highlightClasses = new ArrayList<Integer>();
+    private List<Integer> highlightClasses = new ArrayList<Integer>();
 
     /**
      * Indicates positions of alignment rulers in KWIC view.
      */
-    private ArrayList<List<Integer>> alignments = new ArrayList<List<Integer>>();
+    private List<List<Integer>> alignments = new ArrayList<List<Integer>>();
 
 
     AbstractQueryProcessor () {
@@ -99,7 +100,7 @@
         requestMap.put("warnings", warnings);
         requestMap.put("messages", messages);
         requestMap.put("collection", collection);
-        requestMap.put("query", new LinkedHashMap<String, Object>());
+        requestMap.put("query", new HashMap<String, Object>());
         requestMap.put("meta", meta);
     }
 
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
index 2611ab9..a5f269f 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessor.java
@@ -4,7 +4,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
-import java.util.Map;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -17,9 +16,8 @@
 import org.antlr.v4.runtime.Lexer;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.antlr.v4.runtime.tree.ParseTree;
-import org.apache.commons.lang.math.Fraction;
-import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import de.ids_mannheim.korap.query.object.KoralFrame;
 import de.ids_mannheim.korap.query.object.KoralOperation;
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
index 4667430..df1ca73 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CollectionQueryProcessor.java
@@ -13,7 +13,8 @@
 
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.LinkedHashMap;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -100,7 +101,7 @@
         if (nodeCat.equals("relation")) {
             String operator = getNodeCat(node.getChild(1).getChild(0)).equals(
                     "&") ? "and" : "or";
-            LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator
+            Map<String, Object> relationGroup = KoralObjectGenerator
                     .makeDocGroup(operator);
             putIntoSuperObject(relationGroup);
             objectStack.push(relationGroup);
@@ -112,14 +113,14 @@
             String field = fieldNode.getChild(0).toStringTree(parser);
             ParseTree operatorNode = getFirstChildWithCat(node, "operator");
             ParseTree valueNode = getFirstChildWithCat(node, "value");
-            LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
+            Map<String, Object> term = KoralObjectGenerator.makeDoc();
             term.put("key", field);
             term.putAll(parseValue(valueNode));
             String match = operatorNode.getText();
             term.put("match", "match:" + interpretMatchOperator(match));
 
             if (!checkOperatorValueConformance(term)) {
-                requestMap = new LinkedHashMap<String, Object>();
+                requestMap = new HashMap<String, Object>();
                 return;
             }
             //            if (QueryUtils.checkDateValidity(valueNode.getText())) {
@@ -140,13 +141,13 @@
             ParseTree dateOpNode = getFirstChildWithCat(node, "dateOp");
             ParseTree dateNode = getFirstChildWithCat(node, "date");
 
-            LinkedHashMap<String, Object> term = KoralObjectGenerator.makeDoc();
+            Map<String, Object> term = KoralObjectGenerator.makeDoc();
             term.put("key", field);
             term.putAll(parseValue(dateNode));
             String match = dateOpNode.getText();
             term.put("match", "match:" + interpretMatchOperator(match));
             if (!checkOperatorValueConformance(term)) {
-                requestMap = new LinkedHashMap<String, Object>();
+                requestMap = new HashMap<String, Object>();
                 return;
             }
             if (!QueryUtils.checkDateValidity(dateNode.getText())) {
@@ -161,7 +162,7 @@
         }
 
         if (nodeCat.equals("token")) {
-            LinkedHashMap<String, Object> token = KoralObjectGenerator
+            Map<String, Object> token = KoralObjectGenerator
                     .makeToken();
             // handle negation
             List<ParseTree> negations = getChildrenWithCat(node, "!");
@@ -171,7 +172,7 @@
                 negated = true;
             if (getNodeCat(node.getChild(0)).equals("key")) {
                 // no 'term' child, but direct key specification: process here
-                LinkedHashMap<String, Object> term = KoralObjectGenerator
+                Map<String, Object> term = KoralObjectGenerator
                         .makeTerm();
                 String key = node.getChild(0).getText();
                 if (getNodeCat(node.getChild(0).getChild(0)).equals("regex")) {
@@ -203,7 +204,7 @@
             }
             else {
                 // child is 'term' or 'termGroup' -> process in extra method 
-                LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+                Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
                         node.getChild(1), negated);
                 token.put("wrap", termOrTermGroup);
             }
@@ -246,7 +247,7 @@
      * (inequation operators <,>,<=,>= may only be used with dates).
      */
     private boolean checkOperatorValueConformance (
-            LinkedHashMap<String, Object> term) {
+            Map<String, Object> term) {
         String match = (String) term.get("match");
         String type = (String) term.get("type");
         if (type == null || type.equals("type:regex")) {
@@ -262,8 +263,8 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseValue (ParseTree valueNode) {
-        LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
+    private Map<String, Object> parseValue (ParseTree valueNode) {
+        Map<String, Object> map = new HashMap<String, Object>();
         if (getNodeCat(valueNode).equals("date")) {
             map.put("type", "type:date");
             checkDateValidity(valueNode);
@@ -387,13 +388,13 @@
     }
 
 
-    private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+    private void putIntoSuperObject (Map<String, Object> object) {
         putIntoSuperObject(object, 0);
     }
 
 
     @SuppressWarnings({ "unchecked" })
-    private void putIntoSuperObject (LinkedHashMap<String, Object> object,
+    private void putIntoSuperObject (Map<String, Object> object,
             int objStackPosition) {
         if (objectStack.size() > objStackPosition) {
             ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
@@ -407,7 +408,7 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+    private Map<String, Object> parseTermOrTermGroup (ParseTree node,
             boolean negated) {
         return parseTermOrTermGroup(node, negated, "token");
     }
@@ -426,11 +427,11 @@
      * @return A term or termGroup object, depending on input
      */
     @SuppressWarnings("unchecked")
-    private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+    private Map<String, Object> parseTermOrTermGroup (ParseTree node,
             boolean negatedGlobal, String mode) {
         if (getNodeCat(node).equals("term")) {
             String key = null;
-            LinkedHashMap<String, Object> term = KoralObjectGenerator
+            Map<String, Object> term = KoralObjectGenerator
                     .makeTerm();
             // handle negation
             boolean negated = negatedGlobal;
@@ -505,7 +506,7 @@
             // For termGroups, establish a boolean relation between operands 
             // and recursively call this function with the term or termGroup 
             // operands.
-            LinkedHashMap<String, Object> termGroup = null;
+            Map<String, Object> termGroup = null;
             ParseTree leftOp = null;
             ParseTree rightOp = null;
             // check for leading/trailing parantheses
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
index 705963c..ca88711 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessor.java
@@ -43,39 +43,39 @@
     private static Logger log = LoggerFactory
             .getLogger(Cosmas2QueryProcessor.class);
 
-    LinkedList<LinkedHashMap<String, Object>[]> toWrapStack = new LinkedList<LinkedHashMap<String, Object>[]>();
+    private LinkedList<Map<String, Object>[]> toWrapStack = new LinkedList<Map<String, Object>[]>();
     /**
      * Field for repetition query (Kleene + or * operations, or
      * min/max queries: {2,4}
      */
-    String repetition = "";
+    private String repetition = "";
     /**
      * Global control structure for fieldGroups, keeps track of open
      * fieldGroups.
      */
-    LinkedList<ArrayList<Object>> openFieldGroups = new LinkedList<ArrayList<Object>>();
+    private LinkedList<ArrayList<Object>> openFieldGroups = new LinkedList<ArrayList<Object>>();
     /**
      * Keeps track of how many toWrap objects there are to pop after
      * every recursion of {@link #processNode(ParseTree)}
      */
-    LinkedList<Integer> toWrapsToPop = new LinkedList<Integer>();
+    private LinkedList<Integer> toWrapsToPop = new LinkedList<Integer>();
     /**
      * Flag that indicates whether token fields or meta fields are
      * currently being processed
      */
-    boolean inMeta = false;
+    private boolean inMeta = false;
     /**
      * If true, a sequence (OPPROX node) is governed by an OPALL node
      * (ALL()-operator), which requires to match all tokens of the
      * sequence.
      */
-    boolean inOPALL = false;
-    boolean inOPNHIT = false;
+    private boolean inOPALL = false;
+    private boolean inOPNHIT = false;
     /**
              *
              */
-    int classCounter = 1;
-    boolean negate = false;
+    private int classCounter = 1;
+    private boolean negate = false;
 
     /**
      * Allows for the definition of objects to be wrapped around the
@@ -83,13 +83,13 @@
      * parent node of the argument, the number of the argument and an
      * object in whose operands list the argument shall be wrapped.
      */
-    Table<Tree, Integer, LinkedHashMap<String, Object>> operandWrap = HashBasedTable
+    private Table<Tree, Integer, Map<String, Object>> operandWrap = HashBasedTable
             .create();
 
     /**
      * Keeps track of all visited nodes in a tree
      */
-    List<Tree> visited = new ArrayList<Tree>();
+    private List<Tree> visited = new ArrayList<Tree>();
 
     Integer stackedToWrap = 0;
     /**
@@ -191,7 +191,7 @@
                     }
                     if (nodeHasSequentiableSiblings) {
                         // Step I: create sequence
-                        LinkedHashMap<String, Object> sequence = KoralObjectGenerator
+                        Map<String, Object> sequence = KoralObjectGenerator
                                 .makeGroup(KoralOperation.SEQUENCE);
                         // push sequence on object stack but don't
                         // increment stackedObjects counter since
@@ -325,7 +325,7 @@
     private void processOPEND_OPBEG (Tree node) {
         // Step I: create group
         String nodeCat = getNodeCat(node);
-        LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
+        Map<String, Object> beggroup = new HashMap<String, Object>();
         beggroup.put("@type", "koral:reference");
         beggroup.put("operation", "operation:focus");
         ArrayList<Integer> spanRef = new ArrayList<Integer>();
@@ -364,7 +364,7 @@
         Tree endConditions = getFirstChildWithCat(node.getChild(optsChild),
                 "TPEND");
 
-        LinkedHashMap<String, Object> submatchgroup = KoralObjectGenerator
+        Map<String, Object> submatchgroup = KoralObjectGenerator
                 .makeReference(classCounter + 128);
         ArrayList<Object> submatchOperands = new ArrayList<Object>();
         submatchgroup.put("operands", submatchOperands);
@@ -373,7 +373,7 @@
         // Step II: collect all conditions, create groups for them in
         // processPositionCondition()
         ArrayList<Object> distributedOperands = new ArrayList<Object>();
-        ArrayList<LinkedHashMap<String, Object>> conditionGroups = new ArrayList<LinkedHashMap<String, Object>>();
+        ArrayList<Map<String, Object>> conditionGroups = new ArrayList<Map<String, Object>>();
         if (begConditions != null) {
             for (Tree condition : getChildren(begConditions)) {
                 conditionGroups.add(processPositionCondition(condition,
@@ -391,7 +391,7 @@
         // indicates where to insert next condition group
         ArrayList<Object> currentLowestOperands = submatchOperands;
         int conditionCount = 0;
-        for (LinkedHashMap<String, Object> conditionGroup : conditionGroups) {
+        for (Map<String, Object> conditionGroup : conditionGroups) {
             conditionCount++;
             if (conditionGroups.size() == 1) {
                 submatchOperands.add(conditionGroup);
@@ -399,7 +399,7 @@
             else if (conditionCount < conditionGroups.size()) {
                 ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
                 frames.add(KoralFrame.MATCHES);
-                LinkedHashMap<String, Object> matchesGroup = KoralObjectGenerator
+                Map<String, Object> matchesGroup = KoralObjectGenerator
                         .makePosition(frames);
                 @SuppressWarnings("unchecked")
                 ArrayList<Object> matchesOperands = (ArrayList<Object>) matchesGroup
@@ -410,7 +410,7 @@
                 // focus to grep out only the query term to which the
                 // constraint applies
                 if (conditionCount > 1) {
-                    LinkedHashMap<String, Object> focus = KoralObjectGenerator
+                    Map<String, Object> focus = KoralObjectGenerator
                             .makeReference(classCounter + 128 - 2);
                     ArrayList<Object> focusOperands = new ArrayList<Object>();
                     focus.put("operands", focusOperands);
@@ -434,11 +434,10 @@
                 classCounter + 128 + 2 };
         // classRef.add(classCounter + 1); // yes, do this twice (two
         // classes)!
-        LinkedHashMap<String, Object> group = KoralObjectGenerator
+        Map<String, Object> group = KoralObjectGenerator
                 .makeReference(classCounter + 128);
-        LinkedHashMap<String, Object> classRefCheck = KoralObjectGenerator
-                .makeClassRefOp(ClassRefOp.INVERSION, classRef,
-                        classCounter + 128);
+        Map<String, Object> classRefCheck = KoralObjectGenerator.makeClassRefOp(
+                ClassRefOp.INVERSION, classRef, classCounter + 128);
         ArrayList<Object> operands = new ArrayList<Object>();
         operands.add(classRefCheck);
         group.put("operands", operands);
@@ -458,8 +457,7 @@
         if (operandWrap.containsRow(parent)) {
             // Step I: create group
             int argNr = nodeCat.equals("ARG1") ? 1 : 2;
-            LinkedHashMap<String, Object> container = operandWrap.row(parent)
-                    .get(argNr);
+            Map<String, Object> container = operandWrap.row(parent).get(argNr);
             // Step II: ingest
             if (container != null) {
                 objectStack.push(container);
@@ -513,22 +511,26 @@
     private void processOPIN_OPOV (Tree node) {
         String nodeCat = getNodeCat(node);
 
-        // LinkedHashMap<String, Object> posgroup =
+        // Map<String, Object> posgroup =
         // makePosition(null);
         boolean isExclusion = isExclusion(node);
 
-        KoralOperation operation;
+        Map<String, Object> posGroup;
         if (isExclusion) {
-            operation = KoralOperation.EXCLUSION;
+            posGroup = KoralObjectGenerator.makeGroup(KoralOperation.EXCLUSION);
         }
         else {
-            operation = KoralOperation.POSITION;
+            posGroup = KoralObjectGenerator.makeGroup(KoralOperation.POSITION);
+            // mark this an inverted operands object
+            invertedOperandsLists
+                    .push((ArrayList<Object>) posGroup.get("operands"));
             wrapOperandInClass(node, 2, 128 + classCounter++);
             wrapOperandInClass(node, 1, 128 + classCounter++);
-        }
+            // EM: why bother inverting the operands and creating classes and focus? 
+            // can't we agree on the first operand to be the results, like in 
+            // operation:exclusion?
 
-        Map<String, Object> posGroup = KoralObjectGenerator
-                .makeGroup(operation);
+        }
 
         Map<String, Object> positionOptions;
         if (nodeCat.equals("OPIN")) {
@@ -547,28 +549,25 @@
         ArrayList<ClassRefCheck> checkList = (ArrayList<ClassRefCheck>) positionOptions
                 .get("classRefCheck");
 
-        // EM: why bother inverting the operands and creating classes and focus? 
-        // can't we agree on the first operand to be the results, like in operation:exclusion?
-        if (!isExclusion) {
-            // mark this an inverted operands object
-            invertedOperandsLists
-                    .push((ArrayList<Object>) posGroup.get("operands"));
-
-            // Step II: wrap in classRefCheck and/or focus and decide where to put
+        // Step II: wrap in classRefCheck and/or focus and decide where to put
+        if (isExclusion) {
             if (!checkList.isEmpty()) {
-                posGroup = addClassRefCheck(checkList, posGroup);
-            }
-            posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
-                    posGroup);
+                wrapOperandInClass(node, 1, 128 + classCounter++);
+                wrapOperandInClass(node, 2, 128 + classCounter++);
 
+                posGroup = addClassRefCheck(
+                        (ArrayList<ClassRefCheck>) positionOptions
+                                .get("classRefCheck"),
+                        posGroup);
+            }
         }
-        else if (!checkList.isEmpty()) {
-            wrapOperandInClass(node, 1, 128 + classCounter++);
-            wrapOperandInClass(node, 2, 128 + classCounter++);
-            posGroup = addClassRefCheck(
-                    (ArrayList<ClassRefCheck>) positionOptions
-                            .get("classRefCheck"),
-                    posGroup);
+        else {
+            if (!checkList.isEmpty()) {
+                posGroup = addClassRefCheck(
+                        (ArrayList<ClassRefCheck>) positionOptions
+                                .get("classRefCheck"),
+                        posGroup);
+            }
             posGroup = addClassFocus((boolean) positionOptions.get("matchall"),
                     posGroup);
         }
@@ -576,7 +575,7 @@
         // wrap in 'merge' operation if grouping option is set
         if (positionOptions.containsKey("grouping")
                 && (boolean) positionOptions.get("grouping")) {
-            LinkedHashMap<String, Object> mergeOperation = KoralObjectGenerator
+            Map<String, Object> mergeOperation = KoralObjectGenerator
                     .makeGroup(KoralOperation.MERGE);
             ArrayList<Object> mergeOperands = (ArrayList<Object>) mergeOperation
                     .get("operands");
@@ -594,7 +593,7 @@
         Tree typ = prox_opts.getChild(0);
         Tree dist_list = prox_opts.getChild(1);
         // Step I: create group
-        LinkedHashMap<String, Object> group = KoralObjectGenerator
+        Map<String, Object> group = KoralObjectGenerator
                 .makeGroup(KoralOperation.SEQUENCE);
 
         ArrayList<Object> constraints = new ArrayList<Object>();
@@ -639,7 +638,7 @@
             if (!meas.equals("w") && min == 0) {
                 processSpanDistance(meas, min, max);
             }
-            LinkedHashMap<String, Object> distance = KoralObjectGenerator
+            Map<String, Object> distance = KoralObjectGenerator
                     .makeDistance(meas, min, max);
             // override @type, min/max to be treated according to 
             // Cosmas particularities
@@ -664,7 +663,7 @@
             }
         }
         group.put("inOrder", inOrder);
-        LinkedHashMap<String, Object> embeddedSequence = group;
+        Map<String, Object> embeddedSequence = group;
 
         if (!(openNodeCats.get(1).equals("OPBEG")
                 || openNodeCats.get(1).equals("OPEND") || inOPALL
@@ -677,7 +676,7 @@
             classCounter++;
         }
         else if (openNodeCats.get(1).equals("OPNHIT")) {
-            LinkedHashMap<String, Object> repetition = KoralObjectGenerator
+            Map<String, Object> repetition = KoralObjectGenerator
                     .makeRepetition(min, max);
             ((ArrayList<Object>) repetition.get("operands"))
                     .add(KoralObjectGenerator.makeToken());
@@ -687,13 +686,13 @@
             // different keys, like /w4,s0?
         }
 
-        //        LinkedHashMap<String, Object> sequence = null;
+        //        Map<String, Object> sequence = null;
         //        if (putIntoOverlapDisjunction) {
         //            sequence = embeddedSequence;
         //            group = KoralObjectGenerator.makeGroup("or");
         //            ArrayList<Object> disjOperands = 
         //                    (ArrayList<Object>) group.get("operands");
-        //            LinkedHashMap<String, Object> overlapsGroup = KoralObjectGenerator
+        //            Map<String, Object> overlapsGroup = KoralObjectGenerator
         //                    .makePosition(new String[0]);
         //
         //            ArrayList<Object> overlapsOperands = 
@@ -727,7 +726,7 @@
 
     private void processOPOR (Tree node) {
         // Step I: create group
-        LinkedHashMap<String, Object> disjunction = KoralObjectGenerator
+        Map<String, Object> disjunction = KoralObjectGenerator
                 .makeGroup(KoralOperation.DISJUNCTION);
         disjunction.put("inOrder", false); // Order is not important 
         objectStack.push(disjunction);
@@ -740,11 +739,11 @@
     private void processOPAND_OPNOT (Tree node) {
         // Step I: create group
         String nodeCat = getNodeCat(node);
-        LinkedHashMap<String, Object> distgroup = KoralObjectGenerator
+        Map<String, Object> distgroup = KoralObjectGenerator
                 .makeGroup(KoralOperation.SEQUENCE);
         distgroup.put("inOrder", false); // Order is not important 
         ArrayList<Object> distances = new ArrayList<Object>();
-        LinkedHashMap<String, Object> zerodistance = KoralObjectGenerator
+        Map<String, Object> zerodistance = KoralObjectGenerator
                 .makeDistance("t", 0, 0);
         zerodistance.put("@type", "cosmas:distance"); // overwrite @type: cosmas:distance! 
         if (nodeCat.equals("OPNOT"))
@@ -762,7 +761,7 @@
     private void processOPLABEL (Tree node) {
         // Step I: create element
         String key = node.getChild(0).toStringTree().replaceAll("<|>", "");
-        LinkedHashMap<String, Object> elem = KoralObjectGenerator.makeSpan(key);
+        Map<String, Object> elem = KoralObjectGenerator.makeSpan(key);
         // Step II: decide where to put
         putIntoSuperObject(elem);
     }
@@ -772,7 +771,7 @@
     @SuppressWarnings("unchecked")
     private void processOPELEM (Tree node) {
         // Step I: create element
-        LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
+        Map<String, Object> span = KoralObjectGenerator.makeSpan();
         if (node.getChild(0).toStringTree().equals("EMPTY")) {
             addError(StatusCodes.MALFORMED_QUERY, "Empty #ELEM() operator."
                     + " Please specify a valid element key (like 's' for sentence).");
@@ -793,7 +792,7 @@
                 span.put("key", elnameNode.getChild(0).toStringTree()
                         .toLowerCase());
                 */
-                LinkedHashMap<String, Object> fm = termToFieldMap(
+                Map<String, Object> fm = termToFieldMap(
                         elnameNode.getChild(0).toStringTree());
 
                 if (fm == null)
@@ -821,14 +820,14 @@
                  * to avoid a top-level group that only contains a
                  * sub-group).
                  */
-                LinkedHashMap<String, Object> termGroup = KoralObjectGenerator
+                Map<String, Object> termGroup = KoralObjectGenerator
                         .makeTermGroup(KoralTermGroupRelation.AND);
                 ArrayList<Object> termGroupOperands = (ArrayList<Object>) termGroup
                         .get("operands");
                 for (int i = elname; i < node.getChildCount(); i++) {
                     Tree attrNode = node.getChild(i);
                     if (attrNode.getChildCount() == 2) {
-                        LinkedHashMap<String, Object> term = KoralObjectGenerator
+                        Map<String, Object> term = KoralObjectGenerator
                                 .makeTerm();
                         termGroupOperands.add(term);
                         String layer = attrNode.getChild(0).toStringTree();
@@ -845,13 +844,13 @@
                         term.put("match", match.toString());
                     }
                     else {
-                        LinkedHashMap<String, Object> subTermGroup = KoralObjectGenerator
+                        Map<String, Object> subTermGroup = KoralObjectGenerator
                                 .makeTermGroup(KoralTermGroupRelation.AND);
                         ArrayList<Object> subTermGroupOperands = (ArrayList<Object>) subTermGroup
                                 .get("operands");
                         int j;
                         for (j = 1; j < attrNode.getChildCount(); j++) {
-                            LinkedHashMap<String, Object> term = KoralObjectGenerator
+                            Map<String, Object> term = KoralObjectGenerator
                                     .makeTerm();
                             String layer = attrNode.getChild(0).toStringTree();
                             String[] splitted = layer.split("/");
@@ -883,8 +882,7 @@
                 // possibly only one term was present throughout all
                 // nodes: extract it from the group
                 if (termGroupOperands.size() == 1) {
-                    termGroup = (LinkedHashMap<String, Object>) termGroupOperands
-                            .get(0);
+                    termGroup = (Map<String, Object>) termGroupOperands.get(0);
                 }
 
                 // TODO: This should be improved ...
@@ -905,9 +903,9 @@
         // Step I: get info
         String[] morphterms = node.getChild(0).toStringTree().replace(" ", "")
                 .split("&");
-        LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+        Map<String, Object> token = KoralObjectGenerator.makeToken();
         ArrayList<Object> terms = new ArrayList<Object>();
-        LinkedHashMap<String, Object> fieldMap = null;
+        Map<String, Object> fieldMap = null;
 
         for (String morphterm : morphterms) {
 
@@ -924,7 +922,7 @@
         }
 
         else {
-            LinkedHashMap<String, Object> termGroup = KoralObjectGenerator
+            Map<String, Object> termGroup = KoralObjectGenerator
                     .makeTermGroup(KoralTermGroupRelation.AND);
             termGroup.put("operands", terms);
             token.put("wrap", termGroup);
@@ -944,11 +942,10 @@
     private void processOPWF_OPLEM (Tree node) {
         String nodeCat = getNodeCat(node);
         // Step I: get info
-        LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+        Map<String, Object> token = KoralObjectGenerator.makeToken();
         objectStack.push(token);
         stackedObjects++;
-        LinkedHashMap<String, Object> fieldMap = KoralObjectGenerator
-                .makeTerm();
+        Map<String, Object> fieldMap = KoralObjectGenerator.makeTerm();
         token.put("wrap", fieldMap);
         // make category-specific fieldMap entry
         String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
@@ -1007,8 +1004,7 @@
      *            The class id.
      */
     private void wrapOperandInClass (Tree node, int arg, int cls) {
-        LinkedHashMap<String, Object> clsGroup = KoralObjectGenerator
-                .makeSpanClass(cls);
+        Map<String, Object> clsGroup = KoralObjectGenerator.makeSpanClass(cls);
         wrapOperand(node, arg, clsGroup);
     }
 
@@ -1028,7 +1024,7 @@
      *            be wrapped.
      */
     private void wrapOperand (Tree node, int arg,
-            LinkedHashMap<String, Object> container) {
+            Map<String, Object> container) {
         operandWrap.put(node, arg, container);
     }
 
@@ -1070,7 +1066,7 @@
      * @param mode
      * @return
      */
-    private LinkedHashMap<String, Object> processPositionCondition (Tree cond,
+    private Map<String, Object> processPositionCondition (Tree cond,
             ArrayList<Object> distributedOperands, String mode) {
         boolean negated = false;
         String elem; // the 'span' (s/p/t)
@@ -1115,20 +1111,19 @@
         // as operands, possibly wrapped in spanRefs
         ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
         frames.add(position);
-        LinkedHashMap<String, Object> positionGroup = KoralObjectGenerator
+        Map<String, Object> positionGroup = KoralObjectGenerator
                 .makePosition(frames);
         if (negated)
             positionGroup.put("exclude", true);
         ArrayList<Object> posOperands = new ArrayList<Object>();
-        LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+        Map<String, Object> classGroup = KoralObjectGenerator
                 .makeSpanClass(128 + classCounter++);
         classGroup.put("operands", distributedOperands);
         positionGroup.put("operands", posOperands);
-        LinkedHashMap<String, Object> span = KoralObjectGenerator
-                .makeSpan(elem);
+        Map<String, Object> span = KoralObjectGenerator.makeSpan(elem);
         objectStack.push(classGroup);
         if (hitSpanRef != null) {
-            LinkedHashMap<String, Object> spanRefAroundHit = KoralObjectGenerator
+            Map<String, Object> spanRefAroundHit = KoralObjectGenerator
                     .makeSpanReference(hitSpanRef, KoralOperation.FOCUS);
             ((ArrayList<Object>) spanRefAroundHit.get("operands"))
                     .add(classGroup);
@@ -1136,7 +1131,7 @@
             classGroup = spanRefAroundHit;
         }
         if (elemSpanRef != null) {
-            LinkedHashMap<String, Object> spanRefAroundSpan = KoralObjectGenerator
+            Map<String, Object> spanRefAroundSpan = KoralObjectGenerator
                     .makeSpanReference(elemSpanRef, KoralOperation.FOCUS);
             ((ArrayList<Object>) spanRefAroundSpan.get("operands")).add(span);
             // re-assign after wrapping span in spanRef
@@ -1148,13 +1143,13 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseOPINOptions (Tree node,
+    private Map<String, Object> parseOPINOptions (Tree node,
             boolean isExclusion) {
         Tree posnode = getFirstChildWithCat(node, "POS");
         Tree rangenode = getFirstChildWithCat(node, "RANGE");
         Tree groupnode = getFirstChildWithCat(node, "GROUP");
 
-        LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
+        Map<String, Object> posOptions = new HashMap<String, Object>();
         ArrayList<KoralFrame> positions = new ArrayList<KoralFrame>();
         ArrayList<ClassRefCheck> classRefCheck = new ArrayList<ClassRefCheck>();
         posOptions.put("matchall", false);
@@ -1180,7 +1175,7 @@
             String range = rangenode.getChild(0).toStringTree().toLowerCase();
             if (range.equals("all")) {
                 posOptions.put("matchall", true);
-                // LinkedHashMap<String,Object> ref =
+                // Map<String,Object> ref =
                 // makeResetReference(); // reset all defined classes
                 // wrapOperand(node,2,ref);
             }
@@ -1261,13 +1256,13 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseOPOVOptions (Tree node) {
+    private Map<String, Object> parseOPOVOptions (Tree node) {
         boolean negatePosition = false;
         Tree posnode = getFirstChildWithCat(node, "POS");
         Tree rangenode = getFirstChildWithCat(node, "RANGE");
         Tree exclnode = getFirstChildWithCat(node, "EXCL");
         Tree groupnode = getFirstChildWithCat(node, "GROUP");
-        LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
+        Map<String, Object> posOptions = new HashMap<String, Object>();
         ArrayList<KoralFrame> positions = new ArrayList<KoralFrame>();
         ArrayList<ClassRefCheck> classRefCheck = new ArrayList<ClassRefCheck>();
         posOptions.put("matchall", false);
@@ -1321,7 +1316,7 @@
             String range = rangenode.getChild(0).toStringTree().toLowerCase();
             if (range.equals("all")) {
                 posOptions.put("matchall", true);
-                // LinkedHashMap<String,Object> ref =
+                // Map<String,Object> ref =
                 // makeResetReference(); // reset all defined classes
                 // wrapOperand(node,2,ref);
             }
@@ -1344,8 +1339,7 @@
 
 
     @SuppressWarnings({ "unchecked" })
-    private LinkedHashMap<String, Object> wrap (
-            LinkedHashMap<String, Object>[] wrapCascade) {
+    private Map<String, Object> wrap (Map<String, Object>[] wrapCascade) {
         int i;
         for (i = 0; i < wrapCascade.length - 1; i++) {
             ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i
@@ -1375,7 +1369,7 @@
     }
 
 
-    private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+    private void putIntoSuperObject (Map<String, Object> object) {
         putIntoSuperObject(object, 0);
     }
 
@@ -1408,7 +1402,7 @@
     }
 
 
-    private LinkedHashMap<String, Object> termToFieldMap (String term) {
+    private Map<String, Object> termToFieldMap (String term) {
 
         // regex group #2 is foundry, #4 layer, #5 operator,
         // #6 key, #8 value
@@ -1422,11 +1416,11 @@
         if (!m.matches()) {
             addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
                     "Something went wrong parsing the argument in MORPH() or #ELEM().");
-            requestMap.put("query", new LinkedHashMap<String, Object>());
+            requestMap.put("query", new HashMap<String, Object>());
             return null;
         };
 
-        LinkedHashMap<String, Object> fieldMap = null;
+        Map<String, Object> fieldMap = null;
         fieldMap = KoralObjectGenerator.makeTerm();
 
         if (m.group(2) != null)
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
index e8dc203..792ba7d 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessor.java
@@ -44,7 +44,7 @@
             .getLogger(PoliqarpPlusQueryProcessor.class);
     private int classCounter = 1;
 
-    LinkedHashMap<ParseTree, Integer> classWrapRegistry = new LinkedHashMap<ParseTree, Integer>();
+    Map<ParseTree, Integer> classWrapRegistry = new HashMap<ParseTree, Integer>();
 
 
     /**
@@ -114,7 +114,7 @@
         // in a class, e.g. by an alignment operation
         if (classWrapRegistry.containsKey(node)) {
             Integer classId = classWrapRegistry.get(node);
-            LinkedHashMap<String, Object> spanClass = KoralObjectGenerator
+            Map<String, Object> spanClass = KoralObjectGenerator
                     .makeSpanClass(classId);
             putIntoSuperObject(spanClass);
             objectStack.push(spanClass);
@@ -221,7 +221,7 @@
         // Cover possible quantification (i.e. repetition) of segment
         ParseTree quantification = getFirstChildWithCat(node, "repetition");
         if (quantification != null) {
-            LinkedHashMap<String, Object> quantGroup = KoralObjectGenerator
+            Map<String, Object> quantGroup = KoralObjectGenerator
                     .makeGroup(KoralOperation.REPETITION);
             Integer[] minmax = parseRepetition(quantification);
             quantGroup.put("boundary",
@@ -254,7 +254,7 @@
                 return;
             }
         }
-        LinkedHashMap<String, Object> sequence = KoralObjectGenerator
+        Map<String, Object> sequence = KoralObjectGenerator
                 .makeGroup(KoralOperation.SEQUENCE);
 
         putIntoSuperObject(sequence);
@@ -273,8 +273,8 @@
         Integer[] minmax = parseEmptySegments(node);
         // object will be either a repetition group or a single empty
         // token
-        LinkedHashMap<String, Object> object;
-        LinkedHashMap<String, Object> emptyToken = KoralObjectGenerator
+        Map<String, Object> object;
+        Map<String, Object> emptyToken = KoralObjectGenerator
                 .makeToken();
         if (minmax[0] != 1 || minmax[1] == null || minmax[1] != 1) {
             object = KoralObjectGenerator.makeRepetition(minmax[0], minmax[1]);
@@ -295,7 +295,7 @@
             classId = Integer.parseInt(
                     node.getChild(1).getChild(0).toStringTree(parser));
         }
-        LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+        Map<String, Object> classGroup = KoralObjectGenerator
                 .makeSpanClass(classId);
         addHighlightClass(classId);
         putIntoSuperObject(classGroup);
@@ -305,7 +305,7 @@
 
 
     private void processToken (ParseTree node) {
-        LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+        Map<String, Object> token = KoralObjectGenerator.makeToken();
         // handle negation
         List<ParseTree> negations = getChildrenWithCat(node, "!");
         int termOrTermGroupChildId = 1;
@@ -318,7 +318,7 @@
 
         if (getNodeCat(node.getChild(0)).equals("key")) {
             // no 'term' child, but direct key specification: process here
-            LinkedHashMap<String, Object> term = KoralObjectGenerator
+            Map<String, Object> term = KoralObjectGenerator
                     .makeTerm();
 
             String key = node.getChild(0).getText();
@@ -360,7 +360,7 @@
         }
         else {
             // child is 'term' or 'termGroup' -> process in extra method
-            LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+            Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
                     node.getChild(termOrTermGroupChildId), negated);
             token.put("wrap", termOrTermGroup);
         }
@@ -423,8 +423,8 @@
         boolean negated = false;
         if (negations.size() % 2 == 1)
             negated = true;
-        LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan();
-        LinkedHashMap<String, Object> wrappedTerm = KoralObjectGenerator
+        Map<String, Object> span = KoralObjectGenerator.makeSpan();
+        Map<String, Object> wrappedTerm = KoralObjectGenerator
                 .makeTerm();
         span.put("wrap", wrappedTerm);
         ParseTree keyNode = getFirstChildWithCat(node, "key");
@@ -457,12 +457,12 @@
                 wrappedTerm.put("match", KoralMatchOperator.NOT_EQUALS.toString());
         }
         if (termNode != null) {
-            LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+            Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
                     termNode, negated, "span");
             span.put("attr", termOrTermGroup);
         }
         if (termGroupNode != null) {
-            LinkedHashMap<String, Object> termOrTermGroup = parseTermOrTermGroup(
+            Map<String, Object> termOrTermGroup = parseTermOrTermGroup(
                     termGroupNode, negated, "span");
             span.put("attr", termOrTermGroup);
         }
@@ -473,7 +473,7 @@
 
 
     private void processDisjunction (ParseTree node) {
-        LinkedHashMap<String, Object> disjunction = KoralObjectGenerator
+        Map<String, Object> disjunction = KoralObjectGenerator
                 .makeGroup(KoralOperation.DISJUNCTION);
         putIntoSuperObject(disjunction);
         objectStack.push(disjunction);
@@ -482,7 +482,7 @@
 
 
     private void processPosition (ParseTree node) {
-        LinkedHashMap<String, Object> position = parseFrame(node.getChild(0));
+        Map<String, Object> position = parseFrame(node.getChild(0));
         putIntoSuperObject(position);
         objectStack.push(position);
         stackedObjects++;
@@ -490,11 +490,11 @@
 
 
     private void processRelation (ParseTree node) {
-        LinkedHashMap<String, Object> relationGroup = KoralObjectGenerator
+        Map<String, Object> relationGroup = KoralObjectGenerator
                 .makeGroup(KoralOperation.RELATION);
-        LinkedHashMap<String, Object> relation = KoralObjectGenerator
+        Map<String, Object> relation = KoralObjectGenerator
                 .makeRelation();
-        LinkedHashMap<String, Object> term = KoralObjectGenerator.makeTerm();
+        Map<String, Object> term = KoralObjectGenerator.makeTerm();
         relationGroup.put("relation", relation);
         relation.put("wrap", term);
         if (node.getChild(0).getText().equals("dominates")) {
@@ -543,7 +543,7 @@
                 addError(StatusCodes.INVALID_CLASS_REFERENCE, msg);
             }
         }
-        LinkedHashMap<String, Object> classGroup = KoralObjectGenerator
+        Map<String, Object> classGroup = KoralObjectGenerator
                 .makeSpanClass(classId);
         addHighlightClass(classId);
         putIntoSuperObject(classGroup);
@@ -580,7 +580,7 @@
         else {
             classRefs.add(1); // default
         }
-        LinkedHashMap<String, Object> referenceGroup = KoralObjectGenerator
+        Map<String, Object> referenceGroup = KoralObjectGenerator
                 .makeReference(classRefs);
 
         String type = node.getChild(0).toStringTree(parser);
@@ -601,7 +601,7 @@
 
 
     private void processSubmatch (ParseTree node) {
-        LinkedHashMap<String, Object> submatch = KoralObjectGenerator
+        Map<String, Object> submatch = KoralObjectGenerator
                 .makeReference(null);
         submatch.put("operands", new ArrayList<Object>());
         ParseTree startpos = getFirstChildWithCat(node, "startpos");
@@ -641,13 +641,13 @@
     private void processWithin (ParseTree node) {
         ParseTree domainNode = node.getChild(1);
         String domain = getNodeCat(domainNode);
-        LinkedHashMap<String, Object> span = KoralObjectGenerator
+        Map<String, Object> span = KoralObjectGenerator
                 .makeSpan(domain);
-        LinkedHashMap<String, Object> queryObj = (LinkedHashMap<String, Object>) requestMap
+        Map<String, Object> queryObj = (Map<String, Object>) requestMap
                 .get("query");
         ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
         frames.add(KoralFrame.IS_AROUND);
-        LinkedHashMap<String, Object> contains = KoralObjectGenerator
+        Map<String, Object> contains = KoralObjectGenerator
                 .makePosition(frames);
         ArrayList<Object> operands = (ArrayList<Object>) contains
                 .get("operands");
@@ -719,7 +719,7 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseFrame (ParseTree node) {
+    private Map<String, Object> parseFrame (ParseTree node) {
         String operator = node.toStringTree(parser).toLowerCase();
         ArrayList<KoralFrame> frames = new ArrayList<KoralFrame>();
         switch (operator) {
@@ -746,7 +746,7 @@
     }
 
 
-    private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+    private Map<String, Object> parseTermOrTermGroup (ParseTree node,
             boolean negated) {
         return parseTermOrTermGroup(node, negated, "token");
     }
@@ -767,7 +767,7 @@
      * @return A term or termGroup object, depending on input
      */
     @SuppressWarnings("unchecked")
-    private LinkedHashMap<String, Object> parseTermOrTermGroup (ParseTree node,
+    private Map<String, Object> parseTermOrTermGroup (ParseTree node,
             boolean negatedGlobal, String mode) {
 
         String nodeCat = getNodeCat(node);
@@ -781,7 +781,7 @@
             };
 
             String key = null;
-            LinkedHashMap<String, Object> term = KoralObjectGenerator
+            Map<String, Object> term = KoralObjectGenerator
                     .makeTerm();
             // handle negation
             boolean negated = negatedGlobal;
@@ -875,7 +875,7 @@
             // For termGroups, establish a boolean relation between
             // operands and recursively call this function with
             // the term or termGroup operands
-            LinkedHashMap<String, Object> termGroup = null;
+            Map<String, Object> termGroup = null;
             ParseTree leftOp = null;
             ParseTree rightOp = null;
             // check for leading/trailing parantheses
@@ -919,7 +919,7 @@
      * @param object
      *            The object to be inserted
      */
-    private void putIntoSuperObject (LinkedHashMap<String, Object> object) {
+    private void putIntoSuperObject (Map<String, Object> object) {
         putIntoSuperObject(object, 0);
     }
 
@@ -939,7 +939,7 @@
      *            the stack is the super object.
      */
     @SuppressWarnings({ "unchecked" })
-    private void putIntoSuperObject (LinkedHashMap<String, Object> object,
+    private void putIntoSuperObject (Map<String, Object> object,
             int objStackPosition) {
         if (objectStack.size() > objStackPosition) {
             ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
index 62422ae..f5f7819 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/QuerySerializer.java
@@ -42,7 +42,7 @@
     public static String queryLanguageVersion;
 
     private AbstractQueryProcessor ast;
-    private Map<String, Object> collection = new LinkedHashMap<>();
+    private Map<String, Object> collection = new HashMap<>();
     private Map<String, Object> meta;
     private List<Object> errors;
     private List<Object> warnings;
@@ -251,7 +251,7 @@
             return collection1;
         }
         else {
-            LinkedHashMap<String, Object> docGroup = KoralObjectGenerator
+            Map<String, Object> docGroup = KoralObjectGenerator
                     .makeDocGroup("and");
             ArrayList<Object> operands = (ArrayList<Object>) docGroup
                     .get("operands");
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
index 8fbb7fc..6949812 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/util/KoralObjectGenerator.java
@@ -2,9 +2,9 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.LinkedHashMap;
-import java.util.List;
+import java.util.HashMap;
 import java.util.Map;
+import java.util.List;
 
 import de.ids_mannheim.korap.query.object.ClassRefCheck;
 import de.ids_mannheim.korap.query.object.ClassRefOp;
@@ -16,41 +16,40 @@
 
 public class KoralObjectGenerator {
 
-    protected static final Integer MAXIMUM_DISTANCE = 100;
+    private static final Integer MAXIMUM_DISTANCE = 100;
     private static AbstractQueryProcessor qp;
 
-
     public static void setQueryProcessor (AbstractQueryProcessor qp) {
         KoralObjectGenerator.qp = qp;
     }
 
 
-    public static LinkedHashMap<String, Object> makeSpan () {
-        LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeSpan () {
+        Map<String, Object> span = new HashMap<String, Object>();
         span.put("@type", KoralType.SPAN.toString());
         return span;
     }
 
 
-    public static LinkedHashMap<String, Object> makeSpan (String key) {
-        LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeSpan (String key) {
+        Map<String, Object> span = new HashMap<String, Object>();
         span.put("@type", KoralType.SPAN.toString());
-        LinkedHashMap<String, Object> term = makeTerm();
+        Map<String, Object> term = makeTerm();
         term.put("key", key);
         span.put("wrap", term);
         return span;
     }
 
 
-    public static LinkedHashMap<String, Object> makeTerm () {
-        LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeTerm () {
+        Map<String, Object> term = new HashMap<String, Object>();
         term.put("@type", KoralType.TERM.toString());
         return term;
     }
 
 
-    public static LinkedHashMap<String, Object> makeTermGroup (KoralTermGroupRelation relation) {
-        LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeTermGroup (KoralTermGroupRelation relation) {
+        Map<String, Object> term = new HashMap<String, Object>();
         term.put("@type", KoralType.TERMGROUP.toString());
         term.put("relation", relation.toString());
         term.put("operands", new ArrayList<Object>());
@@ -58,15 +57,15 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeDoc () {
-        LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeDoc () {
+        Map<String, Object> term = new HashMap<String, Object>();
         term.put("@type", KoralType.DOCUMENT.toString());
         return term;
     }
 
 
-    public static LinkedHashMap<String, Object> makeDocGroup (String relation) {
-        LinkedHashMap<String, Object> term = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeDocGroup (String relation) {
+        Map<String, Object> term = new HashMap<String, Object>();
         term.put("@type", KoralType.DOCUMENTGROUP.toString());
         term.put("operation", "operation:" + relation);
         term.put("operands", new ArrayList<Object>());
@@ -74,15 +73,15 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeToken () {
-        LinkedHashMap<String, Object> token = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeToken () {
+        Map<String, Object> token = new HashMap<String, Object>();
         token.put("@type", KoralType.TOKEN.toString());
         return token;
     }
 
 
-    public static LinkedHashMap<String, Object> makeGroup (KoralOperation operation) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeGroup (KoralOperation operation) {
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", operation.toString());
         group.put("operands", new ArrayList<Object>());
@@ -90,17 +89,17 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeRepetition (Integer min,
+    public static Map<String, Object> makeRepetition (Integer min,
             Integer max) {
-        LinkedHashMap<String, Object> group = makeGroup(KoralOperation.REPETITION);
+        Map<String, Object> group = makeGroup(KoralOperation.REPETITION);
         group.put("boundary", makeBoundary(min, max));
         return group;
     }
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> makePosition (KoralFrame frame) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makePosition (KoralFrame frame) {
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", KoralOperation.POSITION.toString());
         group.put("frame", frame.toString());
@@ -109,9 +108,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makePosition (
+    public static Map<String, Object> makePosition (
             List<KoralFrame> allowedFrames) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", KoralOperation.POSITION.toString());
         group.put("frames", Converter.enumListToStringList(allowedFrames));
@@ -119,15 +118,15 @@
         return group;
     }
 
-    public static LinkedHashMap<String, Object> makeSpanClass (int classId) {
+    public static Map<String, Object> makeSpanClass (int classId) {
         return makeSpanClass(classId, false);
     }
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> makeSpanClass (int classId,
+    public static Map<String, Object> makeSpanClass (int classId,
             boolean setBySystem) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", KoralOperation.CLASS.toString());
         if (setBySystem) {
@@ -142,9 +141,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeClassRefCheck (
+    public static Map<String, Object> makeClassRefCheck (
             ArrayList<ClassRefCheck> checks, Integer[] classIn, int classOut) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", KoralOperation.CLASS.toString());
         group.put("classRefCheck", Converter.enumListToStringList(checks));
@@ -155,9 +154,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeClassRefOp (
+    public static Map<String, Object> makeClassRefOp (
             ClassRefOp operation, Integer[] classIn, int classOut) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.GROUP.toString());
         group.put("operation", KoralOperation.CLASS.toString());
         group.put("classRefOp", operation.toString());
@@ -169,8 +168,8 @@
 
 
 //    @Deprecated
-//    public static LinkedHashMap<String, Object> makeTreeRelation (String reltype) {
-//        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+//    public static Map<String, Object> makeTreeRelation (String reltype) {
+//        Map<String, Object> group = new HashMap<String, Object>();
 //        group.put("@type", "koral:treeRelation");
 //        if (reltype != null)
 //            group.put("reltype", reltype);
@@ -178,16 +177,16 @@
 //    }
 
 
-    public static LinkedHashMap<String, Object> makeRelation () {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeRelation () {
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.RELATION.toString());
         return group;
     }
 
 
-    public static LinkedHashMap<String, Object> makeBoundary (Integer min,
+    public static Map<String, Object> makeBoundary (Integer min,
             Integer max) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.BOUNDARY.toString());
         group.put("min", min);
         if (max != null) {
@@ -197,9 +196,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeDistance (String key,
+    public static Map<String, Object> makeDistance (String key,
             Integer min, Integer max) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         if (key.equals("w")) {
             group.put("@type", KoralType.DISTANCE.toString());
         }
@@ -219,9 +218,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeReference (
+    public static Map<String, Object> makeReference (
             ArrayList<Integer> classRefs, KoralOperation operation) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.REFERENCE.toString());
         group.put("operation", operation.toString());
         if (classRefs != null && !classRefs.isEmpty()) {
@@ -231,14 +230,14 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeReference (
+    public static Map<String, Object> makeReference (
             ArrayList<Integer> classRefs) {
         return makeReference(classRefs, KoralOperation.FOCUS);
     }
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> makeReference (int classRef,
+    public static Map<String, Object> makeReference (int classRef,
             KoralOperation operation, boolean setBySystem) {
         ArrayList<Integer> classRefs = new ArrayList<Integer>();
         if (setBySystem)
@@ -249,7 +248,7 @@
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> makeReference (int classRef,
+    public static Map<String, Object> makeReference (int classRef,
             boolean setBySystem) {
         ArrayList<Integer> classRefs = new ArrayList<Integer>();
         if (setBySystem)
@@ -259,14 +258,14 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeReference (int classRef) {
+    public static Map<String, Object> makeReference (int classRef) {
         return makeReference(classRef, false);
     }
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> makeResetReference () {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+    public static Map<String, Object> makeResetReference () {
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.REFERENCE.toString());
         group.put("operation", KoralOperation.FOCUS.toString());
         group.put("reset", true);
@@ -275,9 +274,9 @@
     }
 
 
-    public static LinkedHashMap<String, Object> makeSpanReference (
+    public static Map<String, Object> makeSpanReference (
             Integer[] spanRef, KoralOperation operation) {
-        LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
+        Map<String, Object> group = new HashMap<String, Object>();
         group.put("@type", KoralType.REFERENCE.toString());
         group.put("operation", operation.toString());
         group.put("spanRef", Arrays.asList(spanRef));
@@ -286,7 +285,7 @@
     }
 
 
-    public static void addOperandsToGroup (LinkedHashMap<String, Object> group) {
+    public static void addOperandsToGroup (Map<String, Object> group) {
         ArrayList<Object> operands = new ArrayList<Object>();
         group.put("operands", operands);
     }
@@ -294,7 +293,7 @@
 
     public static Map<String, Object> wrapInReference (
             Map<String, Object> group, Integer classId) {
-        LinkedHashMap<String, Object> refGroup = makeReference(classId);
+        Map<String, Object> refGroup = makeReference(classId);
         ArrayList<Object> operands = new ArrayList<Object>();
         operands.add(group);
         refGroup.put("operands", operands);
@@ -303,10 +302,10 @@
 
 
     @Deprecated
-    public static LinkedHashMap<String, Object> wrapInReference (
-            LinkedHashMap<String, Object> group, Integer classId,
+    public static Map<String, Object> wrapInReference (
+            Map<String, Object> group, Integer classId,
             boolean setBySystem) {
-        LinkedHashMap<String, Object> refGroup = makeReference(classId);
+        Map<String, Object> refGroup = makeReference(classId);
         ArrayList<Object> operands = new ArrayList<Object>();
         operands.add(group);
         refGroup.put("operands", operands);
