adopted changes submatch -> focus in cosmas
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
index 6a90a8e..0603710 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/CosmasTree.java
@@ -464,30 +464,20 @@
         // inlcusion or overlap
         if (nodeCat.equals("OPIN") || nodeCat.equals("OPOV")) {
             // Step I: create group
-            LinkedHashMap<String, Object> submatchgroup = new LinkedHashMap<String, Object>();
-            submatchgroup.put("@type", "korap:group");
-            submatchgroup.put("operation", "operation:" + "submatch");
-            ArrayList<Integer> classRef = new ArrayList<Integer>();
-            classRef.add(classRefCounter);
-            submatchgroup.put("classRef", classRef);
+            LinkedHashMap<String, Object> submatchgroup = makeReference(classRefCounter);
 
             ArrayList<Object> submatchoperands = new ArrayList<Object>();
-            LinkedHashMap<String, Object> posgroup = new LinkedHashMap<String, Object>();
+            LinkedHashMap<String, Object> posgroup = makePosition(null);
             submatchgroup.put("operands", submatchoperands);
             submatchoperands.add(posgroup);
-            posgroup.put("@type", "korap:group");
-//			String relation = nodeCat.equals("OPIN") ? "position" : "overlaps";
-            posgroup.put("operation", "operation:" + "position");
             if (nodeCat.equals("OPIN")) {
                 parseOPINOptions(node, posgroup);
             } else {
                 parseOPOVOptions(node, posgroup);
             }
-            ArrayList<Object> posoperands = new ArrayList<Object>();
-            posgroup.put("operands", posoperands);
             objectStack.push(posgroup);
             // mark this an inverted list
-            invertedOperandsLists.push(posoperands);
+            invertedOperandsLists.push((ArrayList<Object>) posgroup.get("operands"));
             stackedObjects++;
             // Step II: decide where to put
             putIntoSuperObject(submatchgroup, 1);
@@ -526,17 +516,11 @@
 
 
         if (nodeCat.equals("OPNHIT")) {
-            LinkedHashMap<String, Object> exclGroup = new LinkedHashMap<String, Object>();
-            exclGroup.put("@type", "korap:group");
-            exclGroup.put("operation", "operation:" + "submatch");
             ArrayList<Integer> classRef = new ArrayList<Integer>();
-
             classRef.add(classRefCounter);
-//			classRefCounter++;
             // yes, do this twice!
             classRef.add(classRefCounter + 1);
-//			classRefCounter++;
-            exclGroup.put("classRef", classRef);
+            LinkedHashMap<String, Object> exclGroup = makeReference(classRef);
             exclGroup.put("classRefOp", "classRefOp:" + "intersection");
             ArrayList<Object> operands = new ArrayList<Object>();
             exclGroup.put("operands", operands);
@@ -548,8 +532,8 @@
         if (nodeCat.equals("OPEND") || nodeCat.equals("OPBEG")) {
             // Step I: create group
             LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
-            beggroup.put("@type", "korap:group");
-            beggroup.put("operation", "operation:" + "submatch");
+            beggroup.put("@type", "korap:reference");
+            beggroup.put("operation", "operation:focus");
             ArrayList<Integer> spanRef = new ArrayList<Integer>();
             if (nodeCat.equals("OPBEG")) {
                 spanRef.add(0);
@@ -573,29 +557,21 @@
             Tree conditions = node.getChild(optsChild).getChild(0);
 
             // create a containing group expressing the submatch constraint on the first argument
-            LinkedHashMap<String, Object> submatchgroup = new LinkedHashMap<String, Object>();
-            submatchgroup.put("@type", "korap:group");
-            submatchgroup.put("operation", "operation:" + "submatch");
             ArrayList<Integer> spanRef = new ArrayList<Integer>();
             spanRef.add(1);
-            submatchgroup.put("classRef", spanRef);
+            LinkedHashMap<String, Object> submatchgroup = makeReference(spanRef);
             ArrayList<Object> submatchoperands = new ArrayList<Object>();
             submatchgroup.put("operands", submatchoperands);
-            putIntoSuperObject(submatchgroup, 0);
+            putIntoSuperObject(submatchgroup);
 
             // Distinguish two cases. Normal case: query has just one condition, like #BED(X, sa) ...
             if (conditions.getChildCount() == 1) {
                 CosmasCondition c = new CosmasCondition(conditions.getChild(0));
 
                 // create the group expressing the position constraint
-                LinkedHashMap<String, Object> posgroup = new LinkedHashMap<String, Object>();
-                posgroup.put("@type", "korap:group");
-                posgroup.put("operation", "operation:" + "position");
-
-                posgroup.put("frame", "frame:" + c.position);
+                LinkedHashMap<String, Object> posgroup = makePosition(c.position);
+                ArrayList<Object> operands = (ArrayList<Object>) posgroup.get("operands");
                 if (c.negated) posgroup.put("exclude", true);
-                ArrayList<Object> operands = new ArrayList<Object>();
-                posgroup.put("operands", operands);
 
                 // create span representing the element expressed in the condition
                 LinkedHashMap<String, Object> bedElem = new LinkedHashMap<String, Object>();
@@ -603,10 +579,7 @@
                 bedElem.put("key", c.elem);
 
                 // create a class group containing the argument, in order to submatch the arg.
-                LinkedHashMap<String, Object> classGroup = new LinkedHashMap<String, Object>();
-                classGroup.put("@type", "korap:group");
-                classGroup.put("operation", "operation:class");
-                classGroup.put("class", classRefCounter);
+                LinkedHashMap<String, Object> classGroup = makeSpanClass(classRefCounter);
                 classRefCounter++;
                 classGroup.put("operands", new ArrayList<Object>());
                 objectStack.push(classGroup);
diff --git a/src/test/java/CosmasTreeTest.java b/src/test/java/CosmasTreeTest.java
index a4e31cf..c73062b 100644
--- a/src/test/java/CosmasTreeTest.java
+++ b/src/test/java/CosmasTreeTest.java
@@ -317,7 +317,7 @@
 	public void testOPIN() throws QueryException {
 		query="wegen #IN <s>";
 		String opin1 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 						"{@type=korap:group, operation=operation:position, frame=frame:contains, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -331,7 +331,7 @@
 		
 		query="wegen #IN(L) <s>";
 		String opin2 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 						"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -345,13 +345,13 @@
 		
 		query="wegen #IN(%, L) <s>";
 		String opin3 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
-						"{@type=korap:group, operation=operation:position, frame=frame:startswith, exclude=true, operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
+						"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
 								"{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
 							"]}" +
-						"]}" +
+						"], exclude=true}" +
 					"]}";
 		ct = new CosmasTree(query);
 		map = ct.getRequestMap().get("query").toString();
@@ -359,13 +359,13 @@
 		
 		query="wegen #IN('FE,ALL,%,MIN') <s>";
 		String opin4 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
-						"{@type=korap:group, operation=operation:position, frame=frame:matches, range=all, exclude=true, grouping=false, operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
+						"{@type=korap:group, operation=operation:position, frame=frame:matches, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
 								"{@type=korap:token, wrap={@type=korap:term, key=wegen, layer=orth, match=match:eq}}" +
 							"]}" +
-						"]}" +
+						"], range=all, exclude=true, grouping=false}" +
 					"]}";
 		ct = new CosmasTree(query);
 		map = ct.getRequestMap().get("query").toString();
@@ -376,7 +376,7 @@
 	public void testOPOV() throws QueryException {
 		query="wegen #OV <s>";
 		String opov1 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 						"{@type=korap:group, operation=operation:position, frame=frame:overlaps, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -390,7 +390,7 @@
 		
 		query="wegen #OV(L) <s>";
 		String opov2 = 
-					"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+					"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 						"{@type=korap:group, operation=operation:position, frame=frame:overlaps-left, operands=[" +
 							"{@type=korap:span, key=s}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -426,7 +426,7 @@
 		// http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/thematische-bsp/bsp-satzlaenge.html
 		query="#BEG(der /w3:5 Mann)";
 		String beg1 = 
-				"{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
+				"{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
 					"{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
 						"{@type=korap:distance, key=w, min=3, max=5}" +
 					"]," +
@@ -444,7 +444,7 @@
 				"{@type=korap:group, operation=operation:sequence, inOrder=true, distances=[" +
 					"{@type=korap:distance, key=w, min=0, max=10}" +
 				"], operands=[" +
-					"{@type=korap:group, operation=operation:submatch, spanRef=[0,1], operands=[" +
+					"{@type=korap:reference, operation=operation:focus, spanRef=[0,1], operands=[" +
 						"{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
 							"{@type=korap:distance, key=w, min=3, max=5}" +
 						"]," +
@@ -461,7 +461,7 @@
 		
 		query="#END(der /w3:5 Mann)";
 		String end1 = 
-				"{@type=korap:group, operation=operation:submatch, spanRef=[-1,1], operands=[" +
+				"{@type=korap:reference, operation=operation:focus, spanRef=[-1,1], operands=[" +
 					"{@type=korap:group, operation=operation:sequence, inOrder=false, distances=[" +
 						"{@type=korap:distance, key=w, min=3, max=5}" +
 					"], " +
@@ -565,7 +565,7 @@
 	public void testOPNHIT() throws QueryException {
 		query="#NHIT(gehen /w1:10 voran)";
 		String nhit1 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1,2], classRefOp=classRefOp:intersection, operands=[" +
 					"{@type=korap:group, operation=operation:sequence, inOrder=false, " +
 						"distances=[" +
 							"{@type=korap:distance, key=w, min=1, max=10}" +
@@ -589,7 +589,7 @@
 	public void testOPBED() throws QueryException {
 		query = "#BED(der , sa)";
 		String bed1 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
 					"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 						"{@type=korap:span, key=s}," +
 						"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -603,7 +603,7 @@
 		
 		query = "#BED(der Mann , +pe)";
 		String bed2 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands= [" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1], operands= [" +
 						"{@type=korap:group, operation=operation:position, frame=frame:endswith, operands=[" +
 							"{@type=korap:span, key=p}," +
 							"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -620,7 +620,7 @@
 		
 		query = "#BED(der Mann , sa,-pa)";
 		String bed3 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 					"{@type=korap:group, operation=operation:sequence, distances=[" +
 						"{@type=korap:distance, key=w, min=0, max=0}" +
 					"], operands=[" +
@@ -654,7 +654,7 @@
 		
 		query = "Der:sa";
 		String col1 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 					"{@type=korap:group, operation=operation:position, frame=frame:startswith, operands=[" +
 						"{@type=korap:span, key=s}," +
 						"{@type=korap:group, operation=operation:class, class=1, operands=[" +
@@ -668,7 +668,7 @@
 		
 		query = "Mann:sa,-pa,+te)";
 		String col2 = 
-				"{@type=korap:group, operation=operation:submatch, classRef=[1], operands=[" +
+				"{@type=korap:reference, operation=operation:focus, classRef=[1], operands=[" +
 					"{@type=korap:group, operation=operation:sequence, distances=[" +
 						"{@type=korap:distance, key=w, min=0, max=0}" +
 					"], operands=[" +