diff --git a/src/main/antlr/annis/LICENSE b/src/main/antlr/annis/LICENSE
new file mode 100644
index 0000000..d8771da
--- /dev/null
+++ b/src/main/antlr/annis/LICENSE
@@ -0,0 +1,72 @@
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+    You must give any other recipients of the Work or Derivative Works a copy of this License; and
+    You must cause any modified files to carry prominent notices stating that You changed the files; and
+    You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+    If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+    You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
+APPENDIX: How to apply the Apache License to your work
+
+To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
+
+Copyright [yyyy] [name of copyright owner]
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
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 7815edd..880898a 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
@@ -547,8 +547,8 @@
                 ParseTree leftChildSpec = getFirstChildWithCat(node.getChild(i).getChild(0), "@l");
                 ParseTree rightChildSpec = getFirstChildWithCat(node.getChild(i).getChild(0), "@r");
                 if (leftChildSpec != null || rightChildSpec != null) {
-                    String frame = (leftChildSpec!=null) ? "frames:startswith" : "frames:endswith";
-                    LinkedHashMap<String,Object> positionGroup = KoralObjectGenerator.makePosition(new String[]{frame}, null);
+                    String frame = (leftChildSpec!=null) ? "frames:startsWith" : "frames:endsWith";
+                    LinkedHashMap<String,Object> positionGroup = KoralObjectGenerator.makePosition(new String[]{frame});
                     operand2 = KoralObjectGenerator.wrapInClass(operand2, ++classCounter);
                     ((ArrayList<Object>) positionGroup.get("operands")).add(group);
                     ((ArrayList<Object>) positionGroup.get("operands")).add(KoralObjectGenerator.makeReference(classCounter));
@@ -699,13 +699,14 @@
                     frames = new String[]{"frames:matches"}; 
                     break;
                 case "_l_":
-                    frames = new String[]{"frames:startswith"};
+                    frames = new String[]{"frames:startsWith", "frames:matches"};
                     break;
                 case "_r_":
-                    frames = new String[]{"frames:endswith"};
+                    frames = new String[]{"frames:endsWith", "frames:matches"};
                     break;
                 case "_i_":
-                    frames = new String[]{"frames:contains"};break;
+                    frames = new String[]{"frames:isAround"};
+                    break;
                 case "_o_":
                     frames = new String[]{"frames:overlapsLeft", "frames:overlapsRight"};
                     break;
@@ -718,7 +719,7 @@
             }
             //			relation.put("frames", frames);
             //			relation.put("sharedClasses", sharedClasses);
-            relation = KoralObjectGenerator.makePosition(frames, new String[]{});
+            relation = KoralObjectGenerator.makePosition(frames);
             relation.put("groupType", "position");
         } 
         else if (operator.equals("near")) {
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 0f638ee..8e41b38 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
@@ -34,1322 +34,1297 @@
 
     LinkedList<LinkedHashMap<String, Object>[]> toWrapStack = 
             new LinkedList<LinkedHashMap<String,Object>[]>();
-    /**
-     * Field for repetition query (Kleene + or * operations, or
-     * min/max queries: {2,4}
-     */
-    String repetition = "";
-    /**
-     * Global control structure for fieldGroups, keeps track of open
-     * fieldGroups.
-     */
-    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>();
-    /**
-     * Flag that indicates whether token fields or meta fields are
-     * currently being processed
-     */
-    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;
-    /**
-	 *
-	 */
-    int classCounter = 1;
-    boolean negate = false;
-
-    /**
-     * Allows for the definition of objects to be wrapped around the
-     * arguments of an operation. Each record in the table holds the
-     * 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.create();
-
-    /**
-     * Keeps track of all visited nodes in a tree
-     */
-    List<Tree> visited = new ArrayList<Tree>();
-
-    Integer stackedToWrap = 0;
-    /**
-     * A list of node categories that can be sequenced (i.e. which can
-     * be in a sequence with any number of other nodes in this list)
-     */
-    private final List<String> sequentiableNodeTypes = Arrays
-            .asList(new String[] { "OPWF", "OPLEM", "OPMORPH", "OPBEG",
-                    "OPEND", "OPIN", "OPBED", "OPELEM", "OPOR", "OPAND" });
-    /**
-     * Keeps track of sequenced nodes, i.e. nodes that implicitly
-     * govern a sequence, as in (C2PQ (OPWF der) (OPWF Mann)). This is
-     * necessary in order to know when to take the sequence off the
-     * object stack, as the sequence is introduced by the first child
-     * but cannot be closed after this first child in order not to
-     * lose its siblings
-     */
-    private LinkedList<Tree> sequencedNodes = new LinkedList<Tree>();
-
-    private boolean nodeHasSequentiableSiblings;
-
-    /**
-     * Keeps track of operands lists that are to be serialised in an
-     * inverted order (e.g. the IN() operator) compared to their AST
-     * representation.
-     */
-    private LinkedList<ArrayList<Object>> invertedOperandsLists = 
-            new LinkedList<ArrayList<Object>>();
-
-    /**
-     * @param tree
-     *            The syntax tree as returned by ANTLR
-     * @param parser
-     *            The ANTLR parser instance that generated the parse
-     *            tree
-     * @throws QueryException
-     */
-    public Cosmas2QueryProcessor (String query) {
-        KoralObjectGenerator.setQueryProcessor(this);
-        this.query = query;
-        process(query);
-        log.info(">>> " + requestMap.get("query") + " <<<");
-    }
-
-    @Override
-    public void process(String query) {
-        Tree tree = null;
-        tree = parseCosmasQuery(query);
-        log.info("Processing CosmasII query: " + query);
-        if (tree != null) {
-            log.debug("ANTLR parse tree: " + tree.toStringTree());
-            processNode(tree);
-        }
-    }
-
-    private void processNode(Tree node) {
-        // Top-down processing
-        if (visited.contains(node))
-            return;
-        else
-            visited.add(node);
-
-        String nodeCat = getNodeCat(node);
-        openNodeCats.push(nodeCat);
-
-        stackedObjects = 0;
-        stackedToWrap = 0;
-
-        if (verbose) {
-            System.err.println(" " + objectStack);
-            System.out.println(openNodeCats);
-        }
-
-        /* ***************************************
-         * Processing individual node categories *
-         * ***************************************
-         */
-
-        // Check for potential implicit sequences as in (C2PQ (OPWF
-        // der) (OPWF Mann)). The sequence is introduced
-        // by the first child if it (and its siblings) is
-        // sequentiable.
-        if (sequentiableNodeTypes.contains(nodeCat)) {
-            // for each node, check if parent has more than one child
-            // (-> could be implicit sequence)
-            Tree parent = node.getParent();
-            if (parent.getChildCount() > 1) {
-                // if node is first child of parent...
-                if (node == parent.getChild(0)) {
-                    nodeHasSequentiableSiblings = false;
-                    for (int i = 1; i < parent.getChildCount(); i++) {
-                        if (sequentiableNodeTypes.contains(getNodeCat(parent
-                                .getChild(i)))) {
-                            nodeHasSequentiableSiblings = true;
-                            continue;
-                        }
-                    }
-                    if (nodeHasSequentiableSiblings) {
-                        // Step I: create sequence
-                        LinkedHashMap<String, Object> sequence = 
-                                KoralObjectGenerator.makeGroup("sequence");
-                        // push sequence on object stack but don't
-                        // increment stackedObjects counter since
-                        // we've got to wait until the parent node is
-                        // processed - therefore, add the parent
-                        // to the sequencedNodes list and remove the
-                        // sequence from the stack when the parent
-                        // has been processed
-                        objectStack.push(sequence);
-                        sequencedNodes.push(parent);
-                        // Step II: decide where to put sequence
-                        putIntoSuperObject(sequence, 1);
-                    }
-                }
-            }
-        }
-
-        if (nodeCat.equals("OPWF") || nodeCat.equals("OPLEM")) {
-            processOPWF_OPLEM(node);
-        }
-
-        if (nodeCat.equals("OPMORPH")) {
-            processOPMORPH(node);
-        }
-
-        if (nodeCat.equals("OPELEM")) {
-            processOPELEM(node);
-        }
-
-        if (nodeCat.equals("OPLABEL")) {
-            processOPLABEL(node);
-        }
-
-        if (nodeCat.equals("OPAND") || nodeCat.equals("OPNOT")) {
-            processOPAND_OPNOT(node);
-        }
-
-        if (nodeCat.equals("OPOR")) {
-            processOPOR(node);
-        }
-
-        if (nodeCat.equals("OPPROX")) {
-            processOPPROX(node);
-        }
-
-        // inlcusion or overlap
-        if (nodeCat.equals("OPIN") || nodeCat.equals("OPOV")) {
-            processOPIN_OPOV(node);
-        }
-
-        // Wrap the argument of an #IN operator in a previously
-        // defined container
-        if (nodeCat.equals("ARG1") || nodeCat.equals("ARG2")) {
-            processARG1_ARG2(node);
-        }
-
-        if (nodeCat.equals("OPALL")) {
-            inOPALL = true;
-        }
-
-        if (nodeCat.equals("OPNHIT")) {
-            processOPNHIT(node);
-        }
-
-        if (nodeCat.equals("OPEND") || nodeCat.equals("OPBEG")) {
-            processOPEND_OPBEG(node);
-        }
-
-        if (nodeCat.equals("OPBED")) {
-            processOPBED(node);
-        }
-        objectsToPop.push(stackedObjects);
-        toWrapsToPop.push(stackedToWrap);
-
-        /*
-         * ***************************************************************
-         * ***************************************************************
-         * recursion until 'request' node (root of tree) is processed
-         * *
-         * ***********************************************************
-         * ****
-         * ********************************************************
-         * *******
-         */
-        for (int i = 0; i < node.getChildCount(); i++) {
-            Tree child = node.getChild(i);
-            processNode(child);
-        }
-
-        /*
-         * *************************************************************
-         * Stuff that happens after processing the children of a node
-         * *
-         * ***********************************************************
-         * **
-         */
-
-        // remove sequence from object stack if node is implicitly
-        // sequenced
-        if (sequencedNodes.size() > 0) {
-            if (node == sequencedNodes.getFirst()) {
-                objectStack.pop();
-                sequencedNodes.pop();
-            }
-        }
-
-        for (int i = 0; i < objectsToPop.get(0); i++) {
-            objectStack.pop();
-        }
-        objectsToPop.pop();
-
-        // if (!toWrapStack.isEmpty())
-        // System.err.println(toWrapStack.get(0)[0]);
-        for (int i = 0; i < toWrapsToPop.get(0); i++) {
-            putIntoSuperObject(wrap(toWrapStack.pop()));
-        }
-        toWrapsToPop.pop();
-
-        if (nodeCat.equals("ARG2") && openNodeCats.get(1).equals("OPNOT")) {
-            negate = false;
-        }
-
-        if (nodeCat.equals("OPALL")) {
-            inOPALL = false;
-        }
-
-        openNodeCats.pop();
-    }
-
-    private void processOPEND_OPBEG(Tree node) {
-        // Step I: create group
-        String nodeCat = getNodeCat(node);
-        LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
-        beggroup.put("@type", "korap:reference");
-        beggroup.put("operation", "operation:focus");
-        ArrayList<Integer> spanRef = new ArrayList<Integer>();
-        if (nodeCat.equals("OPBEG")) {
-            spanRef.add(0);
-            spanRef.add(1);
-        }
-        else if (nodeCat.equals("OPEND")) {
-            spanRef.add(-1);
-            spanRef.add(1);
-        }
-        beggroup.put("spanRef", spanRef);
-        beggroup.put("operands", new ArrayList<Object>());
-        objectStack.push(beggroup);
-        stackedObjects++;
-
-        // Step II: decide where to put
-        putIntoSuperObject(beggroup, 1);
-    }
-
-    private void processOPBED(Tree node) {
-        // Node structure is (OPBED X+ (OPTS (TPBEG tpos*) (TPEND
-        // tpos*)))
-        // X is some segment, TPBEG or TPEND must be present
-        // (inclusive OR)
-        // tpos is a three-char string of the form "[+-]?[spt][ae]".
-        // s/p/t indicates span, a/e beginning/end, - means negation
-        // See C-II QL documentation for more detail:
-        // http://www.ids-mannheim.de/cosmas2/win-app/hilfe/suchanfrage/eingabe-grafisch/syntax/textpositionen.html
-
-        // Step I: create group
-        int optsChild = node.getChildCount() - 1;
-        Tree begConditions = getFirstChildWithCat(node.getChild(optsChild),
-                "TPBEG");
-        Tree endConditions = getFirstChildWithCat(node.getChild(optsChild),
-                "TPEND");
-
-        LinkedHashMap<String, Object> submatchgroup = 
-                KoralObjectGenerator.makeReference(classCounter);
-        ArrayList<Object> submatchOperands = new ArrayList<Object>();
-        submatchgroup.put("operands", submatchOperands);
-        putIntoSuperObject(submatchgroup);
-
-        // 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>>();
-        if (begConditions != null) {
-            for (Tree condition : getChildren(begConditions)) {
-                conditionGroups.add(processPositionCondition(condition,
-                        distributedOperands, "beg"));
-            }
-        }
-        if (endConditions != null) {
-            for (Tree condition : getChildren(endConditions)) {
-                conditionGroups.add(processPositionCondition(condition,
-                        distributedOperands, "end"));
-            }
-        }
-        // Step III: insert conditions. need to stack matches-groups
-        // because position groups may only have two operands
-        // indicates where to insert next condition group
-        ArrayList<Object> currentLowestOperands = submatchOperands; 
-        int conditionCount = 0;
-        for (LinkedHashMap<String, Object> conditionGroup : conditionGroups) {
-            conditionCount++;
-            if (conditionGroups.size() == 1) {
-                submatchOperands.add(conditionGroup);
-            }
-            else if (conditionCount < conditionGroups.size()) {
-                LinkedHashMap<String, Object> matchesGroup = KoralObjectGenerator
-                        .makePosition(new String[] { "frames:matches" },
-                                new String[0]);
-                @SuppressWarnings("unchecked")
-                ArrayList<Object> matchesOperands = 
-                    (ArrayList<Object>) matchesGroup.get("operands");
-                matchesOperands.add(conditionGroup);
-                // matches groups that are embedded at the second or
-                // lower level receive an additional
-                // focus to grep out only the query term to which the
-                // constraint applies
-                if (conditionCount > 1) {
-                    LinkedHashMap<String, Object> focus = 
-                            KoralObjectGenerator.makeReference(classCounter - 2);
-                    ArrayList<Object> focusOperands = new ArrayList<Object>();
-                    focus.put("operands", focusOperands);
-                    focusOperands.add(matchesGroup);
-                    currentLowestOperands.add(focus);
-                }
-                else {
-                    currentLowestOperands.add(matchesGroup);
-                }
-                currentLowestOperands = matchesOperands;
-            }
-            else {
-                currentLowestOperands.add(conditionGroup);
-            }
-        }
-    }
-
-    private void processOPNHIT(Tree node) {
-        Integer[] classRef = new Integer[] { classCounter + 1,
-                classCounter + 2 };
-        // classRef.add(classCounter + 1); // yes, do this twice (two
-        // classes)!
-        LinkedHashMap<String, Object> group = 
-                KoralObjectGenerator.makeReference(classCounter);
-        LinkedHashMap<String, Object> classRefCheck = 
-                KoralObjectGenerator.makeClassRefOp("classRefOp:inversion", classRef,
-                        classCounter);
-        ArrayList<Object> operands = new ArrayList<Object>();
-        operands.add(classRefCheck);
-        group.put("operands", operands);
-        classCounter++;
-        // direct child is OPPROX
-        wrapOperandInClass(node.getChild(0), 1, classCounter++); 
-        wrapOperandInClass(node.getChild(0), 2, classCounter++);
-        objectStack.push(classRefCheck);
-        stackedObjects++;
-        putIntoSuperObject(group, 1);
-    }
-
-    private void processARG1_ARG2(Tree node) {
-        String nodeCat = getNodeCat(node);
-        Tree parent = node.getParent();
-        if (operandWrap.containsRow(parent)) {
-            // Step I: create group
-            int argNr = nodeCat.equals("ARG1") ? 1 : 2;
-            LinkedHashMap<String, Object> container = operandWrap.row(parent)
-                    .get(argNr);
-            // Step II: ingest
-            if (container != null) {
-                objectStack.push(container);
-                stackedObjects++;
-                putIntoSuperObject(container, 1);
-            }
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void processOPIN_OPOV(Tree node) {
-        // Step I: create group
-        String nodeCat = getNodeCat(node);
-        wrapOperandInClass(node, 2, classCounter++);
-        wrapOperandInClass(node, 1, classCounter++);
-        // LinkedHashMap<String, Object> posgroup =
-        // makePosition(null);
-        LinkedHashMap<String, Object> posgroup = KoralObjectGenerator
-                .makeGroup("position");
-        LinkedHashMap<String, Object> positionOptions;
-        // posgroup
-        if (nodeCat.equals("OPIN")) {
-            positionOptions = parseOPINOptions(node);
-        }
-        else {
-            positionOptions = parseOPOVOptions(node);
-        }
-        posgroup.put("frames", positionOptions.get("frames"));
-        posgroup.put("frame", positionOptions.get("frame"));
-        if (positionOptions.containsKey("exclude")) {
-            posgroup.put("exclude", positionOptions.get("exclude"));
-        }
-        objectStack.push(posgroup);
-        // mark this an inverted operands object
-        invertedOperandsLists.push((ArrayList<Object>) posgroup.get("operands"));
-        stackedObjects++;
-        // Step II: wrap in focus and decide where to put
-        ArrayList<String> check = 
-                (ArrayList<String>) positionOptions.get("classRefCheck");
-        Integer[] classIn = 
-                new Integer[] { classCounter - 2, classCounter - 1 };
-        LinkedHashMap<String, Object> classRefCheck = 
-                KoralObjectGenerator.makeClassRefCheck(check, classIn,
-                        classCounter);
-        ((ArrayList<Object>) classRefCheck.get("operands")).add(posgroup);
-        LinkedHashMap<String, Object> focusGroup = null;
-        if ((boolean) positionOptions.get("matchall") == true) {
-            focusGroup = KoralObjectGenerator.makeClassRefOp("classRefOp:delete", 
-                    new Integer[]{classCounter++}, classCounter);
-            ((ArrayList<Object>) focusGroup.get("operands")).add(classRefCheck);
-        }
-        else { // match only first argument
-            focusGroup = KoralObjectGenerator.wrapInReference(classRefCheck,
-                    classCounter-1);
-            classCounter++;
-        }
-        // wrap in 'merge' operation if grouping option is set
-        if (positionOptions.containsKey("grouping")) {
-            if (positionOptions.get("grouping").equals(true)) {
-                LinkedHashMap<String, Object> mergeOperation = 
-                        KoralObjectGenerator.makeGroup("merge");
-                ArrayList<Object> mergeOperands = (ArrayList<Object>) mergeOperation.get("operands");
-                mergeOperands.add(focusGroup);
-                focusGroup = mergeOperation;
-            }
-        }
-        putIntoSuperObject(focusGroup, 1);
-    }
-
-    @SuppressWarnings("unchecked")
-    private void processOPPROX(Tree node) {
-        // collect info
-        Tree prox_opts = node.getChild(0);
-        Tree typ = prox_opts.getChild(0);
-        Tree dist_list = prox_opts.getChild(1);
-        // Step I: create group
-        LinkedHashMap<String, Object> group = KoralObjectGenerator
-                .makeGroup("sequence");
-
-        ArrayList<Object> constraints = new ArrayList<Object>();
-        boolean exclusion = typ.getChild(0).toStringTree().equals("EXCL");
-
-        boolean inOrder = false;
-        boolean invertedOperands = false;
-
-        group.put("inOrder", inOrder);
-        group.put("distances", constraints);
-
-        boolean putIntoOverlapDisjunction = false;
-
-        int min = 0, max = 0;
-        // possibly several distance constraints
-        for (int i = 0; i < dist_list.getChildCount(); i++) {
-            String direction = dist_list.getChild(i).getChild(0).getChild(0)
-                    .toStringTree().toLowerCase();
-            String minStr = dist_list.getChild(i).getChild(1).getChild(0)
-                    .toStringTree();
-            String maxStr = dist_list.getChild(i).getChild(1).getChild(1)
-                    .toStringTree();
-            String meas = dist_list.getChild(i).getChild(2).getChild(0)
-                    .toStringTree();
-            if (minStr.equals("VAL0")) {
-                minStr = "0";
-            }
-            min = Integer.parseInt(minStr);
-            max = Integer.parseInt(maxStr);
-            // If zero word-distance, wrap this sequence in a
-            // disjunction along with an overlap position
-            // between the two operands
-            /*
-             * XXX: This is currently deactivated. Uncomment to
-             * activate treatment of zero-word distances as
-             * overlap-alternatives (see google doc on special
-             * distances serialization)
-             * 
-             * if (meas.equals("w") && min == 0) { min = 1;
-             * putIntoOverlapDisjunction = true; }
+            /**
+             * Field for repetition query (Kleene + or * operations, or
+             * min/max queries: {2,4}
              */
-            if (!meas.equals("w") && min == 0) {
-                processSpanDistance(meas, min, max);
+            String repetition = "";
+            /**
+             * Global control structure for fieldGroups, keeps track of open
+             * fieldGroups.
+             */
+            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>();
+            /**
+             * Flag that indicates whether token fields or meta fields are
+             * currently being processed
+             */
+            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;
+            /**
+             *
+             */
+            int classCounter = 1;
+            boolean negate = false;
+
+            /**
+             * Allows for the definition of objects to be wrapped around the
+             * arguments of an operation. Each record in the table holds the
+             * 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.create();
+
+            /**
+             * Keeps track of all visited nodes in a tree
+             */
+            List<Tree> visited = new ArrayList<Tree>();
+
+            Integer stackedToWrap = 0;
+            /**
+             * A list of node categories that can be sequenced (i.e. which can
+             * be in a sequence with any number of other nodes in this list)
+             */
+            private final List<String> sequentiableNodeTypes = Arrays
+                    .asList(new String[] { "OPWF", "OPLEM", "OPMORPH", "OPBEG",
+                            "OPEND", "OPIN", "OPBED", "OPELEM", "OPOR", "OPAND" });
+            /**
+             * Keeps track of sequenced nodes, i.e. nodes that implicitly
+             * govern a sequence, as in (C2PQ (OPWF der) (OPWF Mann)). This is
+             * necessary in order to know when to take the sequence off the
+             * object stack, as the sequence is introduced by the first child
+             * but cannot be closed after this first child in order not to
+             * lose its siblings
+             */
+            private LinkedList<Tree> sequencedNodes = new LinkedList<Tree>();
+
+            private boolean nodeHasSequentiableSiblings;
+
+            /**
+             * Keeps track of operands lists that are to be serialised in an
+             * inverted order (e.g. the IN() operator) compared to their AST
+             * representation.
+             */
+            private LinkedList<ArrayList<Object>> invertedOperandsLists = 
+                    new LinkedList<ArrayList<Object>>();
+
+            /**
+             * @param tree
+             *            The syntax tree as returned by ANTLR
+             * @param parser
+             *            The ANTLR parser instance that generated the parse
+             *            tree
+             * @throws QueryException
+             */
+            public Cosmas2QueryProcessor (String query) {
+                KoralObjectGenerator.setQueryProcessor(this);
+                this.query = query;
+                process(query);
+                log.info(">>> " + requestMap.get("query") + " <<<");
             }
-            LinkedHashMap<String, Object> distance = KoralObjectGenerator
-                    .makeDistance(meas, min, max);
-            if (exclusion) {
-                distance.put("exclude", true);
-            }
-            // if (! openNodeCats.get(1).equals("OPNHIT")) {
-            constraints.add(distance);
-            // }
-            if (i == 0) {
-                if (direction.equals("plus")) {
-                    inOrder = true;
-                }
-                else if (direction.equals("minus")) {
-                    inOrder = true;
-                    invertedOperands = true;
-                }
-                else if (direction.equals("both")) {
-                    inOrder = false;
+
+            @Override
+            public void process(String query) {
+                Tree tree = null;
+                tree = parseCosmasQuery(query);
+                log.info("Processing CosmasII query: " + query);
+                if (tree != null) {
+                    log.debug("ANTLR parse tree: " + tree.toStringTree());
+                    processNode(tree);
                 }
             }
-        }
-        group.put("inOrder", inOrder);
-        LinkedHashMap<String, Object> embeddedSequence = group;
 
-        if (!(openNodeCats.get(1).equals("OPBEG")
-                || openNodeCats.get(1).equals("OPEND") 
-                || inOPALL 
-                || openNodeCats.get(1).equals("OPNHIT"))) {
-            wrapOperandInClass(node, 1, classCounter);
-            wrapOperandInClass(node, 2, classCounter);
-            // Deactivated, uncomment to wrap sequence in reference.
-//            group = KoralObjectGenerator.wrapInReference(group,
-//                    classCounter++);
-            classCounter++;
-        }
-        else if (openNodeCats.get(1).equals("OPNHIT")) {
-            LinkedHashMap<String, Object> repetition = KoralObjectGenerator
-                    .makeRepetition(min, max);
-            ((ArrayList<Object>) repetition.get("operands"))
-                    .add(KoralObjectGenerator.makeToken());
-            // TODO go on with this: put the repetition into a class
-            // and put it in between the operands
-            // -> what if there's several distance constraints. with
-            // different keys, like /w4,s0?
-        }
+            private void processNode(Tree node) {
+                // Top-down processing
+                if (visited.contains(node))
+                    return;
+                else
+                    visited.add(node);
 
-        LinkedHashMap<String, Object> sequence = null;
-        if (putIntoOverlapDisjunction) {
-            sequence = embeddedSequence;
-            group = KoralObjectGenerator.makeGroup("or");
-            ArrayList<Object> disjOperands = 
-                    (ArrayList<Object>) group.get("operands");
-            String[] sharedClasses = new String[] { "intersects" };
-            LinkedHashMap<String, Object> overlapsGroup = KoralObjectGenerator
-                    .makePosition(new String[0], sharedClasses);
+                String nodeCat = getNodeCat(node);
+                openNodeCats.push(nodeCat);
 
-            ArrayList<Object> overlapsOperands = 
-                    (ArrayList<Object>) overlapsGroup.get("operands");
-            // this ensures identity of the operands lists and thereby
-            // a distribution of the operands for both created objects
-            sequence.put("operands", overlapsOperands);
-            if (invertedOperands) {
-                invertedOperandsLists.push(overlapsOperands);
-            }
-            disjOperands.add(overlapsGroup);
-            disjOperands.add(KoralObjectGenerator.wrapInReference(sequence, 0));
-            // Step II: decide where to put
-            putIntoSuperObject(group, 0);
-            objectStack.push(sequence);
-        }
-        else {
-            if (invertedOperands) {
-                ArrayList<Object> operands = 
-                        (ArrayList<Object>) embeddedSequence.get("operands");
-                invertedOperandsLists.push(operands);
-            }
-            // Step II: decide where to put
-            putIntoSuperObject(group, 0);
-            objectStack.push(embeddedSequence);
-        }
-        stackedObjects++;
-        visited.add(node.getChild(0));
-    }
+                stackedObjects = 0;
+                stackedToWrap = 0;
 
-    private void processOPOR(Tree node) {
-        // Step I: create group
-        LinkedHashMap<String, Object> disjunction = new LinkedHashMap<String, Object>();
-        disjunction.put("@type", "korap:group");
-        disjunction.put("operation", "operation:or");
-        disjunction.put("operands", new ArrayList<Object>());
-        objectStack.push(disjunction);
-        stackedObjects++;
-        // Step II: decide where to put
-        putIntoSuperObject(disjunction, 1);
-    }
+                if (verbose) {
+                    System.err.println(" " + objectStack);
+                    System.out.println(openNodeCats);
+                }
 
-    private void processOPAND_OPNOT(Tree node) {
-        // Step I: create group
-        String nodeCat = getNodeCat(node);
-        LinkedHashMap<String, Object> distgroup = new LinkedHashMap<String, Object>();
-        distgroup.put("@type", "korap:group");
-        distgroup.put("operation", "operation:sequence");
-        ArrayList<Object> distances = new ArrayList<Object>();
-        LinkedHashMap<String, Object> zerodistance = new LinkedHashMap<String, Object>();
-        zerodistance.put("@type", "cosmas:distance");
-        zerodistance.put("key", "t");
-        zerodistance.put("min", 0);
-        zerodistance.put("max", 0);
-        if (nodeCat.equals("OPNOT"))
-            zerodistance.put("exclude", true);
-        distances.add(zerodistance);
-        distgroup.put("distances", distances);
-        distgroup.put("operands", new ArrayList<Object>());
-        objectStack.push(distgroup);
-        stackedObjects++;
-        // Step II: decide where to put
-        putIntoSuperObject(distgroup, 1);
-    }
-
-    private void processOPLABEL(Tree node) {
-        // Step I: create element
-        LinkedHashMap<String, Object> elem = new LinkedHashMap<String, Object>();
-        elem.put("@type", "korap:span");
-        elem.put("key", node.getChild(0).toStringTree().replaceAll("<|>", ""));
-        // Step II: decide where to put
-        putIntoSuperObject(elem);
-    }
-
-    @SuppressWarnings("unchecked")
-    private void processOPELEM(Tree node) {
-        // Step I: create element
-        LinkedHashMap<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).");
-            return;
-        }
-        else {
-            int elname = 0;
-            Tree elnameNode = getFirstChildWithCat(node, "ELNAME");
-            if (elnameNode != null) {
-                span.put("key", elnameNode.getChild(0).toStringTree()
-                        .toLowerCase());
-                elname = 1;
-            }
-            if (node.getChildCount() > elname) {
-                /*
-                 * Attributes can carry several values, like #ELEM(W
-                 * ANA != 'N V'), denoting a word whose POS is neither
-                 * N nor V. When seeing this, create a sub-termGroup
-                 * and put it into the top-level term group, but only
-                 * if there are other attributes in that group. If
-                 * not, put the several values as distinct
-                 * attr-val-pairs into the top-level group (in order
-                 * to avoid a top-level group that only contains a
-                 * sub-group).
+                /* ***************************************
+                 * Processing individual node categories *
+                 * ***************************************
                  */
-                LinkedHashMap<String, Object> termGroup = 
-                        KoralObjectGenerator.makeTermGroup("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.makeTerm();
-                        termGroupOperands.add(term);
-                        String layer = attrNode.getChild(0).toStringTree();
-                        String[] splitted = layer.split("/");
-                        if (splitted.length > 1) {
-                            term.put("foundry", splitted[0]);
-                            layer = splitted[1];
+
+                // Check for potential implicit sequences as in (C2PQ (OPWF
+                // der) (OPWF Mann)). The sequence is introduced
+                // by the first child if it (and its siblings) is
+                // sequentiable.
+                if (sequentiableNodeTypes.contains(nodeCat)) {
+                    // for each node, check if parent has more than one child
+                    // (-> could be implicit sequence)
+                    Tree parent = node.getParent();
+                    if (parent.getChildCount() > 1) {
+                        // if node is first child of parent...
+                        if (node == parent.getChild(0)) {
+                            nodeHasSequentiableSiblings = false;
+                            for (int i = 1; i < parent.getChildCount(); i++) {
+                                if (sequentiableNodeTypes.contains(getNodeCat(parent
+                                        .getChild(i)))) {
+                                    nodeHasSequentiableSiblings = true;
+                                    continue;
+                                }
+                            }
+                            if (nodeHasSequentiableSiblings) {
+                                // Step I: create sequence
+                                LinkedHashMap<String, Object> sequence = 
+                                        KoralObjectGenerator.makeGroup("sequence");
+                                // push sequence on object stack but don't
+                                // increment stackedObjects counter since
+                                // we've got to wait until the parent node is
+                                // processed - therefore, add the parent
+                                // to the sequencedNodes list and remove the
+                                // sequence from the stack when the parent
+                                // has been processed
+                                objectStack.push(sequence);
+                                sequencedNodes.push(parent);
+                                // Step II: decide where to put sequence
+                                putIntoSuperObject(sequence, 1);
+                            }
                         }
-                        term.put("layer", translateMorph(layer));
-                        term.put("key", attrNode.getChild(1).toStringTree());
-                        String match = getNodeCat(attrNode).equals("EQ") ? "eq":"ne";
-                        term.put("match", "match:" + match);
+                    }
+                }
+
+                if (nodeCat.equals("OPWF") || nodeCat.equals("OPLEM")) {
+                    processOPWF_OPLEM(node);
+                }
+
+                if (nodeCat.equals("OPMORPH")) {
+                    processOPMORPH(node);
+                }
+
+                if (nodeCat.equals("OPELEM")) {
+                    processOPELEM(node);
+                }
+
+                if (nodeCat.equals("OPLABEL")) {
+                    processOPLABEL(node);
+                }
+
+                if (nodeCat.equals("OPAND") || nodeCat.equals("OPNOT")) {
+                    processOPAND_OPNOT(node);
+                }
+
+                if (nodeCat.equals("OPOR")) {
+                    processOPOR(node);
+                }
+
+                if (nodeCat.equals("OPPROX")) {
+                    processOPPROX(node);
+                }
+
+                // inlcusion or overlap
+                if (nodeCat.equals("OPIN") || nodeCat.equals("OPOV")) {
+                    processOPIN_OPOV(node);
+                }
+
+                // Wrap the argument of an #IN operator in a previously
+                // defined container
+                if (nodeCat.equals("ARG1") || nodeCat.equals("ARG2")) {
+                    processARG1_ARG2(node);
+                }
+
+                if (nodeCat.equals("OPALL")) {
+                    inOPALL = true;
+                }
+
+                if (nodeCat.equals("OPNHIT")) {
+                    processOPNHIT(node);
+                }
+
+                if (nodeCat.equals("OPEND") || nodeCat.equals("OPBEG")) {
+                    processOPEND_OPBEG(node);
+                }
+
+                if (nodeCat.equals("OPBED")) {
+                    processOPBED(node);
+                }
+                objectsToPop.push(stackedObjects);
+                toWrapsToPop.push(stackedToWrap);
+
+                /*
+                 * ***************************************************************
+                 * ***************************************************************
+                 * recursion until 'request' node (root of tree) is processed
+                 * *
+                 * ***********************************************************
+                 * ****
+                 * ********************************************************
+                 * *******
+                 */
+                for (int i = 0; i < node.getChildCount(); i++) {
+                    Tree child = node.getChild(i);
+                    processNode(child);
+                }
+
+                /*
+                 * *************************************************************
+                 * Stuff that happens after processing the children of a node
+                 * *
+                 * ***********************************************************
+                 * **
+                 */
+
+                // remove sequence from object stack if node is implicitly
+                // sequenced
+                if (sequencedNodes.size() > 0) {
+                    if (node == sequencedNodes.getFirst()) {
+                        objectStack.pop();
+                        sequencedNodes.pop();
+                    }
+                }
+
+                for (int i = 0; i < objectsToPop.get(0); i++) {
+                    objectStack.pop();
+                }
+                objectsToPop.pop();
+
+                // if (!toWrapStack.isEmpty())
+                // System.err.println(toWrapStack.get(0)[0]);
+                for (int i = 0; i < toWrapsToPop.get(0); i++) {
+                    putIntoSuperObject(wrap(toWrapStack.pop()));
+                }
+                toWrapsToPop.pop();
+
+                if (nodeCat.equals("ARG2") && openNodeCats.get(1).equals("OPNOT")) {
+                    negate = false;
+                }
+
+                if (nodeCat.equals("OPALL")) {
+                    inOPALL = false;
+                }
+
+                openNodeCats.pop();
+            }
+
+            private void processOPEND_OPBEG(Tree node) {
+                // Step I: create group
+                String nodeCat = getNodeCat(node);
+                LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
+                beggroup.put("@type", "korap:reference");
+                beggroup.put("operation", "operation:focus");
+                ArrayList<Integer> spanRef = new ArrayList<Integer>();
+                if (nodeCat.equals("OPBEG")) {
+                    spanRef.add(0);
+                    spanRef.add(1);
+                }
+                else if (nodeCat.equals("OPEND")) {
+                    spanRef.add(-1);
+                    spanRef.add(1);
+                }
+                beggroup.put("spanRef", spanRef);
+                beggroup.put("operands", new ArrayList<Object>());
+                objectStack.push(beggroup);
+                stackedObjects++;
+
+                // Step II: decide where to put
+                putIntoSuperObject(beggroup, 1);
+            }
+
+            private void processOPBED(Tree node) {
+                // Node structure is (OPBED X+ (OPTS (TPBEG tpos*) (TPEND
+                // tpos*)))
+                // X is some segment, TPBEG or TPEND must be present
+                // (inclusive OR)
+                // tpos is a three-char string of the form "[+-]?[spt][ae]".
+                // s/p/t indicates span, a/e beginning/end, - means negation
+                // See C-II QL documentation for more detail:
+                // http://www.ids-mannheim.de/cosmas2/win-app/hilfe/suchanfrage/eingabe-grafisch/syntax/textpositionen.html
+
+                // Step I: create group
+                int optsChild = node.getChildCount() - 1;
+                Tree begConditions = getFirstChildWithCat(node.getChild(optsChild),
+                        "TPBEG");
+                Tree endConditions = getFirstChildWithCat(node.getChild(optsChild),
+                        "TPEND");
+
+                LinkedHashMap<String, Object> submatchgroup = 
+                        KoralObjectGenerator.makeReference(classCounter);
+                ArrayList<Object> submatchOperands = new ArrayList<Object>();
+                submatchgroup.put("operands", submatchOperands);
+                putIntoSuperObject(submatchgroup);
+
+                // 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>>();
+                if (begConditions != null) {
+                    for (Tree condition : getChildren(begConditions)) {
+                        conditionGroups.add(processPositionCondition(condition,
+                                distributedOperands, "beg"));
+                    }
+                }
+                if (endConditions != null) {
+                    for (Tree condition : getChildren(endConditions)) {
+                        conditionGroups.add(processPositionCondition(condition,
+                                distributedOperands, "end"));
+                    }
+                }
+                // Step III: insert conditions. need to stack matches-groups
+                // because position groups may only have two operands
+                // indicates where to insert next condition group
+                ArrayList<Object> currentLowestOperands = submatchOperands; 
+                int conditionCount = 0;
+                for (LinkedHashMap<String, Object> conditionGroup : conditionGroups) {
+                    conditionCount++;
+                    if (conditionGroups.size() == 1) {
+                        submatchOperands.add(conditionGroup);
+                    }
+                    else if (conditionCount < conditionGroups.size()) {
+                        LinkedHashMap<String, Object> matchesGroup = KoralObjectGenerator
+                                .makePosition(new String[] { "frames:matches" });
+                        @SuppressWarnings("unchecked")
+                        ArrayList<Object> matchesOperands = 
+                        (ArrayList<Object>) matchesGroup.get("operands");
+                        matchesOperands.add(conditionGroup);
+                        // matches groups that are embedded at the second or
+                        // lower level receive an additional
+                        // focus to grep out only the query term to which the
+                        // constraint applies
+                        if (conditionCount > 1) {
+                            LinkedHashMap<String, Object> focus = 
+                                    KoralObjectGenerator.makeReference(classCounter - 2);
+                            ArrayList<Object> focusOperands = new ArrayList<Object>();
+                            focus.put("operands", focusOperands);
+                            focusOperands.add(matchesGroup);
+                            currentLowestOperands.add(focus);
+                        }
+                        else {
+                            currentLowestOperands.add(matchesGroup);
+                        }
+                        currentLowestOperands = matchesOperands;
                     }
                     else {
-                        LinkedHashMap<String, Object> subTermGroup = 
-                                KoralObjectGenerator.makeTermGroup("and");
-                        ArrayList<Object> subTermGroupOperands = 
-                                (ArrayList<Object>) subTermGroup.get("operands");
-                        int j;
-                        for (j = 1; j < attrNode.getChildCount(); j++) {
-                            LinkedHashMap<String, Object> term = 
-                                    KoralObjectGenerator.makeTerm();
-                            String layer = attrNode.getChild(0).toStringTree();
-                            String[] splitted = layer.split("/");
-                            if (splitted.length > 1) {
-                                term.put("foundry", splitted[0]);
-                                layer = splitted[1];
-                            }
-                            term.put("layer", translateMorph(layer));
-                            term.put("key", attrNode.getChild(j).toStringTree());
-                            String match = 
-                                    getNodeCat(attrNode).equals("EQ") ? "eq" : "ne";
-                            term.put("match", "match:" + match);
-                            if (node.getChildCount() == elname + 1) {
-                                termGroupOperands.add(term);
-                            }
-                            else {
-                                subTermGroupOperands.add(term);
-                            }
+                        currentLowestOperands.add(conditionGroup);
+                    }
+                }
+            }
+
+            private void processOPNHIT(Tree node) {
+                Integer[] classRef = new Integer[] { classCounter + 1,
+                        classCounter + 2 };
+                // classRef.add(classCounter + 1); // yes, do this twice (two
+                // classes)!
+                LinkedHashMap<String, Object> group = 
+                        KoralObjectGenerator.makeReference(classCounter);
+                LinkedHashMap<String, Object> classRefCheck = 
+                        KoralObjectGenerator.makeClassRefOp("classRefOp:inversion", classRef,
+                                classCounter);
+                ArrayList<Object> operands = new ArrayList<Object>();
+                operands.add(classRefCheck);
+                group.put("operands", operands);
+                classCounter++;
+                // direct child is OPPROX
+                wrapOperandInClass(node.getChild(0), 1, classCounter++); 
+                wrapOperandInClass(node.getChild(0), 2, classCounter++);
+                objectStack.push(classRefCheck);
+                stackedObjects++;
+                putIntoSuperObject(group, 1);
+            }
+
+            private void processARG1_ARG2(Tree node) {
+                String nodeCat = getNodeCat(node);
+                Tree parent = node.getParent();
+                if (operandWrap.containsRow(parent)) {
+                    // Step I: create group
+                    int argNr = nodeCat.equals("ARG1") ? 1 : 2;
+                    LinkedHashMap<String, Object> container = operandWrap.row(parent)
+                            .get(argNr);
+                    // Step II: ingest
+                    if (container != null) {
+                        objectStack.push(container);
+                        stackedObjects++;
+                        putIntoSuperObject(container, 1);
+                    }
+                }
+            }
+
+            @SuppressWarnings("unchecked")
+            private void processOPIN_OPOV(Tree node) {
+                // Step I: create group
+                String nodeCat = getNodeCat(node);
+                wrapOperandInClass(node, 2, classCounter++);
+                wrapOperandInClass(node, 1, classCounter++);
+                // LinkedHashMap<String, Object> posgroup =
+                // makePosition(null);
+                LinkedHashMap<String, Object> posGroup = KoralObjectGenerator
+                        .makeGroup("position");
+                LinkedHashMap<String, Object> positionOptions;
+                // posgroup
+                if (nodeCat.equals("OPIN")) {
+                    positionOptions = parseOPINOptions(node);
+                }
+                else {
+                    positionOptions = parseOPOVOptions(node);
+                }
+                posGroup.put("frames", positionOptions.get("frames"));
+                posGroup.put("frame", positionOptions.get("frame"));
+                if (positionOptions.containsKey("exclude")) {
+                    posGroup.put("exclude", positionOptions.get("exclude"));
+                }
+                objectStack.push(posGroup);
+                // mark this an inverted operands object
+                invertedOperandsLists.push((ArrayList<Object>) posGroup.get("operands"));
+                stackedObjects++;
+                // Step II: wrap in classRefCheck and/or focus and decide where to put
+                ArrayList<String> check = 
+                        (ArrayList<String>) positionOptions.get("classRefCheck");
+                Integer[] classIn = 
+                        new Integer[] { classCounter - 2, classCounter - 1 };
+                LinkedHashMap<String, Object> topGroup;
+                if (! check.isEmpty()) {
+                    // wrap position in a classRefCheck
+                    topGroup = 
+                            KoralObjectGenerator.makeClassRefCheck(check, classIn,
+                                    classCounter);
+                    ((ArrayList<Object>) topGroup.get("operands")).add(posGroup);
+                } else {
+                    topGroup = posGroup;
+                }
+                LinkedHashMap<String, Object> focusGroup = null;
+                if ((boolean) positionOptions.get("matchall") == true) {
+                    focusGroup = KoralObjectGenerator.makeClassRefOp("classRefOp:delete", 
+                            new Integer[]{classCounter++}, classCounter);
+                    ((ArrayList<Object>) focusGroup.get("operands")).add(topGroup);
+                }
+                else { // match only first argument
+                    focusGroup = KoralObjectGenerator.wrapInReference(topGroup,
+                            classCounter-1);
+                    classCounter++;
+                }
+                // wrap in 'merge' operation if grouping option is set
+                if (positionOptions.containsKey("grouping")) {
+                    if (positionOptions.get("grouping").equals(true)) {
+                        LinkedHashMap<String, Object> mergeOperation = 
+                                KoralObjectGenerator.makeGroup("merge");
+                        ArrayList<Object> mergeOperands = (ArrayList<Object>) mergeOperation.get("operands");
+                        mergeOperands.add(focusGroup);
+                        focusGroup = mergeOperation;
+                    }
+                }
+                putIntoSuperObject(focusGroup, 1);
+            }
+
+            @SuppressWarnings("unchecked")
+            private void processOPPROX(Tree node) {
+                // collect info
+                Tree prox_opts = node.getChild(0);
+                Tree typ = prox_opts.getChild(0);
+                Tree dist_list = prox_opts.getChild(1);
+                // Step I: create group
+                LinkedHashMap<String, Object> group = KoralObjectGenerator
+                        .makeGroup("sequence");
+
+                ArrayList<Object> constraints = new ArrayList<Object>();
+                boolean exclusion = typ.getChild(0).toStringTree().equals("EXCL");
+
+                boolean inOrder = false;
+                boolean invertedOperands = false;
+
+                group.put("inOrder", inOrder);
+                group.put("distances", constraints);
+
+                boolean putIntoOverlapDisjunction = false;
+
+                int min = 0, max = 0;
+                // possibly several distance constraints
+                for (int i = 0; i < dist_list.getChildCount(); i++) {
+                    String direction = dist_list.getChild(i).getChild(0).getChild(0)
+                            .toStringTree().toLowerCase();
+                    String minStr = dist_list.getChild(i).getChild(1).getChild(0)
+                            .toStringTree();
+                    String maxStr = dist_list.getChild(i).getChild(1).getChild(1)
+                            .toStringTree();
+                    String meas = dist_list.getChild(i).getChild(2).getChild(0)
+                            .toStringTree();
+                    if (minStr.equals("VAL0")) {
+                        minStr = "0";
+                    }
+                    min = Integer.parseInt(minStr);
+                    max = Integer.parseInt(maxStr);
+                    // If zero word-distance, wrap this sequence in a
+                    // disjunction along with an overlap position
+                    // between the two operands
+                    /*
+                     * XXX: This is currently deactivated. Uncomment to
+                     * activate treatment of zero-word distances as
+                     * overlap-alternatives (see google doc on special
+                     * distances serialization)
+                     * 
+                     * if (meas.equals("w") && min == 0) { min = 1;
+                     * putIntoOverlapDisjunction = true; }
+                     */
+                    if (!meas.equals("w") && min == 0) {
+                        processSpanDistance(meas, min, max);
+                    }
+                    LinkedHashMap<String, Object> distance = KoralObjectGenerator
+                            .makeDistance(meas, min, max);
+                    if (exclusion) {
+                        distance.put("exclude", true);
+                    }
+                    // if (! openNodeCats.get(1).equals("OPNHIT")) {
+                    constraints.add(distance);
+                    // }
+                    if (i == 0) {
+                        if (direction.equals("plus")) {
+                            inOrder = true;
                         }
-                        if (node.getChildCount() > elname + 1) {
-                            termGroupOperands.add(subTermGroup);
+                        else if (direction.equals("minus")) {
+                            inOrder = true;
+                            invertedOperands = true;
+                        }
+                        else if (direction.equals("both")) {
+                            inOrder = false;
                         }
                     }
-                    if (getNodeCat(attrNode).equals("NOTEQ"))
-                        negate = true;
                 }
-                // 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);
+                group.put("inOrder", inOrder);
+                LinkedHashMap<String, Object> embeddedSequence = group;
+
+                if (!(openNodeCats.get(1).equals("OPBEG")
+                        || openNodeCats.get(1).equals("OPEND") 
+                        || inOPALL 
+                        || openNodeCats.get(1).equals("OPNHIT"))) {
+                    wrapOperandInClass(node, 1, classCounter);
+                    wrapOperandInClass(node, 2, classCounter);
+                    // Deactivated, uncomment to wrap sequence in reference.
+                    //            group = KoralObjectGenerator.wrapInReference(group,
+                    //                    classCounter++);
+                    classCounter++;
                 }
-                span.put("attr", termGroup);
-            }
-        }
-        // Step II: decide where to put
-        putIntoSuperObject(span);
-    }
-
-    private void processOPMORPH(Tree node) {
-        // Step I: get info
-        String[] morphterms = 
-                node.getChild(0).toStringTree().replace(" ", "").split("&");
-        LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
-        ArrayList<Object> terms = new ArrayList<Object>();
-        LinkedHashMap<String, Object> fieldMap = null;
-        // regex group #2 is foundry, #4 layer, #5 operator,
-        // #6 key, #8 value
-        String wordOrRegex = "\\w+|\".+?\"";
-        Pattern p = Pattern
-                .compile("((\\w+)/)?((\\w*)(!?=))?("+wordOrRegex+")(:("+wordOrRegex+"))?");
-        Matcher m;
-        for (String morphterm : morphterms) {
-            m = p.matcher(morphterm);
-            if (!m.matches()) {
-                addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
-                        "Something went wrong parsing the argument in MORPH().");
-                requestMap.put("query", new LinkedHashMap<String, Object>());
-                return;
-            }
-
-            fieldMap = new LinkedHashMap<String, Object>();
-            fieldMap.put("@type", "korap:term");
-
-            if (m.group(2) != null)
-                fieldMap.put("foundry", m.group(2));
-            if (m.group(4) != null)
-                fieldMap.put("layer", m.group(4));
-            if (m.group(5) != null) {
-                if ("!=".equals(m.group(5)))
-                    negate = !negate;
-            }
-            if (m.group(6) != null) {
-                String key = m.group(6);
-                if (key.startsWith("\"") && key.endsWith("\"")) {
-                    key = key.substring(1, key.length()-1);
-                    fieldMap.put("type", "type:regex");
+                else if (openNodeCats.get(1).equals("OPNHIT")) {
+                    LinkedHashMap<String, Object> repetition = KoralObjectGenerator
+                            .makeRepetition(min, max);
+                    ((ArrayList<Object>) repetition.get("operands"))
+                    .add(KoralObjectGenerator.makeToken());
+                    // TODO go on with this: put the repetition into a class
+                    // and put it in between the operands
+                    // -> what if there's several distance constraints. with
+                    // different keys, like /w4,s0?
                 }
-                fieldMap.put("key", key);
-            }
-                
-            if (m.group(8) != null) {
-                String value = m.group(8);
-                if (value.startsWith("\"") && value.endsWith("\"")) {
-                    value = value.substring(1, value.length()-1);
-                    fieldMap.put("type", "type:regex");
+
+                //        LinkedHashMap<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
+                //                    .makePosition(new String[0]);
+                //
+                //            ArrayList<Object> overlapsOperands = 
+                //                    (ArrayList<Object>) overlapsGroup.get("operands");
+                //            // this ensures identity of the operands lists and thereby
+                //            // a distribution of the operands for both created objects
+                //            sequence.put("operands", overlapsOperands);
+                //            if (invertedOperands) {
+                //                invertedOperandsLists.push(overlapsOperands);
+                //            }
+                //            disjOperands.add(overlapsGroup);
+                //            disjOperands.add(KoralObjectGenerator.wrapInReference(sequence, 0));
+                //            // Step II: decide where to put
+                //            putIntoSuperObject(group, 0);
+                //            objectStack.push(sequence);
+                //        }
+                //        else {
+                if (invertedOperands) {
+                    ArrayList<Object> operands = 
+                            (ArrayList<Object>) embeddedSequence.get("operands");
+                    invertedOperandsLists.push(operands);
                 }
-                fieldMap.put("value", value);
+                // Step II: decide where to put
+                putIntoSuperObject(group, 0);
+                objectStack.push(embeddedSequence);
+                //        }
+                stackedObjects++;
+                visited.add(node.getChild(0));
             }
 
-            // negate field (see above)
-            if (negate) {
-                fieldMap.put("match", "match:ne");
+            private void processOPOR(Tree node) {
+                // Step I: create group
+                LinkedHashMap<String, Object> disjunction = new LinkedHashMap<String, Object>();
+                disjunction.put("@type", "korap:group");
+                disjunction.put("operation", "operation:or");
+                disjunction.put("operands", new ArrayList<Object>());
+                objectStack.push(disjunction);
+                stackedObjects++;
+                // Step II: decide where to put
+                putIntoSuperObject(disjunction, 1);
             }
-            else {
-                fieldMap.put("match", "match:eq");
+
+            private void processOPAND_OPNOT(Tree node) {
+                // Step I: create group
+                String nodeCat = getNodeCat(node);
+                LinkedHashMap<String, Object> distgroup = new LinkedHashMap<String, Object>();
+                distgroup.put("@type", "korap:group");
+                distgroup.put("operation", "operation:sequence");
+                ArrayList<Object> distances = new ArrayList<Object>();
+                LinkedHashMap<String, Object> zerodistance = new LinkedHashMap<String, Object>();
+                zerodistance.put("@type", "cosmas:distance");
+                zerodistance.put("key", "t");
+                zerodistance.put("min", 0);
+                zerodistance.put("max", 0);
+                if (nodeCat.equals("OPNOT"))
+                    zerodistance.put("exclude", true);
+                distances.add(zerodistance);
+                distgroup.put("distances", distances);
+                distgroup.put("operands", new ArrayList<Object>());
+                objectStack.push(distgroup);
+                stackedObjects++;
+                // Step II: decide where to put
+                putIntoSuperObject(distgroup, 1);
             }
-            terms.add(fieldMap);
-        }
-        if (morphterms.length == 1) {
-            token.put("wrap", fieldMap);
-        }
-        else {
-            LinkedHashMap<String, Object> termGroup = 
-                    KoralObjectGenerator.makeTermGroup("and");
-            termGroup.put("operands", terms);
-            token.put("wrap", termGroup);
-        }
-        // Step II: decide where to put
-        putIntoSuperObject(token, 0);
-        visited.add(node.getChild(0));
-    }
 
-    /**
-     * Nodes introducing tokens. Process all in the same manner,
-     * except for the fieldMap entry
-     * 
-     * @param node
-     */
-    private void processOPWF_OPLEM(Tree node) {
-        String nodeCat = getNodeCat(node);
-        // Step I: get info
-        LinkedHashMap<String, Object> token = 
-                new LinkedHashMap<String, Object>();
-        token.put("@type", "korap:token");
-        objectStack.push(token);
-        stackedObjects++;
-        LinkedHashMap<String, Object> fieldMap = 
-                new LinkedHashMap<String, Object>();
-        token.put("wrap", fieldMap);
-
-        fieldMap.put("@type", "korap:term");
-        // make category-specific fieldMap entry
-        String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
-        String value = node.getChild(0).toStringTree().replaceAll("\"", "");
-        // check for wildcard string
-        Pattern p = Pattern.compile("[+*?]");
-        Matcher m = p.matcher(value);
-        if (m.find())
-            fieldMap.put("type", "type:wildcard");
-
-        if (value.startsWith("$")) {
-            value = value.substring(1);
-            fieldMap.put("caseInsensitive", true);
-        }
-
-        fieldMap.put("key", value);
-        fieldMap.put("layer", attr);
-
-        // negate field (see above)
-        if (negate) {
-            fieldMap.put("match", "match:ne");
-        }
-        else {
-            fieldMap.put("match", "match:eq");
-        }
-        // Step II: decide where to put
-        if (!hasChild(node, "TPOS")) {
-            putIntoSuperObject(token, 1);
-            visited.add(node.getChild(0));
-        }
-        else {
-            // TODO
-        }
-    }
-
-    private void processSpanDistance(String meas, int min, int max) {
-        // Do stuff here in case we'll decide one day to treat span distances
-        // in a special way (see GDoc Special Distances Serialization).
-    }
-
-    /**
-     * Registers an entry in the {@link #operandWrap} table in order
-     * to allow an operator's arguments (or only one of them) to be
-     * wrapped in a class group.
-     * 
-     * @param node
-     *            The operator node (parent node of the ARG1/ARG2
-     *            node)
-     * @param arg
-     *            The argument number (1 or 2)
-     * @param cls
-     *            The class id.
-     */
-    private void wrapOperandInClass(Tree node, int arg, int cls) {
-        LinkedHashMap<String, Object> clsGroup = 
-                KoralObjectGenerator.makeSpanClass(cls);
-        wrapOperand(node, arg, clsGroup);
-    }
-
-    /**
-     * Registers an entry in the {@link #operandWrap} table in order
-     * to allow an operator's arguments (or only one of them) to be
-     * wrapped in an arbitrary object, e.g. a reference group.
-     * 
-     * @param node
-     *            The operator node (parent node of the ARG1/ARG2
-     *            node)
-     * @param arg
-     *            The argument number (1 or 2)
-     * @param container
-     *            The object in whose operand list the argument shall
-     *            be wrapped.
-     */
-    private void wrapOperand(Tree node, int arg,
-            LinkedHashMap<String, Object> container) {
-        operandWrap.put(node, arg, container);
-    }
-
-    private Object translateMorph(String layer) {
-        // might be extended...
-        if (layer.equals("ANA"))
-            return ResourceMapper.descriptor2policy("ANA");
-        else
-            return layer;
-
-    }
-
-    @SuppressWarnings("unchecked")
-    /**
-     * Processes individual position conditions as provided in the OPTS node under the OPBEG node.
-     * #BEG allows to specify position constrains that apply to the beginning or the end of the subquery X.
-     * E.g., in #BEG(X, tpos/tpos), the 'tpos' constraints before the slash indicate conditions that apply 
-     * to the beginning of X, those after the slash are conditions that apply to the end of X.
-     * See the official C-II documentation for more details. <br/><br/>
-     * What's important here is what follows: <br/>
-     * Assume the query #BED(der Mann, sa/pa). This means that <b>the beginning<b/> of "der Mann" stands at
-     * the beginning of a sentence and that <b>the end</b> (because this constraint comes after the slash) stands at the 
-     * beginning of a paragraph. The "end" means the last item, here "Mann", so this token comes at the beginning
-     * of a paragraph. To capture this, we choose spanRefs: The last item of X matches the first item of the span (here: P). 
-     * @param cond
-     * @param distributedOperands
-     * @param mode
-     * @return
-     */
-    private LinkedHashMap<String, Object> processPositionCondition(Tree cond,
-            ArrayList<Object> distributedOperands, String mode) {
-        boolean negated = false;
-        String elem; // the 'span' (s/p/t)
-        String position = "frames:matches"; // default
-        // spanRef to be used for the element ('span')
-        Integer[] elemSpanRef = null;
-        // spanRef to be used for the subquery X
-        Integer[] hitSpanRef = null; 
-
-        String nodeString = cond.toStringTree();
-        if (nodeString.startsWith("-")) {
-            negated = true;
-            nodeString = nodeString.substring(1);
-        }
-        else if (nodeString.startsWith("+")) {
-            nodeString = nodeString.substring(1);
-        }
-        elem = nodeString.substring(0, 1);
-        nodeString = nodeString.substring(1);
-        // in cases where the end of X shall match the beginning of
-        // the span, or vice versa,
-        // we need to define spanRefs
-        if (mode.equals("beg")) {
-            if (nodeString.equals("a")) {
-                position = "frames:startswith";
+            private void processOPLABEL(Tree node) {
+                // Step I: create element
+                LinkedHashMap<String, Object> elem = new LinkedHashMap<String, Object>();
+                elem.put("@type", "korap:span");
+                elem.put("key", node.getChild(0).toStringTree().replaceAll("<|>", ""));
+                // Step II: decide where to put
+                putIntoSuperObject(elem);
             }
-            else if (nodeString.equals("e")) {
-                hitSpanRef = new Integer[] { 0, 1 };
-                elemSpanRef = new Integer[] { -1, 1 };
+
+            @SuppressWarnings("unchecked")
+            private void processOPELEM(Tree node) {
+                // Step I: create element
+                LinkedHashMap<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).");
+                    return;
+                }
+                else {
+                    int elname = 0;
+                    Tree elnameNode = getFirstChildWithCat(node, "ELNAME");
+                    if (elnameNode != null) {
+                        span.put("key", elnameNode.getChild(0).toStringTree()
+                                .toLowerCase());
+                        elname = 1;
+                    }
+                    if (node.getChildCount() > elname) {
+                        /*
+                         * Attributes can carry several values, like #ELEM(W
+                         * ANA != 'N V'), denoting a word whose POS is neither
+                         * N nor V. When seeing this, create a sub-termGroup
+                         * and put it into the top-level term group, but only
+                         * if there are other attributes in that group. If
+                         * not, put the several values as distinct
+                         * attr-val-pairs into the top-level group (in order
+                         * to avoid a top-level group that only contains a
+                         * sub-group).
+                         */
+                        LinkedHashMap<String, Object> termGroup = 
+                                KoralObjectGenerator.makeTermGroup("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.makeTerm();
+                                termGroupOperands.add(term);
+                                String layer = attrNode.getChild(0).toStringTree();
+                                String[] splitted = layer.split("/");
+                                if (splitted.length > 1) {
+                                    term.put("foundry", splitted[0]);
+                                    layer = splitted[1];
+                                }
+                                term.put("layer", translateMorph(layer));
+                                term.put("key", attrNode.getChild(1).toStringTree());
+                                String match = getNodeCat(attrNode).equals("EQ") ? "eq":"ne";
+                                term.put("match", "match:" + match);
+                            }
+                            else {
+                                LinkedHashMap<String, Object> subTermGroup = 
+                                        KoralObjectGenerator.makeTermGroup("and");
+                                ArrayList<Object> subTermGroupOperands = 
+                                        (ArrayList<Object>) subTermGroup.get("operands");
+                                int j;
+                                for (j = 1; j < attrNode.getChildCount(); j++) {
+                                    LinkedHashMap<String, Object> term = 
+                                            KoralObjectGenerator.makeTerm();
+                                    String layer = attrNode.getChild(0).toStringTree();
+                                    String[] splitted = layer.split("/");
+                                    if (splitted.length > 1) {
+                                        term.put("foundry", splitted[0]);
+                                        layer = splitted[1];
+                                    }
+                                    term.put("layer", translateMorph(layer));
+                                    term.put("key", attrNode.getChild(j).toStringTree());
+                                    String match = 
+                                            getNodeCat(attrNode).equals("EQ") ? "eq" : "ne";
+                                    term.put("match", "match:" + match);
+                                    if (node.getChildCount() == elname + 1) {
+                                        termGroupOperands.add(term);
+                                    }
+                                    else {
+                                        subTermGroupOperands.add(term);
+                                    }
+                                }
+                                if (node.getChildCount() > elname + 1) {
+                                    termGroupOperands.add(subTermGroup);
+                                }
+                            }
+                            if (getNodeCat(attrNode).equals("NOTEQ"))
+                                negate = true;
+                        }
+                        // 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);
+                        }
+                        span.put("attr", termGroup);
+                    }
+                }
+                // Step II: decide where to put
+                putIntoSuperObject(span);
             }
-        }
-        else if (mode.equals("end")) {
-            if (nodeString.equals("e")) {
-                position = "frames:endswith";
+
+            private void processOPMORPH(Tree node) {
+                // Step I: get info
+                String[] morphterms = 
+                        node.getChild(0).toStringTree().replace(" ", "").split("&");
+                LinkedHashMap<String, Object> token = KoralObjectGenerator.makeToken();
+                ArrayList<Object> terms = new ArrayList<Object>();
+                LinkedHashMap<String, Object> fieldMap = null;
+                // regex group #2 is foundry, #4 layer, #5 operator,
+                // #6 key, #8 value
+                String wordOrRegex = "\\w+|\".+?\"";
+                Pattern p = Pattern
+                        .compile("((\\w+)/)?((\\w*)(!?=))?("+wordOrRegex+")(:("+wordOrRegex+"))?");
+                Matcher m;
+                for (String morphterm : morphterms) {
+                    m = p.matcher(morphterm);
+                    if (!m.matches()) {
+                        addError(StatusCodes.INCOMPATIBLE_OPERATOR_AND_OPERAND,
+                                "Something went wrong parsing the argument in MORPH().");
+                        requestMap.put("query", new LinkedHashMap<String, Object>());
+                        return;
+                    }
+
+                    fieldMap = new LinkedHashMap<String, Object>();
+                    fieldMap.put("@type", "korap:term");
+
+                    if (m.group(2) != null)
+                        fieldMap.put("foundry", m.group(2));
+                    if (m.group(4) != null)
+                        fieldMap.put("layer", m.group(4));
+                    if (m.group(5) != null) {
+                        if ("!=".equals(m.group(5)))
+                            negate = !negate;
+                    }
+                    if (m.group(6) != null) {
+                        String key = m.group(6);
+                        if (key.startsWith("\"") && key.endsWith("\"")) {
+                            key = key.substring(1, key.length()-1);
+                            fieldMap.put("type", "type:regex");
+                        }
+                        fieldMap.put("key", key);
+                    }
+
+                    if (m.group(8) != null) {
+                        String value = m.group(8);
+                        if (value.startsWith("\"") && value.endsWith("\"")) {
+                            value = value.substring(1, value.length()-1);
+                            fieldMap.put("type", "type:regex");
+                        }
+                        fieldMap.put("value", value);
+                    }
+
+                    // negate field (see above)
+                    if (negate) {
+                        fieldMap.put("match", "match:ne");
+                    }
+                    else {
+                        fieldMap.put("match", "match:eq");
+                    }
+                    terms.add(fieldMap);
+                }
+                if (morphterms.length == 1) {
+                    token.put("wrap", fieldMap);
+                }
+                else {
+                    LinkedHashMap<String, Object> termGroup = 
+                            KoralObjectGenerator.makeTermGroup("and");
+                    termGroup.put("operands", terms);
+                    token.put("wrap", termGroup);
+                }
+                // Step II: decide where to put
+                putIntoSuperObject(token, 0);
+                visited.add(node.getChild(0));
             }
-            else if (nodeString.equals("a")) {
-                hitSpanRef = new Integer[] { 0, 1 };
-                elemSpanRef = new Integer[] { -1, 1 };
+
+            /**
+             * Nodes introducing tokens. Process all in the same manner,
+             * except for the fieldMap entry
+             * 
+             * @param node
+             */
+            private void processOPWF_OPLEM(Tree node) {
+                String nodeCat = getNodeCat(node);
+                // Step I: get info
+                LinkedHashMap<String, Object> token = 
+                        new LinkedHashMap<String, Object>();
+                token.put("@type", "korap:token");
+                objectStack.push(token);
+                stackedObjects++;
+                LinkedHashMap<String, Object> fieldMap = 
+                        new LinkedHashMap<String, Object>();
+                token.put("wrap", fieldMap);
+
+                fieldMap.put("@type", "korap:term");
+                // make category-specific fieldMap entry
+                String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
+                String value = node.getChild(0).toStringTree().replaceAll("\"", "");
+                // check for wildcard string
+                Pattern p = Pattern.compile("[+*?]");
+                Matcher m = p.matcher(value);
+                if (m.find())
+                    fieldMap.put("type", "type:wildcard");
+
+                if (value.startsWith("$")) {
+                    value = value.substring(1);
+                    fieldMap.put("caseInsensitive", true);
+                }
+
+                fieldMap.put("key", value);
+                fieldMap.put("layer", attr);
+
+                // negate field (see above)
+                if (negate) {
+                    fieldMap.put("match", "match:ne");
+                }
+                else {
+                    fieldMap.put("match", "match:eq");
+                }
+                // Step II: decide where to put
+                if (!hasChild(node, "TPOS")) {
+                    putIntoSuperObject(token, 1);
+                    visited.add(node.getChild(0));
+                }
+                else {
+                    // TODO
+                }
             }
-        }
-        // Create the position group and add the span and the subquery
-        // as operands, possibly wrapped in spanRefs
-        LinkedHashMap<String, Object> positionGroup = KoralObjectGenerator
-                .makePosition(new String[] { position }, new String[0]);
-        if (negated)
-            positionGroup.put("exclude", true);
-        ArrayList<Object> posOperands = new ArrayList<Object>();
-        LinkedHashMap<String, Object> classGroup = 
-                KoralObjectGenerator.makeSpanClass(classCounter++);
-        classGroup.put("operands", distributedOperands);
-        positionGroup.put("operands", posOperands);
-        LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
-        span.put("@type", "korap:span");
-        span.put("key", elem);
-        objectStack.push(classGroup);
-        if (hitSpanRef != null) {
-            LinkedHashMap<String, Object> spanRefAroundHit = 
-                    KoralObjectGenerator.makeSpanReference(hitSpanRef, "focus");
-            ((ArrayList<Object>) spanRefAroundHit.get("operands"))
+
+            private void processSpanDistance(String meas, int min, int max) {
+                // Do stuff here in case we'll decide one day to treat span distances
+                // in a special way (see GDoc Special Distances Serialization).
+            }
+
+            /**
+             * Registers an entry in the {@link #operandWrap} table in order
+             * to allow an operator's arguments (or only one of them) to be
+             * wrapped in a class group.
+             * 
+             * @param node
+             *            The operator node (parent node of the ARG1/ARG2
+             *            node)
+             * @param arg
+             *            The argument number (1 or 2)
+             * @param cls
+             *            The class id.
+             */
+            private void wrapOperandInClass(Tree node, int arg, int cls) {
+                LinkedHashMap<String, Object> clsGroup = 
+                        KoralObjectGenerator.makeSpanClass(cls);
+                wrapOperand(node, arg, clsGroup);
+            }
+
+            /**
+             * Registers an entry in the {@link #operandWrap} table in order
+             * to allow an operator's arguments (or only one of them) to be
+             * wrapped in an arbitrary object, e.g. a reference group.
+             * 
+             * @param node
+             *            The operator node (parent node of the ARG1/ARG2
+             *            node)
+             * @param arg
+             *            The argument number (1 or 2)
+             * @param container
+             *            The object in whose operand list the argument shall
+             *            be wrapped.
+             */
+            private void wrapOperand(Tree node, int arg,
+                    LinkedHashMap<String, Object> container) {
+                operandWrap.put(node, arg, container);
+            }
+
+            private Object translateMorph(String layer) {
+                // might be extended...
+                if (layer.equals("ANA"))
+                    return ResourceMapper.descriptor2policy("ANA");
+                else
+                    return layer;
+
+            }
+
+            @SuppressWarnings("unchecked")
+            /**
+             * Processes individual position conditions as provided in the OPTS node under the OPBEG node.
+             * #BEG allows to specify position constrains that apply to the beginning or the end of the subquery X.
+             * E.g., in #BEG(X, tpos/tpos), the 'tpos' constraints before the slash indicate conditions that apply 
+             * to the beginning of X, those after the slash are conditions that apply to the end of X.
+             * See the official C-II documentation for more details. <br/><br/>
+             * What's important here is what follows: <br/>
+             * Assume the query #BED(der Mann, sa/pa). This means that <b>the beginning<b/> of "der Mann" stands at
+             * the beginning of a sentence and that <b>the end</b> (because this constraint comes after the slash) stands at the 
+             * beginning of a paragraph. The "end" means the last item, here "Mann", so this token comes at the beginning
+             * of a paragraph. To capture this, we choose spanRefs: The last item of X matches the first item of the span (here: P). 
+             * @param cond
+             * @param distributedOperands
+             * @param mode
+             * @return
+             */
+            private LinkedHashMap<String, Object> processPositionCondition(Tree cond,
+                    ArrayList<Object> distributedOperands, String mode) {
+                boolean negated = false;
+                String elem; // the 'span' (s/p/t)
+                String position = "frames:matches"; // default
+                // spanRef to be used for the element ('span')
+                Integer[] elemSpanRef = null;
+                // spanRef to be used for the subquery X
+                Integer[] hitSpanRef = null; 
+
+                String nodeString = cond.toStringTree();
+                if (nodeString.startsWith("-")) {
+                    negated = true;
+                    nodeString = nodeString.substring(1);
+                }
+                else if (nodeString.startsWith("+")) {
+                    nodeString = nodeString.substring(1);
+                }
+                elem = nodeString.substring(0, 1);
+                nodeString = nodeString.substring(1);
+                // in cases where the end of X shall match the beginning of
+                // the span, or vice versa,
+                // we need to define spanRefs
+                if (mode.equals("beg")) {
+                    if (nodeString.equals("a")) {
+                        position = "frames:startsWith";
+                    }
+                    else if (nodeString.equals("e")) {
+                        hitSpanRef = new Integer[] { 0, 1 };
+                        elemSpanRef = new Integer[] { -1, 1 };
+                    }
+                }
+                else if (mode.equals("end")) {
+                    if (nodeString.equals("e")) {
+                        position = "frames:endsWith";
+                    }
+                    else if (nodeString.equals("a")) {
+                        hitSpanRef = new Integer[] { 0, 1 };
+                        elemSpanRef = new Integer[] { -1, 1 };
+                    }
+                }
+                // Create the position group and add the span and the subquery
+                // as operands, possibly wrapped in spanRefs
+                LinkedHashMap<String, Object> positionGroup = KoralObjectGenerator
+                        .makePosition(new String[] { position });
+                if (negated)
+                    positionGroup.put("exclude", true);
+                ArrayList<Object> posOperands = new ArrayList<Object>();
+                LinkedHashMap<String, Object> classGroup = 
+                        KoralObjectGenerator.makeSpanClass(classCounter++);
+                classGroup.put("operands", distributedOperands);
+                positionGroup.put("operands", posOperands);
+                LinkedHashMap<String, Object> span = new LinkedHashMap<String, Object>();
+                span.put("@type", "korap:span");
+                span.put("key", elem);
+                objectStack.push(classGroup);
+                if (hitSpanRef != null) {
+                    LinkedHashMap<String, Object> spanRefAroundHit = 
+                            KoralObjectGenerator.makeSpanReference(hitSpanRef, "focus");
+                    ((ArrayList<Object>) spanRefAroundHit.get("operands"))
                     .add(classGroup);
-         // re-assign after wrapping classGroup in spanRef
-            classGroup = spanRefAroundHit; 
-        }
-        if (elemSpanRef != null) {
-            LinkedHashMap<String, Object> spanRefAroundSpan = 
-                    KoralObjectGenerator.makeSpanReference(elemSpanRef, "focus");
-            ((ArrayList<Object>) spanRefAroundSpan.get("operands")).add(span);
-         // re-assign after wrapping span in spanRef
-            span = spanRefAroundSpan; 
-        }
-        posOperands.add(span);
-        posOperands.add(classGroup);
-        return positionGroup;
-    }
-
-    private LinkedHashMap<String, Object> parseOPINOptions(Tree node) {
-        Tree posnode = getFirstChildWithCat(node, "POS");
-        Tree rangenode = getFirstChildWithCat(node, "RANGE");
-        Tree exclnode = getFirstChildWithCat(node, "EXCL");
-        Tree groupnode = getFirstChildWithCat(node, "GROUP");
-        boolean negatePosition = false;
-        LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
-        ArrayList<String> positions = new ArrayList<String>();
-        ArrayList<String> classRefCheck = new ArrayList<String>();
-        posOptions.put("matchall", false);
-        String frame = "";
-        String posOption = null;
-        if (posnode != null) {
-            posOption = posnode.getChild(0).toStringTree();
-            switch (posOption) {
-                case "L":
-                    positions.add("frames:startswith");
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:includes");
-                    frame = "startswith";
-                    break;
-                case "R":
-                    positions.add("frames:endswith");
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:includes");
-                    frame = "endswith";
-                    break;
-                case "F":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:includes");
-                    frame = "matches";
-                    break;
-                case "FE":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:equals");
-                    frame = "matches";
-                    break;
-                case "FI":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:unequals");
-                    classRefCheck.add("classRefCheck:includes");
-                    frame = "matches-noident";
-                    break;
-                case "N":
-                    positions.add("frames:contains");
-                    classRefCheck.add("classRefCheck:includes");
-                    frame = "contains";
-                    break;
+                    // re-assign after wrapping classGroup in spanRef
+                    classGroup = spanRefAroundHit; 
+                }
+                if (elemSpanRef != null) {
+                    LinkedHashMap<String, Object> spanRefAroundSpan = 
+                            KoralObjectGenerator.makeSpanReference(elemSpanRef, "focus");
+                    ((ArrayList<Object>) spanRefAroundSpan.get("operands")).add(span);
+                    // re-assign after wrapping span in spanRef
+                    span = spanRefAroundSpan; 
+                }
+                posOperands.add(span);
+                posOperands.add(classGroup);
+                return positionGroup;
             }
-        }
-        else {
-            classRefCheck.add("classRefCheck:includes");
-            frame = "contains";
-        }
-        posOptions.put("frames", positions);
-        posOptions.put("classRefCheck", classRefCheck);
-        posOptions.put("frame", "frame:" + frame);
-        addMessage(
-                StatusCodes.DEPRECATED_QUERY_ELEMENT,
-                "Deprecated 2014-09-22: 'frame' only to be supported until 3 months from deprecation date. "
-                        + "Position frames are now expressed through 'frames' and 'sharedClasses'");
 
-        if (exclnode != null) {
-            if (exclnode.getChild(0).toStringTree().equals("YES")) {
-                negatePosition = !negatePosition;
+            private LinkedHashMap<String, Object> parseOPINOptions(Tree node) {
+                Tree posnode = getFirstChildWithCat(node, "POS");
+                Tree rangenode = getFirstChildWithCat(node, "RANGE");
+                Tree exclnode = getFirstChildWithCat(node, "EXCL");
+                Tree groupnode = getFirstChildWithCat(node, "GROUP");
+                boolean negatePosition = false;
+                LinkedHashMap<String, Object> posOptions = new LinkedHashMap<String, Object>();
+                ArrayList<String> positions = new ArrayList<String>();
+                ArrayList<String> classRefCheck = new ArrayList<String>();
+                posOptions.put("matchall", false);
+                String posOption = null;
+                if (posnode != null) {
+                    posOption = posnode.getChild(0).toStringTree();
+                    switch (posOption) {
+                        case "L":
+                            positions.add("frames:startsWith");
+                            positions.add("frames:matches");
+                            //                    classRefCheck.add("classRefCheck:includes");
+                            break;
+                        case "R":
+                            positions.add("frames:endsWith");
+                            positions.add("frames:matches");
+                            //                    classRefCheck.add("classRefCheck:includes");
+                            break;
+                        case "F":
+                            positions.add("frames:matches");
+                            //                    classRefCheck.add("classRefCheck:includes");
+                            break;
+                        case "FE":
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:equals");
+                            break;
+                        case "FI":
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:unequals");
+                            //                    classRefCheck.add("classRefCheck:includes");
+                            break;
+                        case "N":
+                            positions.add("frames:contains");
+                            //                    classRefCheck.add("classRefCheck:includes");
+                            break;
+                    }
+                } else {
+                    classRefCheck.add("classRefCheck:includes");
+                }
+                posOptions.put("frames", positions);
+                posOptions.put("classRefCheck", classRefCheck);
+                if (exclnode != null) {
+                    if (exclnode.getChild(0).toStringTree().equals("YES")) {
+                        negatePosition = !negatePosition;
+                    }
+                }
+
+                if (rangenode != null) {
+                    String range = rangenode.getChild(0).toStringTree().toLowerCase();
+                    if (range.equals("all")) {
+                        posOptions.put("matchall", true);
+                        // LinkedHashMap<String,Object> ref =
+                        // makeResetReference(); // reset all defined classes
+                        // wrapOperand(node,2,ref);
+                    }
+                }
+
+                if (negatePosition) {
+                    posOptions.put("exclude", true);
+                }
+
+                boolean grouping = false;
+                if (groupnode != null) {
+                    if (groupnode.getChild(0).toStringTree().equalsIgnoreCase("max")) {
+                        grouping = true;
+                    }
+                } 
+                posOptions.put("grouping", grouping);
+
+                return posOptions;
             }
-        }
 
-        if (rangenode != null) {
-            String range = rangenode.getChild(0).toStringTree().toLowerCase();
-            if (range.equals("all")) {
-                posOptions.put("matchall", true);
-                // LinkedHashMap<String,Object> ref =
-                // makeResetReference(); // reset all defined classes
-                // wrapOperand(node,2,ref);
-            }
-        }
-
-        if (negatePosition) {
-            posOptions.put("exclude", true);
-        }
-
-        boolean grouping = false;
-        if (groupnode != null) {
-            if (groupnode.getChild(0).toStringTree().equalsIgnoreCase("max")) {
-                grouping = true;
-            }
-        } 
-        posOptions.put("grouping", grouping);
-        
-        return posOptions;
-    }
-
-    private LinkedHashMap<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>();
-        ArrayList<String> positions = new ArrayList<String>();
-        ArrayList<String> classRefCheck = new ArrayList<String>();
-        posOptions.put("matchall", false);
-        String frame = "";
-        String posOption = null;
-        if (posnode != null) {
-            posOption = posnode.getChild(0).toStringTree();
-            switch (posOption) {
-                case "L":
-                    positions.add("frames:startswith");
-                    positions.add("frames:overlapsLeft");
-                    positions.add("frames:matches");
+            private LinkedHashMap<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>();
+                ArrayList<String> positions = new ArrayList<String>();
+                ArrayList<String> classRefCheck = new ArrayList<String>();
+                posOptions.put("matchall", false);
+                String posOption = null;
+                if (posnode != null) {
+                    posOption = posnode.getChild(0).toStringTree();
+                    switch (posOption) {
+                        case "L":
+                            positions.add("frames:startsWith");
+                            positions.add("frames:overlapsLeft");
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:intersects");
+                            break;
+                        case "R":
+                            positions.add("frames:endsWith");
+                            positions.add("frames:overlapsRight");
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:intersects");
+                            break;
+                        case "F":
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:intersects");
+                            break;
+                        case "FE":
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:equals");
+                            break;
+                        case "FI":
+                            positions.add("frames:matches");
+                            classRefCheck.add("classRefCheck:unequals");
+                            break;
+                        case "X":
+                            positions.add("frames:contains");
+                            classRefCheck.add("classRefCheck:intersects");
+                            break;
+                    }
+                }
+                else {
                     classRefCheck.add("classRefCheck:intersects");
-                    frame = "overlapsLeft";
-                    break;
-                case "R":
-                    positions.add("frames:endswith");
-                    positions.add("frames:overlapsRight");
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:intersects");
-                    frame = "overlapsRight";
-                    break;
-                case "F":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:intersects");
-                    frame = "matches";
-                    break;
-                case "FE":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:equals");
-                    frame = "matches";
-                    break;
-                case "FI":
-                    positions.add("frames:matches");
-                    classRefCheck.add("classRefCheck:unequals");
-                    frame = "matches-noident";
-                    break;
-                case "X":
-                    positions.add("frames:contains");
-                    classRefCheck.add("classRefCheck:intersects");
-                    frame = "overlaps";
-                    break;
+                }
+
+                posOptions.put("frames", positions);
+                posOptions.put("classRefCheck", classRefCheck);
+                if (exclnode != null) {
+                    if (exclnode.getChild(0).toStringTree().equals("YES")) {
+                        negatePosition = !negatePosition;
+                    }
+                }
+
+                if (rangenode != null) {
+                    String range = rangenode.getChild(0).toStringTree().toLowerCase();
+                    if (range.equals("all")) {
+                        posOptions.put("matchall", true);
+                        // LinkedHashMap<String,Object> ref =
+                        // makeResetReference(); // reset all defined classes
+                        // wrapOperand(node,2,ref);
+                    }
+                }
+
+                if (negatePosition) {
+                    posOptions.put("exclude", "true");
+                }
+
+                boolean grouping = false;
+                if (groupnode != null) {
+                    if (groupnode.getChild(0).toStringTree().equalsIgnoreCase("max")) {
+                        grouping = true;
+                    }
+                } 
+                posOptions.put("grouping", grouping);
+
+                return posOptions;
             }
-        }
-        else {
-            classRefCheck.add("classRefCheck:intersects");
-            frame = "overlaps";
-        }
 
-        posOptions.put("frames", positions);
-        posOptions.put("classRefCheck", classRefCheck);
-        posOptions.put("frame", "frame:" + frame);
-        addMessage(
-                StatusCodes.DEPRECATED_QUERY_ELEMENT,
-                "Deprecated 2014-09-22: 'frame' only to be supported until 3 months from deprecation date. "
-                        + "Position frames are now expressed through 'frames' and 'sharedClasses'");
-
-        if (exclnode != null) {
-            if (exclnode.getChild(0).toStringTree().equals("YES")) {
-                negatePosition = !negatePosition;
+            @SuppressWarnings({ "unchecked" })
+            private LinkedHashMap<String, Object> wrap(LinkedHashMap<String, Object>[] wrapCascade) {
+                int i;
+                for (i = 0; i < wrapCascade.length - 1; i++) {
+                    ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i + 1]
+                            .get("operands");
+                    containerOperands.add(0, wrapCascade[i]);
+                }
+                return wrapCascade[i];
             }
-        }
 
-        if (rangenode != null) {
-            String range = rangenode.getChild(0).toStringTree().toLowerCase();
-            if (range.equals("all")) {
-                posOptions.put("matchall", true);
-                // LinkedHashMap<String,Object> ref =
-                // makeResetReference(); // reset all defined classes
-                // wrapOperand(node,2,ref);
+            @SuppressWarnings("unchecked")
+            private void putIntoSuperObject(LinkedHashMap<String, Object> object,
+                    int objStackPosition) {
+                if (objectStack.size() > objStackPosition) {
+                    ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
+                            .get(objStackPosition).get("operands");
+                    if (!invertedOperandsLists.contains(topObjectOperands)) {
+                        topObjectOperands.add(object);
+                    }
+                    else {
+                        topObjectOperands.add(0, object);
+                    }
+                }
+                else {
+                    requestMap.put("query", object);
+                }
             }
-        }
 
-        if (negatePosition) {
-            posOptions.put("exclude", "true");
-        }
-        
-        boolean grouping = false;
-        if (groupnode != null) {
-            if (groupnode.getChild(0).toStringTree().equalsIgnoreCase("max")) {
-                grouping = true;
+            private void putIntoSuperObject(LinkedHashMap<String, Object> object) {
+                putIntoSuperObject(object, 0);
             }
-        } 
-        posOptions.put("grouping", grouping);
-        
-        return posOptions;
-    }
 
-    @SuppressWarnings({ "unchecked" })
-    private LinkedHashMap<String, Object> wrap(LinkedHashMap<String, Object>[] wrapCascade) {
-        int i;
-        for (i = 0; i < wrapCascade.length - 1; i++) {
-            ArrayList<Object> containerOperands = (ArrayList<Object>) wrapCascade[i + 1]
-                    .get("operands");
-            containerOperands.add(0, wrapCascade[i]);
-        }
-        return wrapCascade[i];
-    }
+            /**
+             * Normalises position operators to equivalents using #BED
+             */
+            private String rewritePositionQuery(String q) {
+                Pattern p = Pattern.compile("(\\w+):((\\+|-)?(sa|se|pa|pe|ta|te),?)+");
+                Matcher m = p.matcher(q);
 
-    @SuppressWarnings("unchecked")
-    private void putIntoSuperObject(LinkedHashMap<String, Object> object,
-            int objStackPosition) {
-        if (objectStack.size() > objStackPosition) {
-            ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack
-                    .get(objStackPosition).get("operands");
-            if (!invertedOperandsLists.contains(topObjectOperands)) {
-                topObjectOperands.add(object);
+                String rewrittenQuery = q;
+                while (m.find()) {
+                    String match = m.group();
+                    String conditionsString = match.split(":")[1];
+                    Pattern conditionPattern = Pattern
+                            .compile("(\\+|-)?(sa|se|pa|pe|ta|te)");
+                    Matcher conditionMatcher = conditionPattern
+                            .matcher(conditionsString);
+                    String replacement = "#BED(" + m.group(1) + " , ";
+                    while (conditionMatcher.find()) {
+                        replacement = replacement + conditionMatcher.group() + ",";
+                    }
+                    // remove trailing comma and close parenthesis
+                    replacement = 
+                            replacement.substring(0, replacement.length() - 1)+ ")"; 
+                    rewrittenQuery = rewrittenQuery.replace(match, replacement);
+                }
+                return rewrittenQuery;
             }
-            else {
-                topObjectOperands.add(0, object);
+
+            private Tree parseCosmasQuery(String query) {
+                query = rewritePositionQuery(query);
+                Tree tree = null;
+                Antlr3DescriptiveErrorListener errorListener = 
+                        new Antlr3DescriptiveErrorListener(query);
+                try {
+                    ANTLRStringStream ss = new ANTLRStringStream(query);
+                    c2psLexer lex = new c2psLexer(ss);
+                    org.antlr.runtime.CommonTokenStream tokens = 
+                            new org.antlr.runtime.CommonTokenStream(lex); // v3
+                    parser = new c2psParser(tokens);
+                    // Use custom error reporters
+                    lex.setErrorReporter(errorListener);
+                    ((c2psParser) parser).setErrorReporter(errorListener); 
+                    c2psParser.c2ps_query_return c2Return = ((c2psParser) parser)
+                            .c2ps_query(); // statt t().
+                    // AST Tree anzeigen:
+                    tree = (Tree) c2Return.getTree();
+
+                }
+                catch (RecognitionException e) {
+                    log.error("Could not parse query. Please make sure it is well-formed.");
+                    addError(StatusCodes.MALFORMED_QUERY,
+                            "Could not parse query. Please make sure it is well-formed.");
+                }
+                String treestring = tree.toStringTree();
+
+                boolean erroneous = false;
+                if (parser.failed() || parser.getNumberOfSyntaxErrors() > 0) {
+                    erroneous = true;
+                    tree = null;
+                }
+
+                if (erroneous || treestring.contains("<mismatched token")
+                        || treestring.contains("<error")
+                        || treestring.contains("<unexpected")) {
+                    log.error(errorListener.generateFullErrorMsg().toString());
+                    addError(errorListener.generateFullErrorMsg());
+                }
+                return tree;
             }
-        }
-        else {
-            requestMap.put("query", object);
-        }
-    }
-
-    private void putIntoSuperObject(LinkedHashMap<String, Object> object) {
-        putIntoSuperObject(object, 0);
-    }
-
-    /**
-     * Normalises position operators to equivalents using #BED
-     */
-    private String rewritePositionQuery(String q) {
-        Pattern p = Pattern.compile("(\\w+):((\\+|-)?(sa|se|pa|pe|ta|te),?)+");
-        Matcher m = p.matcher(q);
-
-        String rewrittenQuery = q;
-        while (m.find()) {
-            String match = m.group();
-            String conditionsString = match.split(":")[1];
-            Pattern conditionPattern = Pattern
-                    .compile("(\\+|-)?(sa|se|pa|pe|ta|te)");
-            Matcher conditionMatcher = conditionPattern
-                    .matcher(conditionsString);
-            String replacement = "#BED(" + m.group(1) + " , ";
-            while (conditionMatcher.find()) {
-                replacement = replacement + conditionMatcher.group() + ",";
-            }
-            // remove trailing comma and close parenthesis
-            replacement = 
-                    replacement.substring(0, replacement.length() - 1)+ ")"; 
-            rewrittenQuery = rewrittenQuery.replace(match, replacement);
-        }
-        return rewrittenQuery;
-    }
-
-    private Tree parseCosmasQuery(String query) {
-        query = rewritePositionQuery(query);
-        Tree tree = null;
-        Antlr3DescriptiveErrorListener errorListener = 
-                new Antlr3DescriptiveErrorListener(query);
-        try {
-            ANTLRStringStream ss = new ANTLRStringStream(query);
-            c2psLexer lex = new c2psLexer(ss);
-            org.antlr.runtime.CommonTokenStream tokens = 
-                    new org.antlr.runtime.CommonTokenStream(lex); // v3
-            parser = new c2psParser(tokens);
-            // Use custom error reporters
-            lex.setErrorReporter(errorListener);
-            ((c2psParser) parser).setErrorReporter(errorListener); 
-            c2psParser.c2ps_query_return c2Return = ((c2psParser) parser)
-                    .c2ps_query(); // statt t().
-            // AST Tree anzeigen:
-            tree = (Tree) c2Return.getTree();
-
-        }
-        catch (RecognitionException e) {
-            log.error("Could not parse query. Please make sure it is well-formed.");
-            addError(StatusCodes.MALFORMED_QUERY,
-                    "Could not parse query. Please make sure it is well-formed.");
-        }
-        String treestring = tree.toStringTree();
-
-        boolean erroneous = false;
-        if (parser.failed() || parser.getNumberOfSyntaxErrors() > 0) {
-            erroneous = true;
-            tree = null;
-        }
-
-        if (erroneous || treestring.contains("<mismatched token")
-                || treestring.contains("<error")
-                || treestring.contains("<unexpected")) {
-            log.error(errorListener.generateFullErrorMsg().toString());
-            addError(errorListener.generateFullErrorMsg());
-        }
-        return tree;
-    }
 }
\ No newline at end of file
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 1aa3e8d..e0ac4eb 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
@@ -577,7 +577,7 @@
         String domain = getNodeCat(domainNode);
         LinkedHashMap<String, Object> span = KoralObjectGenerator.makeSpan(domain);
         LinkedHashMap<String, Object> queryObj = (LinkedHashMap<String, Object>) requestMap.get("query");
-        LinkedHashMap<String, Object> contains = KoralObjectGenerator.makePosition(new String[]{"frames:contains"}, null);
+        LinkedHashMap<String, Object> contains = KoralObjectGenerator.makePosition(new String[]{"frames:isAround"});
         ArrayList<Object> operands = (ArrayList<Object>) contains.get("operands");
         operands.add(span);
         operands.add(queryObj);
@@ -647,27 +647,25 @@
     private LinkedHashMap<String, Object> parseFrame(ParseTree node) {
         String operator = node.toStringTree(parser).toLowerCase();
         String[] frames = new String[] { "" };
-        String[] classRefCheck = new String[] { "classRefCheck:includes" };
         switch (operator) {
             case "contains":
-                frames = new String[] { "frames:contains" };
+                frames = new String[] { "frames:isAround" };
                 break;
             case "matches":
                 frames = new String[] { "frames:matches" };
                 break;
             case "startswith":
-                frames = new String[] { "frames:startswith" };
+                frames = new String[] { "frames:startsWith", "frames:matches" };
                 break;
             case "endswith":
-                frames = new String[] { "frames:endswith" };
+                frames = new String[] { "frames:endsWith", "frames:matches" };
                 break;
             case "overlaps":
                 frames = new String[] { "frames:overlapsLeft",
                         "frames:overlapsRight" };
-                classRefCheck = new String[] { "classRefCheck:intersects" };
                 break;
         }
-        return KoralObjectGenerator.makePosition(frames, classRefCheck);
+        return KoralObjectGenerator.makePosition(frames);
     }
 
     private LinkedHashMap<String, Object> parseTermOrTermGroup(ParseTree node,
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 befa081..610c83e 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
@@ -89,7 +89,7 @@
     }
 
     public static LinkedHashMap<String, Object> makePosition(
-            String[] allowedFrames, String[] classRefCheck) {
+            String[] allowedFrames) {
         LinkedHashMap<String, Object> group = new LinkedHashMap<String, Object>();
         group.put("@type", "korap:group");
         group.put("operation", "operation:position");
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
index 627bfa7..8a0ae98 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/AnnisQueryProcessorTest.java
@@ -257,7 +257,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("operation:position",	res.at("/query/operation").asText());
         assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:startswith",	res.at("/query/frames/0").asText());
+        assertEquals("frames:startsWith",	res.at("/query/frames/0").asText());
         assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
         assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
         assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
@@ -274,7 +274,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("operation:position",	res.at("/query/operation").asText());
         assertEquals("operation:relation",	res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:endswith",		res.at("/query/frames/0").asText());
+        assertEquals("frames:endsWith",		res.at("/query/frames/0").asText());
         assertEquals("korap:span",			res.at("/query/operands/0/operands/0/@type").asText());
         assertEquals("S",					res.at("/query/operands/0/operands/0/key").asText());
         assertEquals("korap:group",			res.at("/query/operands/0/operands/1/@type").asText());
@@ -671,7 +671,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group",         res.at("/query/@type").asText());
         assertEquals("operation:position",  res.at("/query/operation").asText());
-        assertEquals("frames:startswith",   res.at("/query/frames/0").asText());
+        assertEquals("frames:startsWith",   res.at("/query/frames/0").asText());
         assertEquals("korap:reference",     res.at("/query/operands/0/@type").asText());
         assertEquals("operation:focus",     res.at("/query/operands/0/operation").asText());
         assertEquals(1,                     res.at("/query/operands/0/classRef/0").asInt());
@@ -703,28 +703,30 @@
         query = "node & node & #1 _i_ #2";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:contains",     res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround",     res.at("/query/frames/0").asText());
         assertEquals("korap:span",          res.at("/query/operands/0/@type").asText());
         assertEquals("korap:span",          res.at("/query/operands/1/@type").asText());
 
         query = "node & node & #1 _l_ #2";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:startswith",   res.at("/query/frames/0").asText());
+        assertEquals("frames:startsWith",   res.at("/query/frames/0").asText());
+        assertEquals("frames:matches",      res.at("/query/frames/1").asText());
         assertEquals("korap:span",          res.at("/query/operands/0/@type").asText());
         assertEquals("korap:span",          res.at("/query/operands/1/@type").asText());
 
         query = "node & node & #1 _r_ #2";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:endswith",     res.at("/query/frames/0").asText());
+        assertEquals("frames:endsWith",     res.at("/query/frames/0").asText());
+        assertEquals("frames:matches",      res.at("/query/frames/1").asText());
         assertEquals("korap:span",          res.at("/query/operands/0/@type").asText());
         assertEquals("korap:span",          res.at("/query/operands/1/@type").asText());
 
         query = "node & \"Mann\" & #1 _r_ #2";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:endswith",     res.at("/query/frames/0").asText());
+        assertEquals("frames:endsWith",     res.at("/query/frames/0").asText());
         assertEquals("korap:span",          res.at("/query/operands/0/@type").asText());
         assertEquals("korap:token",         res.at("/query/operands/1/@type").asText());
         assertEquals("Mann",                res.at("/query/operands/1/wrap/key").asText());
@@ -732,7 +734,7 @@
         query = "node & \"Mann\" & #2 _r_ #1";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:endswith",     res.at("/query/frames/0").asText());
+        assertEquals("frames:endsWith",     res.at("/query/frames/0").asText());
         assertEquals("korap:span",          res.at("/query/operands/1/@type").asText());
         assertEquals("korap:token",         res.at("/query/operands/0/@type").asText());
         assertEquals("Mann",                res.at("/query/operands/0/wrap/key").asText());
@@ -740,10 +742,10 @@
         query = "node & cat=\"VP\" & cat=\"NP\" & #1 _r_ #2 & #2 _l_ #3";
         qs.setQuery(query, "annis");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("frames:startswith",   res.at("/query/frames/0").asText());
+        assertEquals("frames:startsWith",   res.at("/query/frames/0").asText());
         assertEquals("operation:focus",     res.at("/query/operands/0/operation").asText());
         assertEquals(1,                     res.at("/query/operands/0/classRef/0").asInt());
-        assertEquals("frames:endswith",     res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:endsWith",     res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals("korap:span",          res.at("/query/operands/0/operands/0/operands/0/@type").asText());
         assertEquals("korap:group",         res.at("/query/operands/0/operands/0/operands/1/@type").asText());
         assertEquals("operation:class",     res.at("/query/operands/0/operands/0/operands/1/operation").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
index ac91781..4c04ed9 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/Cosmas2QueryProcessorTest.java
@@ -556,23 +556,36 @@
         query = "wegen #IN(L) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("classRefCheck:includes",		res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("frames:startswith",           res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals("frames:matches",              res.at("/query/operands/0/operands/0/frames/1").asText());
-        assertEquals(true,							res.at("/query/operands/0/operands/0/frames/2").isMissingNode());
+        assertEquals("korap:reference",             res.at("/query/@type").asText());
+        assertEquals("operation:focus",             res.at("/query/operation").asText());
+        assertEquals(2,                             res.at("/query/classRef/0").asInt());
+        assertEquals("korap:group",                 res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:position",          res.at("/query/operands/0/operation").asText());
+        assertEquals("frames:startsWith",           res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:matches",              res.at("/query/operands/0/frames/1").asText());
+        assertEquals(true,                          res.at("/query/operands/0/frames/2").isMissingNode());
+        assertEquals("korap:group",                 res.at("/query/operands/0/@type").asText());
+        assertEquals("operation:class",             res.at("/query/operands/0/operands/0/operation").asText());
+        assertEquals(1,                             res.at("/query/operands/0/operands/0/classOut").asInt());
+        assertEquals("korap:span",                  res.at("/query/operands/0/operands/0/operands/0/@type").asText());
+        assertEquals("s",                           res.at("/query/operands/0/operands/0/operands/0/key").asText());
+        assertEquals("korap:group",                 res.at("/query/operands/0/operands/1/@type").asText());
+        assertEquals("operation:class",             res.at("/query/operands/0/operands/1/operation").asText());
+        assertEquals(2,                             res.at("/query/operands/0/operands/1/classOut").asInt());
+        assertEquals("korap:token",                 res.at("/query/operands/0/operands/1/operands/0/@type").asText());
+        assertEquals("wegen",                       res.at("/query/operands/0/operands/1/operands/0/wrap/key").asText());
 
         query = "wegen #IN(F) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("classRefCheck:includes",		res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("frames:matches",				res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals(true,							res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
+        assertEquals(true,                  		res.at("/query/operands/0/classRefCheck").isMissingNode());
+        assertEquals("frames:matches",				res.at("/query/operands/0/frames/0").asText());
+        assertEquals(true,							res.at("/query/operands/0/frames/1").isMissingNode());
 
         query = "wegen #IN(FI) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("classRefCheck:unequals",		res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("classRefCheck:includes",		res.at("/query/operands/0/classRefCheck/1").asText());
         assertEquals("frames:matches",				res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals(true,							res.at("/query/operands/0/operands/0/frames/1").isMissingNode());
 
@@ -586,18 +599,16 @@
         query = "wegen #IN(%, L) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
-        assertEquals("classRefCheck:includes",		res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals("frames:matches",				res.at("/query/operands/0/operands/0/frames/1").asText());
-//        assertEquals(true,                          res.at("/query/operands/0/operands/0/exclude").isMissingNode());
-        
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:matches",				res.at("/query/operands/0/frames/1").asText());
+        //        assertEquals(true,                          res.at("/query/operands/0/operands/0/exclude").isMissingNode());
+
         query = "wegen #IN(FE,%,MIN) <s>";
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("classRefCheck:equals",		res.at("/query/operands/0/classRefCheck/0").asText());
         assertEquals("frames:matches",				res.at("/query/operands/0/operands/0/frames/0").asText());
-        assertEquals("frames:matches",              res.at("/query/operands/0/operands/0/frames/0").asText());
-//        assertEquals(true,							res.at("/query/operands/0/operands/0/exclude").isMissingNode());
+        //        assertEquals(true,							res.at("/query/operands/0/operands/0/exclude").isMissingNode());
 
         query = "wegen #IN(FE,ALL,%,MIN) <s>";
         qs.setQuery(query, "cosmas2");
@@ -654,8 +665,9 @@
         qs.setQuery(query, "cosmas2");
         res = mapper.readTree(qs.toJSON());
         assertEquals("classRefCheck:intersects",	res.at("/query/operands/0/classRefCheck/0").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals("frames:overlapsLeft",			res.at("/query/operands/0/operands/0/frames/1").asText());
+        assertEquals("frames:matches",              res.at("/query/operands/0/operands/0/frames/2").asText());
 
         query = "wegen #OV(F) <s>";
         qs.setQuery(query, "cosmas2");
@@ -938,7 +950,7 @@
         assertEquals(2,  					res.at("/query/operands/0/operands/0/operands/0/classOut").asInt());
         assertEquals("gehen",				res.at("/query/operands/0/operands/0/operands/0/operands/0/wrap/key").asText());
         assertEquals(3,                     res.at("/query/operands/0/operands/0/operands/1/classOut").asInt());
-//        assertEquals("classRefOp:merge",    res.at("/query/operands/0/operands/0/operands/1/classRefOp").asText());
+        //        assertEquals("classRefOp:merge",    res.at("/query/operands/0/operands/0/operands/1/classRefOp").asText());
         assertEquals("operation:sequence",	res.at("/query/operands/0/operands/0/operands/1/operands/0/operation").asText());
         assertEquals(4,  					res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/classOut").asInt());
         assertEquals("voran",				res.at("/query/operands/0/operands/0/operands/1/operands/0/operands/0/operands/0/wrap/key").asText());
@@ -957,7 +969,7 @@
         assertEquals(1,  							res.at("/query/classRef/0").asInt());
         assertEquals("korap:group",					res.at("/query/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/frames/0").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/@type").asText());
         assertEquals("operation:class",				res.at("/query/operands/0/operands/1/operation").asText());
         assertEquals(1,  							res.at("/query/operands/0/operands/1/classOut").asInt());
@@ -1004,7 +1016,7 @@
 
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/0/operands/0/@type").asText());
         assertEquals("s",							res.at("/query/operands/0/operands/0/operands/0/key").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/operands/1/@type").asText());
@@ -1016,7 +1028,7 @@
 
         assertEquals("korap:group",					res.at("/query/operands/0/operands/1/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/1/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/1/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/1/frames/0").asText());
         assertEquals(true,							res.at("/query/operands/0/operands/1/exclude").asBoolean());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/1/operands/0/@type").asText());
         assertEquals("p",							res.at("/query/operands/0/operands/1/operands/0/key").asText());
@@ -1039,7 +1051,7 @@
         assertEquals(1,  							res.at("/query/classRef/0").asInt());
         assertEquals("korap:group",					res.at("/query/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/frames/0").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/@type").asText());
         assertEquals("operation:class",				res.at("/query/operands/0/operands/1/operation").asText());
         assertEquals(1,  							res.at("/query/operands/0/operands/1/classOut").asInt());
@@ -1059,7 +1071,7 @@
         assertEquals("frames:matches",				res.at("/query/operands/0/frames/0").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/0/operands/0/@type").asText());
         assertEquals("s",							res.at("/query/operands/0/operands/0/operands/0/key").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/operands/1/@type").asText());
@@ -1068,7 +1080,7 @@
         assertEquals("der",							res.at("/query/operands/0/operands/0/operands/1/operands/0/wrap/key").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/1/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/1/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/1/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/1/frames/0").asText());
         assertEquals(true,							res.at("/query/operands/0/operands/1/exclude").asBoolean());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/1/operands/0/@type").asText());
         assertEquals("p",							res.at("/query/operands/0/operands/1/operands/0/key").asText());
@@ -1088,7 +1100,7 @@
         assertEquals("frames:matches",				res.at("/query/operands/0/frames/0").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/0/frames/0").asText());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/0/operands/0/@type").asText());
         assertEquals("s",							res.at("/query/operands/0/operands/0/operands/0/key").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/0/operands/1/@type").asText());
@@ -1103,7 +1115,7 @@
         assertEquals("frames:matches",				res.at("/query/operands/0/operands/1/operands/0/frames/0").asText());
         assertEquals("korap:group",					res.at("/query/operands/0/operands/1/operands/0/operands/0/@type").asText());
         assertEquals("operation:position",			res.at("/query/operands/0/operands/1/operands/0/operands/0/operation").asText());
-        assertEquals("frames:startswith",			res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith",			res.at("/query/operands/0/operands/1/operands/0/operands/0/frames/0").asText());
         assertEquals(true,							res.at("/query/operands/0/operands/1/operands/0/operands/0/exclude").asBoolean());
         assertEquals("korap:span",					res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/@type").asText());
         assertEquals("p",							res.at("/query/operands/0/operands/1/operands/0/operands/0/operands/0/key").asText());
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
index 7ddc660..7368ef4 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusQueryProcessorTest.java
@@ -524,7 +524,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group",         res.at("/query/@type").asText());
         assertEquals("operation:position",  res.at("/query/operation").asText());
-        assertEquals("frames:contains",     res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround",     res.at("/query/frames/0").asText());
         assertEquals(true,                  res.at("/query/frames/1").isMissingNode());
         assertEquals("korap:span",          res.at("/query/operands/0/@type").asText());
         assertEquals("s",                   res.at("/query/operands/0/key").asText());
@@ -668,7 +668,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group", 		res.at("/query/@type").asText());
         assertEquals("operation:position", 	res.at("/query/operation").asText());
-        assertEquals("frames:contains",		res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround",		res.at("/query/frames/0").asText());
         assertEquals(true, 					res.at("/query/frames/1").isMissingNode());
         assertEquals("korap:span", 			res.at("/query/operands/0/@type").asText());
         assertEquals("s", 					res.at("/query/operands/0/key").asText());
@@ -685,7 +685,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group", 			res.at("/query/@type").asText());
         assertEquals("operation:position", 		res.at("/query/operation").asText());
-        assertEquals("frames:contains", 		res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround", 		res.at("/query/frames/0").asText());
         assertEquals("s", 						res.at("/query/operands/0/key").asText());
         assertEquals("korap:group", 			res.at("/query/operands/1/@type").asText());
         assertEquals("operation:sequence", 		res.at("/query/operands/1/operation").asText());
@@ -697,7 +697,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("korap:group", 			res.at("/query/@type").asText());
         assertEquals("operation:position", 		res.at("/query/operation").asText());
-        assertEquals("frames:contains", 		res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround", 		res.at("/query/frames/0").asText());
         assertEquals("s", 						res.at("/query/operands/0/key").asText());
         assertEquals("korap:group", 			res.at("/query/operands/1/@type").asText());
         assertEquals("operation:sequence", 		res.at("/query/operands/1/operation").asText());
@@ -712,7 +712,7 @@
         res = mapper.readTree(qs.toJSON());
         assertEquals("s", 						res.at("/query/operands/0/key").asText());
         assertEquals("korap:group", 			res.at("/query/operands/1/@type").asText());
-        assertEquals("frames:startswith", 		res.at("/query/operands/1/frames/0").asText());
+        assertEquals("frames:startsWith", 		res.at("/query/operands/1/frames/0").asText());
         assertEquals("operation:position", 		res.at("/query/operands/1/operation").asText());
         assertEquals("np", 						res.at("/query/operands/1/operands/0/key").asText());
         assertEquals("pp", 						res.at("/query/operands/1/operands/1/key").asText());
@@ -1022,7 +1022,7 @@
         assertEquals("operation:position", 	res.at("/query/operands/0/operation").asText());
         assertEquals("operation:class", 	res.at("/query/operands/0/operands/1/operation").asText());
         assertEquals(3, 					res.at("/query/operands/0/operands/1/classOut").asInt());
-        assertEquals("frames:startswith", 	res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith", 	res.at("/query/operands/0/frames/0").asText());
         assertEquals(3,                     res.at("/meta/highlight/0").asInt());
 
         query = "focus(1000:startswith(<s>,{1000:<np>}))";
@@ -1039,7 +1039,7 @@
         assertEquals("korap:reference", 	res.at("/query/@type").asText());
         assertEquals("operation:focus", 	res.at("/query/operation").asText());
         assertEquals("operation:position", 	res.at("/query/operands/0/operation").asText());
-        assertEquals("frames:startswith", 	res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:startsWith", 	res.at("/query/operands/0/frames/0").asText());
         assertEquals("operation:class", 	res.at("/query/operands/0/operands/1/operation").asText());
         assertEquals(3, 					res.at("/query/operands/0/operands/1/classOut").asInt());
         assertEquals("operation:sequence", 	res.at("/query/operands/0/operands/1/operands/0/operation").asText());
@@ -1103,7 +1103,7 @@
         assertEquals("operation:focus", 	res.at("/query/operation").asText());
         assertEquals(1, 					res.at("/query/spanRef/0").asInt());
         assertEquals(4, 					res.at("/query/spanRef/1").asInt());
-        assertEquals("frames:contains", 	res.at("/query/operands/0/frames/0").asText());
+        assertEquals("frames:isAround", 	res.at("/query/operands/0/frames/0").asText());
         assertEquals("s", 					res.at("/query/operands/0/operands/0/key").asText());
         assertEquals("Haus", 				res.at("/query/operands/0/operands/1/wrap/key").asText());
     }
@@ -1315,7 +1315,7 @@
         qs.setQuery(query, "poliqarpplus");
         res = mapper.readTree(qs.toJSON());
         assertEquals("operation:position",  res.at("/query/operation").asText());
-        assertEquals("frames:contains",     res.at("/query/frames/0").asText());
+        assertEquals("frames:isAround",     res.at("/query/frames/0").asText());
         assertEquals("s",                   res.at("/query/operands/0/key").asText());
         assertEquals("VVFIN",               res.at("/query/operands/1/wrap/key").asText());
     }
