adapted Cosmas and PQ to current JSON-LD specifications
diff --git a/notes.txt b/notes.txt
index a89cf6c..56ad883 100644
--- a/notes.txt
+++ b/notes.txt
@@ -13,4 +13,8 @@
  - operands of distance operators to be expressed via shrink/classes?
  - #BEG() and #END() are solved via shrink, with the shrink argument not being a class but a position (first/last) indicating the first or last word in the matched sequence  
  - #BED() with two conditions (like 'sa,-pa') can't be mapped to position group as implemented -> make two position groups and embed in 'and'-group
+ 
+ 
+ Poliqarp
+ - empty tokens as distance operators
  
\ No newline at end of file
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 beb2c38..6f471e4 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
@@ -136,8 +136,8 @@
 		
 		context.put("korap", "http://korap.ids-mannheim.de/ns/query");
 		context.put("@language", "de");
-		context.put("operands", operands);
-		context.put("relation", relation);
+		context.put("@operands", operands);
+		context.put("@relation", relation);
 		context.put("class", classMap);
 		context.put("query", "korap:query");
 		context.put("filter", "korap:filter");
@@ -203,7 +203,7 @@
 						// Step I: create sequence
 						LinkedHashMap<String, Object> sequence = new LinkedHashMap<String, Object>();
 						sequence.put("@type", "korap:sequence");
-						sequence.put("operands", new ArrayList<Object>());
+						sequence.put("@operands", new ArrayList<Object>());
 						// 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
@@ -230,15 +230,16 @@
 			
 			fieldMap.put("@type", "korap:term");			
 			// make category-specific fieldMap entry
-			String attr = nodeCat.equals("OPWF") ? "orth:" : "base:";
-			String value = attr+node.getChild(0).toStringTree().replaceAll("\"", "");
+			String attr = nodeCat.equals("OPWF") ? "orth" : "lemma";
+			String value = node.getChild(0).toStringTree().replaceAll("\"", "");
 			fieldMap.put("@value", value);
+			fieldMap.put("@attr", attr);
 			
 			// negate field (see above)
 			if (negate) {
-				fieldMap.put("relation", "!=");
+				fieldMap.put("@relation", "!=");
 			} else {
-				fieldMap.put("relation", "=");
+				fieldMap.put("@relation", "=");
 			}
 			//Step II: decide where to put
 			putIntoSuperObject(token, 1);
@@ -248,43 +249,56 @@
 			//Step I: get info
 			LinkedHashMap<String, Object> token = new LinkedHashMap<String, Object>();
 			token.put("@type", "korap:token");
+			LinkedHashMap<String, Object> fieldMap = new LinkedHashMap<String, Object>();
+			token.put("@value", fieldMap);
 			
-			List<String> morphValues = QueryUtils.parseMorph(node.getChild(0).toStringTree());
-			if (morphValues.size() == 1) {
-				LinkedHashMap<String, Object> fieldMap = new LinkedHashMap<String, Object>();
-				token.put("@value", fieldMap);
-				
-				fieldMap.put("@type", "korap:term");
-				fieldMap.put("@value", morphValues.get(0));
-				// make category-specific fieldMap entry
-				// negate field (see above)
-				if (negate) {
-					fieldMap.put("relation", "!=");
-				} else {
-					fieldMap.put("relation", "=");
-				}
+			fieldMap.put("@type", "korap:term");
+//			fieldMap.put("@value", "morph:"+node.getChild(0).toString().replace(" ", "_"));
+			fieldMap.put("@value", node.getChild(0).toString().replace(" ", "_"));
+			// make category-specific fieldMap entry
+			// negate field (see above)
+			if (negate) {
+				fieldMap.put("@relation", "!=");
 			} else {
-				LinkedHashMap<String, Object> conjGroup = new LinkedHashMap<String, Object>();
-				token.put("@value", conjGroup);
-				ArrayList<Object> conjOperands = new ArrayList<Object>();
-				conjGroup.put("@type", "korap:group");
-				conjGroup.put("relation", "and");
-				conjGroup.put("operands", conjOperands);
-				for (String value : morphValues) {
-					LinkedHashMap<String, Object> fieldMap = new LinkedHashMap<String, Object>();
-					token.put("@value", fieldMap);
-					
-					fieldMap.put("@type", "korap:term");
-					fieldMap.put("@value", value);
-					// make category-specific fieldMap entry
-					// negate field (see above)
-					if (negate) {
-						fieldMap.put("relation", "!=");
-					} else {
-						fieldMap.put("relation", "=");
-					}
-				}
+				fieldMap.put("@relation", "=");
 			}
+//			List<String> morphValues = QueryUtils.parseMorph(node.getChild(0).toStringTree());
+//			System.err.println(morphValues);
+//			if (morphValues.size() == 1) {
+//				LinkedHashMap<String, Object> fieldMap = new LinkedHashMap<String, Object>();
+//				token.put("@value", fieldMap);
+//				
+//				fieldMap.put("@type", "korap:term");
+//				fieldMap.put("@value", morphValues.get(0));
+//				// make category-specific fieldMap entry
+//				// negate field (see above)
+//				if (negate) {
+//					fieldMap.put("@relation", "!=");
+//				} else {
+//					fieldMap.put("@relation", "=");
+//				}
+//			} else {
+//				LinkedHashMap<String, Object> conjGroup = new LinkedHashMap<String, Object>();
+//				token.put("@value", conjGroup);
+//				ArrayList<Object> conjOperands = new ArrayList<Object>();
+//				conjGroup.put("@type", "korap:group");
+//				conjGroup.put("@relation", "and");
+//				conjGroup.put("@operands", conjOperands);
+//				for (String value : morphValues) {
+//					LinkedHashMap<String, Object> fieldMap = new LinkedHashMap<String, Object>();
+//					token.put("@value", fieldMap);
+//					
+//					fieldMap.put("@type", "korap:term");
+//					fieldMap.put("@value", value);
+//					// make category-specific fieldMap entry
+//					// negate field (see above)
+//					if (negate) {
+//						fieldMap.put("@relation", "!=");
+//					} else {
+//						fieldMap.put("@relation", "=");
+//					}
+//				}
+//			}
 			
 			
 			//Step II: decide where to put
@@ -294,7 +308,7 @@
 		if (nodeCat.equals("OPELEM")) {
 			// Step I: create element
 			LinkedHashMap<String, Object> elem = new LinkedHashMap<String, Object>();
-			elem.put("@type", "korap:element");
+			elem.put("@type", "korap:span");
 			elem.put("@value", node.getChild(0).getChild(0).toStringTree().toLowerCase());
 			//Step II: decide where to put
 			putIntoSuperObject(elem);
@@ -303,7 +317,7 @@
 		if (nodeCat.equals("OPLABEL")) {
 			// Step I: create element
 			LinkedHashMap<String, Object> elem = new LinkedHashMap<String, Object>();
-			elem.put("@type", "korap:element");
+			elem.put("@type", "korap:span");
 			elem.put("@value", node.getChild(0).toStringTree().replaceAll("<|>", ""));
 			//Step II: decide where to put
 			putIntoSuperObject(elem);
@@ -316,8 +330,8 @@
 			String relation = "or";
 			if (nodeCat.equals("OPAND")) relation = "and";
 			if (nodeCat.equals("OPNOT")) relation = "not";
-			disjunction.put("relation", relation);
-			disjunction.put("operands", new ArrayList<Object>());
+			disjunction.put("@relation", relation);
+			disjunction.put("@operands", new ArrayList<Object>());
 			objectStack.push(disjunction);
 			stackedObjects++;
 			// Step II: decide where to put
@@ -325,25 +339,28 @@
 		}
 		
 		if (nodeCat.equals("OPPROX")) {
+			//TODO direction "both": wrap in "or" group with operands once flipped, once not
 			// 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> proxGroup = new LinkedHashMap<String, Object>();
-			proxGroup.put("@type", "korap:group");
-			proxGroup.put("relation", "distance");
-			objectStack.push(proxGroup);
+			LinkedHashMap<String, Object> proxSequence = new LinkedHashMap<String, Object>();
+			proxSequence.put("@type", "korap:sequence");
+			objectStack.push(proxSequence);
 			stackedObjects++;
-			if (openNodeCats.get(1).equals("OPALL")) proxGroup.put("match", "all");
-			else if (openNodeCats.get(1).equals("OPNHIT")) proxGroup.put("match", "between");
-			else proxGroup.put("match", "operands");
+//			if (openNodeCats.get(1).equals("OPALL")) proxSequence.put("match", "all");
+//			else if (openNodeCats.get(1).equals("OPNHIT")) proxSequence.put("match", "between");
+//			else proxSequence.put("match", "operands");
 			ArrayList<Object> constraints = new ArrayList<Object>();
-			String subtype = typ.getChild(0).toStringTree().equals("PROX") ? "incl" : "excl"; 
-			proxGroup.put("@subtype", subtype);
-			proxGroup.put("constraint", constraints);
+			boolean exclusion = ! typ.getChild(0).toStringTree().equals("PROX"); 
+			
+			String inOrder = "true";
+			proxSequence.put("@inOrder", inOrder);
+			proxSequence.put("@constraints", constraints);
+			
 			ArrayList<Object> operands = new ArrayList<Object>(); 
-			proxGroup.put("operands", operands);
+			proxSequence.put("@operands", operands);
 			
 			// if only one dist_info, put directly into constraints
 			if (dist_list.getChildCount()==1) {
@@ -357,22 +374,27 @@
 				if (direction.equals("minus")) {
 					direction = "plus";
 					invertedOperandsLists.add(operands);
+				} else if (direction.equals("both")) {
+					inOrder="false";
 				}
 				LinkedHashMap<String, Object> distance = new LinkedHashMap<String, Object>();
 				distance.put("@type", "korap:distance");
-				distance.put("measure", meas);
-				distance.put("direction", direction);
-				distance.put("min", min);
-				distance.put("max", max);
+				distance.put("@measure", meas);
+				distance.put("@min", Integer.parseInt(min));
+				distance.put("@max", Integer.parseInt(max));
+				if (exclusion) {
+					distance.put("@exclude", exclusion);
+				}
 				constraints.add(distance);
+				proxSequence.put("@inOrder", inOrder);
 			}
 			// otherwise, create group and add info there
 			else {
 				LinkedHashMap<String, Object> distanceGroup = new LinkedHashMap<String, Object>();
 				ArrayList<Object> groupOperands = new ArrayList<Object>();
 				distanceGroup.put("@type", "korap:group");
-				distanceGroup.put("relation", "and");
-				distanceGroup.put("operands", groupOperands);
+				distanceGroup.put("@relation", "and");
+				distanceGroup.put("@operands", groupOperands);
 				constraints.add(distanceGroup);
 				for (int i=0; i<dist_list.getChildCount(); i++) {
 					String direction = dist_list.getChild(i).getChild(0).getChild(0).toStringTree().toLowerCase();
@@ -384,32 +406,42 @@
 					}
 					LinkedHashMap<String, Object> distance = new LinkedHashMap<String, Object>();
 					distance.put("@type", "korap:distance");
-					distance.put("measure", meas);
-					distance.put("direction", direction);
-					distance.put("min", min);
-					distance.put("max", max);
+					distance.put("@measure", meas);
+					distance.put("@min", min);
+					distance.put("@max", max);
+					if (exclusion) {
+						distance.put("@exclude", exclusion);
+					}
 					groupOperands.add(distance);
+					if (direction.equals("plus")) {
+						inOrder="true";
+					} else if (direction.equals("minus")) {
+						inOrder="true";
+						invertedOperandsLists.add(operands);
+					}
 				}
+				proxSequence.put("@inOrder", inOrder);
+				
 			}
 			// Step II: decide where to put
-			putIntoSuperObject(proxGroup, 1);
+			putIntoSuperObject(proxSequence, 1);
 		}
 		
 		// inlcusion or overlap
 		if (nodeCat.equals("OPIN") || nodeCat.equals("OPOV")) {
 			// Step I: create group
-			LinkedHashMap<String, Object> shrinkgroup = new LinkedHashMap<String, Object>();
-			shrinkgroup.put("@type", "korap:group");
-			shrinkgroup.put("relation", "shrink");
-			shrinkgroup.put("shrink", "1");
+			LinkedHashMap<String, Object> submatchgroup = new LinkedHashMap<String, Object>();
+			submatchgroup.put("@type", "korap:group");
+			submatchgroup.put("@relation", "submatch");
+			submatchgroup.put("@classRef", "1");
 			
-			ArrayList<Object> shrinkoperands = new ArrayList<Object>(); 
+			ArrayList<Object> submatchoperands = new ArrayList<Object>(); 
 			LinkedHashMap<String, Object> posgroup = new LinkedHashMap<String, Object>();
-			shrinkgroup.put("operands", shrinkoperands);
-			shrinkoperands.add(posgroup);
+			submatchgroup.put("@operands", submatchoperands);
+			submatchoperands.add(posgroup);
 			posgroup.put("@type", "korap:group");
-			String relation = nodeCat.equals("OPIN") ? "position" : "overlap";
-			posgroup.put("relation", relation);
+			String relation = nodeCat.equals("OPIN") ? "position" : "overlaps";
+			posgroup.put("@relation", relation);
 			
 			if (nodeCat.equals("OPIN")) {
 				parseOPINOptions(node, posgroup);
@@ -419,14 +451,14 @@
 			
 			
 			ArrayList<Object> posoperands = new ArrayList<Object>();
-			posgroup.put("operands", posoperands);
+			posgroup.put("@operands", posoperands);
 			objectStack.push(posgroup);
 			// mark this an inverted list
 			invertedOperandsLists.push(posoperands);
 			stackedObjects++;
 			
 			// Step II: decide where to put
-			putIntoSuperObject(shrinkgroup, 1);
+			putIntoSuperObject(submatchgroup, 1);
 		}
 		
 		
@@ -436,7 +468,7 @@
 			LinkedHashMap<String, Object> classGroup = new LinkedHashMap<String, Object>();
 			classGroup.put("@type", "korap:group");
 			classGroup.put("class", "1");
-			classGroup.put("operands", new ArrayList<Object>());
+			classGroup.put("@operands", new ArrayList<Object>());
 			objectStack.push(classGroup);
 			stackedObjects++;
 			// Step II: decide where to put
@@ -452,10 +484,15 @@
 			// Step I: create group
 			LinkedHashMap<String, Object> beggroup = new LinkedHashMap<String, Object>();
 			beggroup.put("@type", "korap:group");
-			beggroup.put("relation", "shrink");
-			String reduction = nodeCat.equals("OPBEG") ? "first" : "last";
-			beggroup.put("shrink", reduction);
-			beggroup.put("operands", new ArrayList<Object>());
+			beggroup.put("@relation", "submatch");
+			ArrayList<Integer> spanRef = new ArrayList<Integer>();
+			if (nodeCat.equals("OPBEG")) {
+				spanRef.add(0); spanRef.add(1);
+			} else {
+				spanRef.add(-1); spanRef.add(1);
+			}
+			beggroup.put("@spanRef", spanRef);
+			beggroup.put("@operands", new ArrayList<Object>());
 			objectStack.push(beggroup);
 			stackedObjects++;
 			
@@ -471,15 +508,15 @@
 			if (conditions.getChildCount()==1) {
 				LinkedHashMap<String, Object> posgroup = new LinkedHashMap<String, Object>();
 				posgroup.put("@type", "korap:group");
-				posgroup.put("relation", "position");
+				posgroup.put("@relation", "position");
 				CosmasCondition c = new CosmasCondition(conditions.getChild(0));
-				posgroup.put("position", c.position);
-				if (c.negated) posgroup.put("@subtype", "excl");
+				posgroup.put("@position", c.position);
+				if (c.negated) posgroup.put("@relation", "!=");
 				ArrayList<Object> operands = new ArrayList<Object>();
-				posgroup.put("operands", operands);
+				posgroup.put("@operands", operands);
 				LinkedHashMap<String, Object> bedElem = new LinkedHashMap<String, Object>();
 				operands.add(bedElem);
-				bedElem.put("@type", "korap:element");
+				bedElem.put("@type", "korap:span");
 				bedElem.put("@value", c.elem);
 				objectStack.push(posgroup);
 				stackedObjects++;
@@ -492,9 +529,9 @@
 				// -> create 'and' group and embed all position groups there
 				LinkedHashMap<String, Object> conjunct = new LinkedHashMap<String, Object>();
 				conjunct.put("@type", "korap:group");
-				conjunct.put("relation", "and");
+				conjunct.put("@relation", "and");
 				ArrayList<Object> operands = new ArrayList<Object>();
-				conjunct.put("operands", operands);
+				conjunct.put("@operands", operands);
 				ArrayList<ArrayList<Object>> distributedOperands = new ArrayList<ArrayList<Object>>();
 				
 				for (int i=0; i<conditions.getChildCount(); i++) {
@@ -505,15 +542,15 @@
 					
 					CosmasCondition c = new CosmasCondition(conditions.getChild(i));
 					posGroup.put("@type", "korap:group");
-					posGroup.put("relation", "position");
-					posGroup.put("position", c.position);
-					if (c.negated) posGroup.put("@subtype", "excl");
+					posGroup.put("@relation", "position");
+					posGroup.put("@position", c.position);
+					if (c.negated) posGroup.put("@exclude", "true");
 					ArrayList<Object> posOperands = new ArrayList<Object>();
 					distributedOperands.add(posOperands);
-					posGroup.put("operands", posOperands);
+					posGroup.put("@operands", posOperands);
 					LinkedHashMap<String, Object> bedElem = new LinkedHashMap<String, Object>();
 					posOperands.add(bedElem);
-					bedElem.put("@type", "korap:element");
+					bedElem.put("@type", "korap:span");
 					bedElem.put("@value", c.elem);
 					
 					
@@ -586,7 +623,7 @@
 		} else {
 			position = "contains";
 		}
-		posgroup.put("position", position);
+		posgroup.put("@position", position);
 		position = openNodeCats.get(1).equals("OPIN") ? "contains" : "full";
 		
 		if (rangenode != null) {
@@ -599,13 +636,14 @@
 				negatePosition = !negatePosition;
 			}
 		}
-		
+		System.err.println(negatePosition);
 		if (negatePosition) {
-			posgroup.put("@subtype", "excl");	
+			posgroup.put("@exclude", "true");	
+//			negate = !negate;
 		}
 		
 		if (groupnode != null) {
-			String grouping = groupnode.getChild(0).toStringTree().equals("MAX") ? "true" : "false";
+			String grouping = groupnode.getChild(0).toStringTree().equals("max") ? "true" : "false";
 			posgroup.put("grouping", grouping);
 		}
 	}
@@ -622,16 +660,16 @@
 		} else {
 			position = "any";
 		}
-		posgroup.put("position", position);
+		posgroup.put("@position", position);
 		position = openNodeCats.get(1).equals("OPIN") ? "contains" : "full";
 		
 		if (exclnode != null) {
 			if (exclnode.getChild(0).toStringTree().equals("YES")) {
-				posgroup.put("@subtype", "excl");
+				posgroup.put("@relation", "!=");
 			}
 		}
 		if (groupnode != null) {
-			String grouping = groupnode.getChild(0).toStringTree().equals("MAX") ? "true" : "false";
+			String grouping = groupnode.getChild(0).toStringTree().equals("@max") ? "true" : "false";
 			posgroup.put("grouping", grouping);
 		}
 		
@@ -681,7 +719,7 @@
 				operands.add(object);
 			}
 		} else if (objectStack.size()>objStackPosition) {
-			ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack.get(objStackPosition).get("operands");
+			ArrayList<Object> topObjectOperands = (ArrayList<Object>) objectStack.get(objStackPosition).get("@operands");
 			if (!invertedOperandsLists.contains(topObjectOperands)) {
 				topObjectOperands.add(object);
 			} else {
@@ -724,7 +762,12 @@
 		 */
 		String[] queries = new String[] {
 				/* COSMAS 2 */
-				"MORPH(V)"
+				"MORPH(V)",
+				"MORPH(V PRES)",
+				"wegen #IN(%, L) <s>",
+				"wegen #IN(%) <s>",
+				"(Mann oder Frau) #IN <s>",
+				"#BEG(der /w3:5 Mann) /+w10 kommt"
 				};
 		CosmasTree.debug=true;
 		for (String q : queries) {
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
index b10105c..530f597 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/PoliqarpPlusTree.java
@@ -178,8 +178,8 @@
 		
 		context.put("korap", "http://korap.ids-mannheim.de/ns/query");
 		context.put("@language", "de");
-		context.put("operands", operands);
-		context.put("relation", relation);
+		context.put("@operands", operands);
+		context.put("@relation", relation);
 		context.put("class", classMap);
 		context.put("query", "korap:query");
 		context.put("filter", "korap:filter");
@@ -277,7 +277,6 @@
 				}
 				// Step I: decide type of element (one or more elements? -> token or sequence)
 				// take into account a possible 'occ' child with accompanying parantheses, therefore 3 extra children
-				// TODO analyse emptysegments
 				int occExtraChildren = cqHasOccChild ? 3:0;
 				if (node.getChildCount()>1 + occExtraChildren) {
 					ParseTree emptySegments = QueryUtils.getFirstChildWithCat(node, "empty_segments");
@@ -285,20 +284,19 @@
 						String[] minmax = parseEmptySegments(emptySegments);
 						Integer min = Integer.parseInt(minmax[0]);
 						Integer max = Integer.parseInt(minmax[1]);
-						sequence.put("@type", "korap:group");
-						sequence.put("relation", "distance");
-						sequence.put("@subtype", "incl");
+						sequence.put("@type", "korap:sequence");
+//						sequence.put("@relation", "distance");
+						sequence.put("@inOrder", "true");
 						ArrayList<Object> constraint = new ArrayList<Object>(); 
-						sequence.put("constraint", constraint);
+						sequence.put("@constraints", constraint);
 						ArrayList<Object> sequenceOperands = new ArrayList<Object>();
-						sequence.put("operands", sequenceOperands);
+						sequence.put("@operands", sequenceOperands);
 						objectStack.push(sequence);
 						stackedObjects++;
 						LinkedHashMap<String, Object> distMap = new LinkedHashMap<String, Object>();
 						constraint.add(distMap);
 						distMap.put("@type", "korap:distance");
 						distMap.put("measure", "w");
-						distMap.put("direction", "plus");
 						distMap.put("min", min);
 						distMap.put("max", max);
 					} else {
@@ -311,7 +309,7 @@
 							sequence.put("offset-min", min);
 							sequence.put("offset-max", max);
 						}
-						sequence.put("operands", sequenceOperands);
+						sequence.put("@operands", sequenceOperands);
 						objectStack.push(sequence);
 						stackedObjects++;
 					}
@@ -334,7 +332,7 @@
 				// Step II: decide where to put this element 
 				// check if this is an argument for a containing occurrence group (see step 0)
 				if (cqHasOccSibling) {
-					ArrayList<Object> topGroupOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+					ArrayList<Object> topGroupOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 					topGroupOperands.add(sequence);
 				// ...if not modified by occurrence, put into suitable super structure
 				} else {
@@ -350,20 +348,20 @@
 								LinkedHashMap<String,Object> superSequence = new LinkedHashMap<String,Object>();
 								superSequence.put("@type", "korap:sequence");
 								ArrayList<Object> operands = new ArrayList<Object>();
-								superSequence.put("operands", operands);
+								superSequence.put("@operands", operands);
 								operands.add(sequence);
 								requestMap.put("query", superSequence);
 								objectStack.push(superSequence); // add at 2nd position to keep current cq_segment accessible
 								stackedObjects++;
 							} else {
 								// if not first child, add to previously created parent sequence
-								ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+								ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 								topSequenceOperands.add(sequence);
 							}
 						}
 					} else if (!objectStack.isEmpty()){
 						// embed in super sequence
-						ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+						ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 						topSequenceOperands.add(sequence);
 					}
 				}
@@ -404,7 +402,7 @@
 //					}
 //					
 				} else {
-					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(onTopOfObjectStack).get("operands");
+					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(onTopOfObjectStack).get("@operands");
 					topSequenceOperands.add(token);
 				}
 			}
@@ -415,13 +413,13 @@
 			LinkedHashMap<String,Object> group = new LinkedHashMap<String,Object>();
 			curOccGroup = group;
 			group.put("@type", "korap:group");
-			group.put("operands", new ArrayList<Object>());
+			group.put("@operands", new ArrayList<Object>());
 			objectStack.push(group);
 			stackedObjects++;
 			// add group to sequence only if it is not an only child (in that case, cq_segments has already added the info and is just waiting for the values from "field")
 			// take into account a possible 'occ' child
 			if (node.getParent().getChildCount()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(group);
 			} else {
 				requestMap.put("query", group);
@@ -435,13 +433,13 @@
 			stackedObjects++;
 			ArrayList<Object> disjOperands = new ArrayList<Object>();
 			disjunction.put("@type", "korap:group");
-			disjunction.put("relation", "or");
-			disjunction.put("operands", disjOperands);
+			disjunction.put("@relation", "or");
+			disjunction.put("@operands", disjOperands);
 			// decide where to put the disjunction
 			if (openNodeCats.get(1).equals("query")) {
 				requestMap.put("query", disjunction);	
 			} else if (openNodeCats.get(1).equals("cq_segments")) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(disjunction);
 			}
 		}
@@ -479,8 +477,15 @@
 				value = valNode.getChild(0).toStringTree(poliqarpParser); 				//e.g. (re_query "bar*")
 				fieldMap.put("@subtype", "korap:value#regex");
 			}
-			fieldMap.put("@value", fieldName+":"+value);
-			fieldMap.put("relation", relation);
+			fieldMap.put("@value", value);
+			if (fieldName.contains("/")) {
+				String[] splitted = fieldName.split("/");
+				fieldMap.put("@attr", splitted[1]);
+				fieldMap.put("@foundry", splitted[0]);
+			} else {
+				fieldMap.put("@attr", fieldName);
+			}
+			fieldMap.put("@relation", relation);
 			// Step II: decide where to put the field map (as the only value of a token or the meta filter or as a part of a group in case of coordinated fields)
 			if (fieldStack.isEmpty()) {
 				if (!inMeta) {
@@ -505,7 +510,7 @@
 			LinkedHashMap<String,Object> group = new LinkedHashMap<String,Object>(); 
 			ArrayList<Object> groupOperands = new ArrayList<Object>();
 			group.put("@type", "korap:group");
-			group.put("operands", groupOperands);
+			group.put("@operands", groupOperands);
 			fieldStack.push(groupOperands);
 			stackedFields++;
 			// Step I: get operator (& or |)
@@ -515,7 +520,7 @@
 			if (negField) {
 				relation = relation.equals("or") ? "and": "or";
 			}
-			group.put("relation", relation);
+			group.put("@relation", relation);
 			// Step II: decide where to put the group (directly under token or in top meta filter section or embed in super group)
 			if (openNodeCats.get(1).equals("cq_segment")) {
 				tokenStack.getFirst().put("@value", group);
@@ -554,15 +559,15 @@
 				LinkedHashMap<String,Object> tokenValues = new LinkedHashMap<String,Object>();
 				token.put("@value", tokenValues);
 				tokenValues.put("@type", "korap:term");
-				tokenValues.put("@value", "orth:"+word);
-				tokenValues.put("relation", "=");
+				tokenValues.put("@value", word);
+				tokenValues.put("@attr", "orth");
+				tokenValues.put("@relation", "=");
 				// add token to sequence only if it is not an only child (in that case, sq_segments has already added the info and is just waiting for the values from "field")
 				if (node.getParent().getChildCount()>1) {
-					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 					topSequenceOperands.add(token);
 				}
 			}
-			System.out.println(stackedObjects+" "+objectStack);
 			visited.add(node.getChild(0));
 		}
 		
@@ -571,7 +576,7 @@
 			reQuery.put("@subtype", "korap:regex");
 			String regex = node.getChild(0).toStringTree(poliqarpParser);
 			reQuery.put("@value", regex);
-			reQuery.put("relation", "=");
+			reQuery.put("@relation", "=");
 			
 			// if in field, regex was already added there
 			if (!openNodeCats.get(1).equals("field")) {
@@ -583,7 +588,7 @@
 				if (openNodeCats.get(1).equals("query")) {
 					requestMap.put("query", token);
 				} else {
-					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+					ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 					topSequenceOperands.add(token);
 				}
 			} 
@@ -600,17 +605,17 @@
 			// Step I: get info
 			// fill group
 			alignGroup.put("@type", "korap:group");
-			alignGroup.put("relation", "left-align");
-			alignGroup.put("operands", new ArrayList<Object>());
+			alignGroup.put("@relation", "left-align");
+			alignGroup.put("@operands", new ArrayList<Object>());
 			// Step II: decide where to put the group
 			// add group to sequence only if it is not an only child (in that case, sq_segments has already added the info and is just waiting for the relevant info)
 			if (node.getParent().getChildCount()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(alignGroup); 
 			} else if (openNodeCats.get(2).equals("query")) {
 				requestMap.put("query", alignGroup);	
 			} else {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(alignGroup); 
 			}
 			visited.add(node.getChild(0));
@@ -629,12 +634,12 @@
 			objectStack.push(elem);
 			stackedObjects++;
 			// Step II: fill object (token values) and put into containing sequence
-			elem.put("@type", "korap:element");
+			elem.put("@type", "korap:span");
 			String value = node.getChild(1).toStringTree(poliqarpParser);
 			elem.put("@value", value);
 			// add token to sequence only if it is not an only child (in that case, cq_segments has already added the info and is just waiting for the values from "field")
 			if (node.getParent().getChildCount()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(elem);
 			}
 			visited.add(node.getChild(0));
@@ -661,13 +666,13 @@
 			}
 			span.put("@type", "korap:group");
 			span.put("class", id);
-			span.put("operands", spanOperands);
+			span.put("@operands", spanOperands);
 			// Step II: decide where to put the span
 			// add span to sequence only if it is not an only child (in that case, cq_segments has already added the info and is just waiting for the relevant info)
 			if (openNodeCats.get(2).equals("query") && node.getParent().getChildCount() == 1) {
 				requestMap.put("query", span);	
 			} else if (objectStack.size()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(span); 
 			} 
 			// ignore leading and trailing braces
@@ -686,19 +691,19 @@
 			// Step I: get info
 			String relation = QueryUtils.getNodeCat(node.getChild(0));
 			positionGroup.put("@type", "korap:group");
-			positionGroup.put("relation", "position");
-			positionGroup.put("position", relation.toLowerCase());
+			positionGroup.put("@relation", "position");
+			positionGroup.put("@position", relation.toLowerCase());
 //			positionGroup.put("@subtype", "incl");
-			positionGroup.put("operands", posOperands);
+			positionGroup.put("@operands", posOperands);
 			// Step II: decide where to put the group
 			// add group to sequence only if it is not an only child (in that case, sq_segments has already added the info and is just waiting for the relevant info)
 			if (node.getParent().getChildCount()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(positionGroup); 
 			} else if (openNodeCats.get(2).equals("query")) {
 				requestMap.put("query", positionGroup);	
 			} else {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 				topSequenceOperands.add(positionGroup); 
 			}
 		}
@@ -720,19 +725,19 @@
 				}
 			}
 			shrinkGroup.put("@type", "korap:group");
-			shrinkGroup.put("relation", "shrink");
-			shrinkGroup.put(type, operandClass);
-			shrinkGroup.put("operands", shrinkOperands);
+			shrinkGroup.put("@relation", type);
+			shrinkGroup.put("classRef", operandClass);
+			shrinkGroup.put("@operands", shrinkOperands);
 			int i=1;
 			// Step II: decide where to put the group
 			// add group to sequence only if it is not an only child (in that case, sq_segments has already added the info and is just waiting for the relevant info)
 			if (node.getParent().getChildCount()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("operands"); // this shrinkGroup is on top
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("@operands"); // this shrinkGroup is on top
 				topSequenceOperands.add(shrinkGroup);
 			} else if (openNodeCats.get(2).equals("query")) {
 				requestMap.put("query", shrinkGroup);	
 			} else if (objectStack.size()>1) {
-				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("operands");
+				ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(i).get("@operands");
 				topSequenceOperands.add(shrinkGroup); 
 			} 
 			visited.add(node.getChild(0));
@@ -742,8 +747,10 @@
 		if (nodeCat.equals("occ")) {
 			ParseTree occChild = node.getChild(0);
 			String repetition = occChild.toStringTree(poliqarpParser);
-			curOccGroup.put("relation", "repetition");
-			curOccGroup.put("quantifier", repetition);
+			String[] minmax = parseRepetition(repetition);
+			curOccGroup.put("@relation", "repetition");
+			curOccGroup.put("@min", minmax[0]);
+			curOccGroup.put("@max", minmax[1]);
 			visited.add(occChild);
 		}
 				
@@ -815,6 +822,19 @@
 		openNodeCats.pop();
 	}
 
+	private String[] parseRepetition(String repetition) {
+		if (repetition.equals("*")) {
+			return new String[] {"0", "100"};
+		} else if (repetition.equals("+")) {
+			return new String[] {"1", "100"};
+		} else if (repetition.equals("?")) {
+			return new String[] {"0", "1"};
+		} else {
+			repetition = repetition.substring(1, repetition.length()-1); // remove braces
+			return repetition.split(",");
+		}
+	}
+
 	private String[] parseEmptySegments(ParseTree emptySegments) {
 		String[] minmax = new String[2];
 		Integer min = 0;
@@ -824,8 +844,6 @@
 			child = emptySegments.getChild(i);
 			ParseTree nextSibling = emptySegments.getChild(i+1);
 			String nextSiblingString = nextSibling.toStringTree(); 
-			System.err.println("FOO "+child.toStringTree());
-			System.out.println("FOO "+nextSiblingString);
 			if (child.toStringTree().equals("[]")) {
 				if (nextSiblingString.equals("?")) {
 					max++;
@@ -861,7 +879,7 @@
 		LinkedHashMap<String,Object> occGroup = new LinkedHashMap<String,Object>();
 		occGroup.put("@type", "korap:group");
 		ArrayList<Object> groupOperands = new ArrayList<Object>();
-		occGroup.put("operands", groupOperands);
+		occGroup.put("@operands", groupOperands);
 		curOccGroup = occGroup;
 		objectStack.push(occGroup);
 		stackedObjects++;
@@ -870,7 +888,7 @@
 				requestMap.put("query", occGroup);
 		// embed in super sequence
 		} else {
-			ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("operands");
+			ArrayList<Object> topSequenceOperands = (ArrayList<Object>) objectStack.get(1).get("@operands");
 			topSequenceOperands.add(occGroup);
 		}		
 	}
@@ -921,6 +939,9 @@
 				"startswith(<s>,[][base=der][base=Mann])",
 //				"[][base=Mann]",
 				"[base=Hund][][base=Katze][][][base=Maus]",
+				"[base=Hund][]?[][base=Katze]",
+				"split([base=der]{[base=Mann]})",
+				"[base=Mann&gen=m&cas=N]"
 		};
 		PoliqarpPlusTree.debug=true;
 		for (String q : queries) {
diff --git a/src/test/java/CosmasTreeTest.java b/src/test/java/CosmasTreeTest.java
index 0d7db7a..efe86f6 100644
--- a/src/test/java/CosmasTreeTest.java
+++ b/src/test/java/CosmasTreeTest.java
@@ -26,7 +26,7 @@
 	
 	@Test
 	public void testContext() throws QueryException {
-		String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, operands={@id=korap:operands, @container=@list}, relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}";
+		String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, @operands={@id=korap:operands, @container=@list}, @relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}";
 		ppt = new CosmasTree("Test");
 		assertTrue(equalsContent(contextString, ppt.getRequestMap().get("@context")));
 	}
@@ -36,31 +36,31 @@
 	public void testSingleToken() throws QueryException {
 		query="der";
 		String single1 = 
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}";
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(single1.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		query="Mann";
 		String single2 = 
-				"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}";
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(single2.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		query="&Mann";
 		String single3 = 
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}";
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=lemma, @relation==}}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(single3.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
-//	@Test
+	@Test
 	public void testMORPH() throws QueryException {
 		query="#MORPH(V)";
 		String morph1 = 
-					"{@type=korap:token, @value={@type=korap:term, @value=pos:v, relation==}}";
+					"{@type=korap:token, @value={@type=korap:term, @value=V, @relation==}}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(morph1.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -70,9 +70,9 @@
 	public void testSequence() throws QueryException {
 		query="der Mann";
 		String seq1 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -80,10 +80,10 @@
 		
 		query="der Mann schläft";
 		String seq2 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:schläft, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=schläft, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -91,11 +91,11 @@
 		
 		query="der Mann schläft lang";
 		String seq3 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:schläft, relation==}}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:lang, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=schläft, @attr=orth, @relation==}}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=lang, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -106,9 +106,9 @@
 	public void testOPOR() throws QueryException {
 		query="Sonne oder Mond";
 		String disj1 = 
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 					"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -116,12 +116,12 @@
 		
 		query="(Sonne scheint) oder Mond";
 		String disj2 = 
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:scheint, relation==}}" +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=scheint, @attr=orth, @relation==}}" +
 						"]}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 					"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -129,14 +129,14 @@
 		
 		query="(Sonne scheint) oder (Mond scheint)";
 		String disj3 = 
-				"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:scheint, relation==}}" +
+				"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=scheint, @attr=orth, @relation==}}" +
 						"]}," +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:scheint, relation==}}" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=scheint, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}";
 		ppt = new CosmasTree(query);
@@ -149,12 +149,12 @@
 	public void testOPORAND() throws QueryException {
 		query="(Sonne oder Mond) und scheint";
 		String orand1 = 
-				"{@type=korap:group, relation=and, operands=[" +
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+				"{@type=korap:group, @relation=and, @operands=[" +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 					"]}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:scheint, relation==}}" +
+					"{@type=korap:token, @value={@type=korap:term, @value=scheint, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -162,11 +162,11 @@
 		
 		query="scheint und (Sonne oder Mond)";
 		String orand2 = 
-				"{@type=korap:group, relation=and, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:scheint, relation==}}," +
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+				"{@type=korap:group, @relation=and, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=scheint, @attr=orth, @relation==}}," +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new CosmasTree(query);
@@ -178,13 +178,13 @@
 	public void testOPPROX() throws QueryException {
 		query="Sonne /+w1:4 Mond";
 		String prox1 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-						"constraint=[" +
-							"{@type=korap:distance, measure=w, direction=plus, min=1, max=4}" +
+					"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:distance, @measure=w, @min=1, @max=4}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+						"@operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -193,17 +193,17 @@
 		
 		query="Sonne /+w1:4,s0,p1:3 Mond";
 		String prox2 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-						"constraint=[" +
-							"{@type=korap:group, relation=and, operands=[" +
-								"{@type=korap:distance, measure=w, direction=plus, min=1, max=4}," +
-								"{@type=korap:distance, measure=s, direction=both, min=0, max=0}," +
-								"{@type=korap:distance, measure=p, direction=both, min=1, max=3}" +
+					"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:group, @relation=and, @operands=[" +
+								"{@type=korap:distance, @measure=w, @min=1, @max=4}," +
+								"{@type=korap:distance, @measure=s, @min=0, @max=0}," +
+								"{@type=korap:distance, @measure=p, @min=1, @max=3}" +
 							"]}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+						"@operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -212,17 +212,17 @@
 		
 		query="Sonne %+w1:4,s0,p1:3 Mond";
 		String prox3 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=excl, " +
-						"constraint=[" +
-							"{@type=korap:group, relation=and, operands=[" +
-								"{@type=korap:distance, measure=w, direction=plus, min=1, max=4}," +
-								"{@type=korap:distance, measure=s, direction=both, min=0, max=0}," +
-								"{@type=korap:distance, measure=p, direction=both, min=1, max=3}" +
+				"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:group, @relation=and, @operands=[" +
+								"{@type=korap:distance, @measure=w, @min=1, @max=4, @exclude=true}," +
+								"{@type=korap:distance, @measure=s, @min=0, @max=0, @exclude=true}," +
+								"{@type=korap:distance, @measure=p, @min=1, @max=3, @exclude=true}" +
 							"]}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+						"@operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -231,13 +231,13 @@
 		
 		query="Sonne /+w4 Mond";
 		String prox4 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-						"constraint=[" +
-							"{@type=korap:distance, measure=w, direction=plus, min=0, max=4}" +
+					"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:distance, @measure=w, @min=0, @max=4}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+						"@operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -246,13 +246,13 @@
 		
 		query="Sonne /-w4 Mond";
 		String prox5 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-						"constraint=[" +
-							"{@type=korap:distance, measure=w, direction=plus, min=0, max=4}" +
+					"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:distance, @measure=w, @min=0, @max=4}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}" +
+						"@operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -261,23 +261,23 @@
 	}
 	
 	@Test
-	public void testNestedOPPROX() throws QueryException {	
+	public void testOPPROXNested() throws QueryException {	
 		query="Sonne /-w4 Mond /+w2 Sterne";
 		String prox6 = 
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-						"constraint=[" +
-							"{@type=korap:distance, measure=w, direction=plus, min=0, max=4}" +
+					"{@type=korap:sequence, @inOrder=true, " +
+						"@constraints=[" +
+							"{@type=korap:distance, @measure=w, @min=0, @max=4}" +
 						"], " +
-						"operands=[" +
-							"{@type=korap:group, relation=distance, match=operands, @subtype=incl, " +
-								"constraint=[" +
-									"{@type=korap:distance, measure=w, direction=plus, min=0, max=2}" +
+						"@operands=[" +
+							"{@type=korap:sequence, @inOrder=true, " +
+								"@constraints=[" +
+									"{@type=korap:distance, @measure=w, @min=0, @max=2}" +
 								"], " +
-								"operands=[" +
-									"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}," +
-									"{@type=korap:token, @value={@type=korap:term, @value=orth:Sterne, relation==}}" +
+								"@operands=[" +
+									"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}," +
+									"{@type=korap:token, @value={@type=korap:term, @value=Sterne, @attr=orth, @relation==}}" +
 								"]}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}" +
 						"]" +
 					"}";
 		ppt = new CosmasTree(query);
@@ -289,11 +289,11 @@
 	public void testOPIN() throws QueryException {
 		query="wegen #IN <s>";
 		String opin1 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=position, position=contains, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -303,11 +303,11 @@
 		
 		query="wegen #IN(L) <s>";
 		String opin2 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=position, position=startswith, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -317,11 +317,11 @@
 		
 		query="wegen #IN(%, L) <s>";
 		String opin3 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=position, position=startswith, @subtype=excl, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=position, @position=startswith, @exclude=true, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -331,11 +331,11 @@
 		
 		query="wegen #IN('FE,ALL,%,MIN') <s>";
 		String opin4 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=position, position=ident, range=all, @subtype=excl, grouping=false, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=position, @position=ident, range=all, @exclude=true, grouping=false, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -348,11 +348,11 @@
 	public void testOPOV() throws QueryException {
 		query="wegen #OV <s>";
 		String opov1 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=overlap, position=any, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=overlaps, @position=any, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -362,11 +362,11 @@
 		
 		query="wegen #OV(L) <s>";
 		String opov2 = 
-					"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-						"{@type=korap:group, relation=overlap, position=startswith, operands=[" +
-							"{@type=korap:element, @value=s}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:wegen, relation==}}" +
+					"{@type=korap:group, @relation=submatch, @classRef=1, @operands=[" +
+						"{@type=korap:group, @relation=overlaps, @position=startswith, @operands=[" +
+							"{@type=korap:span, @value=s}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=wegen, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					"]}";
@@ -379,9 +379,9 @@
 	public void testOPNOT() throws QueryException {
 		query="Sonne nicht Mond";
 		String opnot1 = 
-					"{@type=korap:group, relation=not, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Sonne, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mond, relation==}}" +
+					"{@type=korap:group, @relation=not, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Sonne, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mond, @attr=orth, @relation==}}" +
 					"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -396,13 +396,13 @@
 		// 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, relation=shrink, shrink=first, operands=[" +
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, constraint=[" +
-						"{@type=korap:distance, measure=w, direction=both, min=3, max=5}" +
+				"{@type=korap:group, @relation=submatch, @spanRef=[0,1], @operands=[" +
+					"{@type=korap:sequence, @inOrder=false, @constraints=[" +
+						"{@type=korap:distance, @measure=w, @min=3, @max=5}" +
 					"]," +
-					"operands = [" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+					"@operands = [" +
+						"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new CosmasTree(query);
@@ -411,19 +411,19 @@
 		
 		query="#BEG(der /w3:5 Mann) /+w10 kommt"; // nesting #BEG() in a distance group
 		String beg2 = 
-				"{@type=korap:group, relation=distance, match=operands, @subtype=incl, constraint=[" +
-					"{@type=korap:distance, measure=w, direction=plus, min=0, max=10}" +
-				"], operands=[" +
-					"{@type=korap:group, relation=shrink, shrink=first, operands=[" +
-						"{@type=korap:group, relation=distance, match=operands, @subtype=incl, constraint=[" +
-							"{@type=korap:distance, measure=w, direction=both, min=3, max=5}" +
+				"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+					"{@type=korap:distance, @measure=w, @min=0, @max=10}" +
+				"], @operands=[" +
+					"{@type=korap:group, @relation=submatch, @spanRef=[0,1], @operands=[" +
+						"{@type=korap:sequence, @inOrder=false, @constraints=[" +
+							"{@type=korap:distance, @measure=w, @min=3, @max=5}" +
 						"]," +
-						"operands = [" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+						"@operands = [" +
+							"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:kommt, relation==}}" +
+					"{@type=korap:token, @value={@type=korap:term, @value=kommt, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -431,13 +431,13 @@
 		
 		query="#END(der /w3:5 Mann)";
 		String end1 = 
-				"{@type=korap:group, relation=shrink, shrink=last, operands=[" +
-					"{@type=korap:group, relation=distance, match=operands, @subtype=incl, constraint=[" +
-						"{@type=korap:distance, measure=w, direction=both, min=3, max=5}" +
-					"]," +
-					"operands = [" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+				"{@type=korap:group, @relation=submatch, @spanRef=[-1,1], @operands=[" +
+					"{@type=korap:sequence, @inOrder=false, @constraints=[" +
+						"{@type=korap:distance, @measure=w, @min=3, @max=5}" +
+					"], " +
+					"@operands = [" +
+						"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new CosmasTree(query);
@@ -450,7 +450,7 @@
 	public void testELEM() throws QueryException {
 		// http://www.ids-mannheim.de/cosmas2/web-app/hilfe/suchanfrage/eingabe-zeile/syntax/elem.html
 		query="#ELEM(S)";
-		String elem1 = "{@type=korap:element, @value=s}";
+		String elem1 = "{@type=korap:span, @value=s}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(elem1.replaceAll(" ", ""), map.replaceAll(" ", ""));
@@ -460,13 +460,13 @@
 	public void testOPALL() throws QueryException {
 		query="#ALL(gehen /w1:10 voran)";
 		String all1 =
-				"{@type=korap:group, relation=distance, match=all, @subtype=incl, " +
-					"constraint=[" +
-						"{@type=korap:distance, measure=w, direction=both, min=1, max=10}" +
+				"{@type=korap:sequence, @inOrder=false, " +
+					"@constraints=[" +
+						"{@type=korap:distance, @measure=w, @min=1, @max=10}" +
 					"], " +
-					"operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:gehen, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:voran, relation==}}" +
+					"@operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=gehen, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=voran, @attr=orth, @relation==}}" +
 					"]" +
 				"}";
 		ppt = new CosmasTree(query);
@@ -478,13 +478,13 @@
 	public void testOPNHIT() throws QueryException {
 		query="#NHIT(gehen /w1:10 voran)";
 		String nhit1 = 
-				"{@type=korap:group, relation=distance, match=between, @subtype=incl, " +
-					"constraint=[" +
-						"{@type=korap:distance, measure=w, direction=both, min=1, max=10}" +
+				"{@type=korap:sequence, @inOrder=false, " +
+					"@constraints=[" +
+						"{@type=korap:distance, @measure=w, @min=1, @max=10}" +
 					"], " +
-					"operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:gehen, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:voran, relation==}}" +
+					"@operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=gehen, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=voran, @attr=orth, @relation==}}" +
 					"]" +
 				"}";
 		ppt = new CosmasTree(query);
@@ -496,9 +496,9 @@
 	public void testOPBED() throws QueryException {
 		query = "#BED(der , sa)";
 		String bed1 = 
-				"{@type=korap:group, relation=position, position=startswith, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}" +
+				"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new CosmasTree(query);
 		map = ppt.getRequestMap().get("query").toString();
@@ -506,11 +506,11 @@
 		
 		query = "#BED(der Mann , +pe)";
 		String bed2 = 
-				"{@type=korap:group, relation=position, position=endswith, operands=[" +
-					"{@type=korap:element, @value=p}," +
-					"{@type=korap:sequence, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+				"{@type=korap:group, @relation=position, @position=endswith, @operands=[" +
+					"{@type=korap:span, @value=p}," +
+					"{@type=korap:sequence, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new CosmasTree(query);
@@ -519,19 +519,19 @@
 		
 		query = "#BED(der Mann , sa,-pa)";
 		String bed3 = 
-				"{@type=korap:group, relation=and, operands=[" +
-					"{@type=korap:group, relation=position, position=startswith, operands=[" +
-						"{@type=korap:element, @value=s}," +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+				"{@type=korap:group, @relation=and, @operands=[" +
+					"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+						"{@type=korap:span, @value=s}," +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}," +
-					"{@type=korap:group, relation=position, position=startswith, @subtype=excl, operands=[" +
-						"{@type=korap:element, @value=p}," +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+					"{@type=korap:group, @relation=position, @position=startswith, @exclude=true, @operands=[" +
+						"{@type=korap:span, @value=p}," +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}" +
 				"]}";
diff --git a/src/test/java/PoliqarpPlusTreeTest.java b/src/test/java/PoliqarpPlusTreeTest.java
index 5561d16..6090867 100644
--- a/src/test/java/PoliqarpPlusTreeTest.java
+++ b/src/test/java/PoliqarpPlusTreeTest.java
@@ -25,7 +25,7 @@
 	
 	@Test
 	public void testContext() throws QueryException {
-		String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, operands={@id=korap:operands, @container=@list}, relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}";
+		String contextString = "{korap=http://korap.ids-mannheim.de/ns/query, @language=de, @operands={@id=korap:operands, @container=@list}, @relation={@id=korap:relation, @type=korap:relation#types}, class={@id=korap:class, @type=xsd:integer}, query=korap:query, filter=korap:filter, meta=korap:meta}";
 		ppt = new PoliqarpPlusTree("[base=test]");
 		assertTrue(equalsContent(contextString, ppt.getRequestMap().get("@context")));
 	}
@@ -33,30 +33,30 @@
 	@Test
 	public void testSingleTokens() throws QueryException {
 		// [base=Mann]
-		String token1 = "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}";
+		String token1 = "{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}";
 		assertTrue(equalsQueryContent(token1, "[base=Mann]"));
 		
 		// [orth!=Frau]
-		String token2 = "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation=!=}}";
+		String token2 = "{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation=!=}}";
 		assertTrue(equalsQueryContent(token2, "[orth!=Frau]"));
 		
 		// [!p=NN]
-		String token3 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation=!=}}";
+		String token3 = "{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation=!=}}";
 		assertTrue(equalsQueryContent(token3, "[!p=NN]"));
 		
 		// [!p!=NN]
-		String token4 = "{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}";
+		String token4 = "{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation==}}";
 		assertTrue(equalsQueryContent(token4, "[!p!=NN]"));
 	}
 	
 	@Test
 	public void testElements() throws QueryException {
 		// <s>
-		String elem1 = "{@type=korap:element, @value=s}";
+		String elem1 = "{@type=korap:span, @value=s}";
 		assertTrue(equalsQueryContent(elem1, "<s>"));
 		
 		// <vp>
-		String elem2 = "{@type=korap:element, @value=vp}";
+		String elem2 = "{@type=korap:span, @value=vp}";
 		assertTrue(equalsQueryContent(elem2, "<vp>"));
 	}
 	
@@ -64,12 +64,12 @@
 	public void testEmptyTokens() throws QueryException {
 		// [base=der][][base=Mann]
 		String et1 = 
-			"{@type=korap:group, relation=distance, @subtype=incl, constraint=[" +
-				"{@type=korap:distance, measure=w, direction=plus, min=1, max=1}" +
+			"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+				"{@type=korap:distance, measure=w, min=1, max=1}" +
 			"], " +
-			"operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+			"@operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 			"]}";
 		ppt = new PoliqarpPlusTree("[base=der][][base=Mann]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -77,12 +77,12 @@
 		
 		// [base=der][][][base=Mann]
 		String et2 = 
-			"{@type=korap:group, relation=distance, @subtype=incl, constraint=[" +
-				"{@type=korap:distance, measure=w, direction=plus, min=2, max=2}" +
+			"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+				"{@type=korap:distance, measure=w, min=2, max=2}" +
 			"], " +
-			"operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+			"@operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 			"]}";
 		ppt = new PoliqarpPlusTree("[base=der][][][base=Mann]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -90,12 +90,12 @@
 		
 		// [base=der][][]?[base=Mann]
 		String et3 = 
-			"{@type=korap:group, relation=distance, @subtype=incl, constraint=[" +
-				"{@type=korap:distance, measure=w, direction=plus, min=1, max=2}" +
+			"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+				"{@type=korap:distance, measure=w, min=1, max=2}" +
 			"], " +
-			"operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+			"@operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 			"]}";
 		ppt = new PoliqarpPlusTree("[base=der][][]?[base=Mann]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -104,31 +104,32 @@
 		
 		// startswith(<s>, [][base=Mann]
 		String et4 = 
-			"{@type=korap:group, relation=position, position=startswith, operands=[" +
-				"{@type=korap:element, @value=s}," +
-				"{@type=korap:sequence, offset-min=1, offset-max=1, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+			"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +	
+				"{@type=korap:span, @value=s}," +
+				"{@type=korap:sequence, offset-min=1, offset-max=1, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 				"]}" +
 			"]}";
 		ppt = new PoliqarpPlusTree("startswith(<s>, [][base=Mann])");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(et4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
+		// [base=der][]{2,5}[base=Mann][]?[][base=Frau]   nested distances
 		String et5 = 
-				"{@type=korap:group, relation=distance, @subtype=incl, constraint=[" +
-					"{@type=korap:distance, measure=w, direction=plus, min=1, max=1}" +
+				"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+					"{@type=korap:distance, measure=w, min=2, max=5}" +
 				"], " +
-				"operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-					"{@type=korap:group, relation=distance, @subtype=incl, constraint=[" +
-						"{@type=korap:distance, measure=w, direction=plus, min=2, max=2}" +
+				"@operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+					"{@type=korap:sequence, @inOrder=true, @constraints=[" +
+						"{@type=korap:distance, measure=w, min=1, max=2}" +
 					"], " +
-					"operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:Frau, relation==}}" +
+					"@operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=base, @relation==}}" +
 					"]}" +
 				"]}";
-		ppt = new PoliqarpPlusTree("[base=der][][base=Mann][][][base=Frau]");
+		ppt = new PoliqarpPlusTree("[base=der][]{2,5}[base=Mann][]?[][base=Frau]");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(et5.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
@@ -139,13 +140,13 @@
 		// [base=Mann&(cas=N|cas=A)]
 		String cof1 = 
 			"{@type=korap:token, @value=" +
-				"{@type=korap:group, operands=[" +
-					"{@type=korap:term, @value=base:Mann, relation==}," +
-					"{@type=korap:group, operands=[" +
-						"{@type=korap:term, @value=cas:N, relation==}," +
-						"{@type=korap:term, @value=cas:A, relation==}" +
-					"], relation=or}" +
-				"], relation=and}" +
+				"{@type=korap:group, @operands=[" +
+					"{@type=korap:term, @value=Mann, @attr=base, @relation==}," +
+					"{@type=korap:group, @operands=[" +
+						"{@type=korap:term, @value=N, @attr=cas, @relation==}," +
+						"{@type=korap:term, @value=A, @attr=cas, @relation==}" +
+					"], @relation=or}" +
+				"], @relation=and}" +
 			"}";
 		ppt = new PoliqarpPlusTree("[base=Mann&(cas=N|cas=A)]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -156,25 +157,38 @@
 		    new PoliqarpPlusTree(" [ base=Mann & ( cas=N | cas=A)] ").getRequestMap().get("query").toString(),
 		    new PoliqarpPlusTree("[base=Mann &(cas=N|cas=A)]").getRequestMap().get("query").toString()
 	        );
+		
+		// [base=Mann&cas=N&gen=m]
+		String cof2 = 
+			"{@type=korap:token, @value=" +
+				"{@type=korap:group, @operands=[" +
+					"{@type=korap:term, @value=Mann, @attr=base, @relation==}," +
+					"{@type=korap:term, @value=N, @attr=cas, @relation==}," +
+					"{@type=korap:term, @value=m, @attr=gen, @relation==}" +
+				"], @relation=and}" +
+			"}";
+		ppt = new PoliqarpPlusTree("[base=Mann&cas=N&gen=m]");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(cof2.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	@Test
 	public void testOccurrence() throws QueryException {
 		// [base=foo]*
-		String occ1 = "{@type=korap:group, operands=[" +
-					     "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
-					  "], relation=repetition, quantifier=* }"; 
+		String occ1 = "{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					  "], @relation=repetition, @min=0, @max=100}"; 
 		ppt = new PoliqarpPlusTree("[base=foo]*");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(occ1.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// [base=foo]*[base=bar]
 		String occ2 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:group, operands=[" +
-					     "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
-					"], relation=repetition, quantifier=* }," +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					"], @relation=repetition, @min=0, @max=100 }," +
+					"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}" +
 				"]}"; 
 		ppt = new PoliqarpPlusTree("[base=foo]*[base=bar]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -182,11 +196,11 @@
 		
 		// [base=bar][base=foo]*
 		String occ3 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-					"{@type=korap:group, operands=[" +
-					     "{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
-					"], relation=repetition, quantifier=* }" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+					"{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					"], @relation=repetition, @min=0, @max=100 }" +
 				"]}"; 
 		ppt = new PoliqarpPlusTree("[base=bar][base=foo]*");
 		map = ppt.getRequestMap().get("query").toString();
@@ -194,26 +208,26 @@
 		
 		// ([base=bar][base=foo])*
 		String occ4 = 
-				"{@type=korap:group, operands=[" +	
-					"{@type=korap:sequence, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
+				"{@type=korap:group, @operands=[" +	
+					"{@type=korap:sequence, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
 					"]}" +
-				"], relation=repetition, quantifier=* }" ;
+				"], @relation=repetition, @min=0, @max=100 }" ;
 		ppt = new PoliqarpPlusTree("([base=bar][base=foo])*");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(occ4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// <s>([base=bar][base=foo])*
 		String occ5 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:group, operands=[" +	
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:group, @operands=[" +	
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
 						"]}" +
-					"], relation=repetition, quantifier=* }" +
+					"], @relation=repetition, @min=0, @max=100 }" +
 				"]}" ;
 		ppt = new PoliqarpPlusTree("<s>([base=bar][base=foo])*");
 		map = ppt.getRequestMap().get("query").toString();
@@ -221,15 +235,15 @@
 		
 		// <s><np>([base=bar][base=foo])*
 		String occ6 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:element, @value=np}," +
-					"{@type=korap:group, operands=[" +	
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:span, @value=np}," +
+					"{@type=korap:group, @operands=[" +	
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
 						"]}" +
-					"], relation=repetition, quantifier=* }" +
+					"], @relation=repetition, @min=0, @max=100 }" +
 				"]}" ;
 		ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*");
 		map = ppt.getRequestMap().get("query").toString();
@@ -239,16 +253,16 @@
 		// comment: embedded sequence shouldn't really be here, but does not really hurt, either. (?)
 		// really hard to get this behaviour out of the PQPlus grammar...
 		String occ7 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:element, @value=np}," +
-					"{@type=korap:group, operands=[" +	
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:span, @value=np}," +
+					"{@type=korap:group, @operands=[" +	
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
 						"]}" +
-					"], relation=repetition, quantifier=* }," +
-					"{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
+					"], @relation=repetition, @min=0, @max=100 }," +
+					"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation==}}" +
 				"]}" ;
 		ppt = new PoliqarpPlusTree("<s><np>([base=bar][base=foo])*[p=NN]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -256,34 +270,58 @@
 		
 		// ([base=bar][base=foo])*[p=NN]
 		String occ8 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:group, operands=[" +	
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:bar, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:foo, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:group, @operands=[" +	
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=bar, @attr=base, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
 						"]}" +
-					"], relation=repetition, quantifier=* }," +
-					"{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
+					"], @relation=repetition, @min=0, @max=100 }," +
+					"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation==}}" +
 				"]}" ;
 		ppt = new PoliqarpPlusTree("([base=bar][base=foo])*[p=NN]");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(occ8.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		// [base=foo]+
+		String occ9 = "{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					  "], @relation=repetition, @min=1, @max=100}"; 
+		ppt = new PoliqarpPlusTree("[base=foo]+");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(occ9.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		// [base=foo]?
+		String occ10 = "{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					  "], @relation=repetition, @min=0, @max=1}"; 
+		ppt = new PoliqarpPlusTree("[base=foo]?");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(occ10.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		// [base=foo]{2,5}
+		String occ11 = "{@type=korap:group, @operands=[" +
+					     "{@type=korap:token, @value={@type=korap:term, @value=foo, @attr=base, @relation==}}" +
+					  "], @relation=repetition, @min=2, @max=5}"; 
+		ppt = new PoliqarpPlusTree("[base=foo]{2,5}");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(occ11.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	@Test
 	public void testTokenSequence() throws QueryException {
 		// [base=Mann][orth=Frau]
-		String seq1 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
-				"{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
+		String seq1 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}, " +
+				"{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation==}}" +
 				"]}";
 		assertTrue(equalsQueryContent(seq1, "[base=Mann][orth=Frau]"));
 		
 		// [base=Mann][orth=Frau][p=NN]
-		String seq2 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
-				"{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}, " +
-				"{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
+		String seq2 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}, " +
+				"{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation==}}, " +
+				"{@type=korap:token, @value={@type=korap:term, @value=NN,@attr=p, @relation==}}" +
 				"]}";
 		assertTrue(equalsQueryContent(seq2, "[base=Mann][orth=Frau][p=NN]"));
 	}
@@ -292,12 +330,12 @@
 	public void testDisjSegments() throws QueryException {
 		// ([base=der]|[base=das])[base=Schild]
 		String disj1 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=das, @attr=base, @relation==}}" +
 					"]}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Schild, @attr=base, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("([base=der]|[base=das])[base=Schild]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -305,11 +343,11 @@
 		
 		// [base=Schild]([base=der]|[base=das])
 		String disj2 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:Schild, relation==}}," +
-					"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:das, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Schild, @attr=base, @relation==}}," +
+					"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+						"{@type=korap:token, @value={@type=korap:term, @value=das, @attr=base, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("[base=Schild]([base=der]|[base=das])");
@@ -320,24 +358,24 @@
 	@Test
 	public void testTokenElemSequence() throws QueryException {
 		// [base=Mann]<vp>
-		String seq1 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
-				"{@type=korap:element, @value=vp}" +
+		String seq1 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}, " +
+				"{@type=korap:span, @value=vp}" +
 				"]}";
 		assertTrue(equalsQueryContent(seq1, "[base=Mann]<vp>"));
 		
 		// <vp>[base=Mann]
-		String seq2 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:element, @value=vp}, "+
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}} " +
+		String seq2 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:span, @value=vp}, "+
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}} " +
 				"]}";
 		assertTrue(equalsQueryContent(seq2, "<vp>[base=Mann]"));
 		
 		// <vp>[base=Mann]<pp>
-		String seq3 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:element, @value=vp}, "+
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}, " +
-				"{@type=korap:element, @value=pp} "+
+		String seq3 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:span, @value=vp}, "+
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}, " +
+				"{@type=korap:span, @value=pp} "+
 				"]}";
 		assertTrue(equalsQueryContent(seq3, "<vp>[base=Mann]<pp>"));
 	}
@@ -345,17 +383,17 @@
 	@Test
 	public void testElemSequence() throws QueryException {
 		// <np><vp>
-		String seq1 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:element, @value=np}," +
-				"{@type=korap:element, @value=vp}" +
+		String seq1 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:span, @value=np}," +
+				"{@type=korap:span, @value=vp}" +
 				"]}";
 		assertTrue(equalsQueryContent(seq1, "<np><vp>"));
 		
 		// <np><vp><pp>
-		String seq2 = "{@type=korap:sequence, operands=[" +
-				"{@type=korap:element, @value=np}," +
-				"{@type=korap:element, @value=vp}," +
-				"{@type=korap:element, @value=pp}" +
+		String seq2 = "{@type=korap:sequence, @operands=[" +
+				"{@type=korap:span, @value=np}," +
+				"{@type=korap:span, @value=vp}," +
+				"{@type=korap:span, @value=pp}" +
 				"]}";
 		assertTrue(equalsQueryContent(seq2, "<np><vp><pp>"));
 	}
@@ -363,51 +401,53 @@
 	@Test 
 	public void testClasses() throws QueryException {
 		// {[base=Mann]}
-		String cls1 = "{@type=korap:group, class=0, operands=[" +
-				"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+		String cls1 = "{@type=korap:group, class=0, @operands=[" +
+				"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 				"]}";
 		assertTrue(equalsQueryContent(cls1, "{[base=Mann]}"));
 		
 		// {[base=Mann][orth=Frau]}
-		String cls2 = "{@type=korap:group, class=0, operands=[" +
-				 "{@type=korap:sequence, operands=[" +
-				  "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
-				  "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
+		String cls2 = "{@type=korap:group, class=0, @operands=[" +
+				 "{@type=korap:sequence, @operands=[" +
+				  "{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}," +
+				  "{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation==}}" +
 				 "]}" +
 				"]}";
 		assertTrue(equalsQueryContent(cls2, "{[base=Mann][orth=Frau]}"));
 		
 		// [p=NN]{[base=Mann][orth=Frau]}
-		String cls3 = "{@type=korap:sequence, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}," +
-						"{@type=korap:group, class=0, operands=[" +
-							"{@type=korap:sequence, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
-								"{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
+		String cls3 = "{@type=korap:sequence, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation==}}," +
+						"{@type=korap:group, class=0, @operands=[" +
+							"{@type=korap:sequence, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}," +
+								"{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation==}}" +
 							"]}" +
 						"]}" +
 					  "]}";
 		assertTrue(equalsQueryContent(cls3, "[p=NN]{[base=Mann][orth=Frau]}"));
 		
 		// {[base=Mann][orth=Frau]}[p=NN]
-		String cls4 = "{@type=korap:sequence, operands=[" +
-						"{@type=korap:group, class=0, operands=[" +
-						   "{@type=korap:sequence, operands=[" +
-						     "{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}," +
-						     "{@type=korap:token, @value={@type=korap:term, @value=orth:Frau, relation==}}" +
+		String cls4 = "{@type=korap:sequence, @operands=[" +
+						"{@type=korap:group, class=0, @operands=[" +
+						   "{@type=korap:sequence, @operands=[" +
+						     "{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}," +
+						     "{@type=korap:token, @value={@type=korap:term, @value=Frau, @attr=orth, @relation==}}" +
 						   "]}" +
 						"]}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=p:NN, relation==}}" +
+						"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @relation==}}" +
 					  "]}";
-		assertTrue(equalsQueryContent(cls4, "{[base=Mann][orth=Frau]}[p=NN]"));
+		ppt = new PoliqarpPlusTree("{[base=Mann][orth=Frau]}[p=NN]");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(cls4.replaceAll(" ", ""), map.replaceAll(" ", ""));
 
 		// {2:{1:[tt/p=ADJA]}[mate/p=NN]}"
-		String cls5 = "{@type=korap:group, class=2, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-						   "{@type=korap:group, class=1, operands=[" +
-						     "{@type=korap:token, @value={@type=korap:term, @value=tt/p:ADJA, relation==}}" +
+		String cls5 = "{@type=korap:group, class=2, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+						   "{@type=korap:group, class=1, @operands=[" +
+						     "{@type=korap:token, @value={@type=korap:term, @value=ADJA, @attr=p, @foundry=tt, @relation==}}" +
 						   "]}," +
-						   "{@type=korap:token, @value={@type=korap:term, @value=mate/p:NN, relation==}}" + 
+						   "{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @foundry=mate, @relation==}}" + 
 						"]}" +
 					  "]}";
 		ppt = new PoliqarpPlusTree("{2: {1:[tt/p=ADJA]}[mate/p=NN]}");
@@ -418,25 +458,25 @@
 	@Test
 	public void testPositions() throws QueryException {
 		// contains(<s>,<np>)
-		String pos1 = "{@type=korap:group, relation=position, position=contains, operands=[" +
-				  "{@type=korap:element, @value=s}," +
-				  "{@type=korap:element, @value=np}" +
+		String pos1 = "{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+				  "{@type=korap:span, @value=s}," +
+				  "{@type=korap:span, @value=np}" +
 				"]}";
 		assertTrue(equalsQueryContent(pos1, "contains(<s>,<np>)"));
 		
 		// contains(<s>,[base=Mann])
-		String pos2 = "{@type=korap:group, relation=position, position=contains, operands=[" +
-				  "{@type=korap:element, @value=s}," +
-				  "{@type=korap:token, @value= {@type=korap:term, @value=base:Mann, relation==}}" +
+		String pos2 = "{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+				  "{@type=korap:span, @value=s}," +
+				  "{@type=korap:token, @value= {@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 				"]}";
 		assertTrue(equalsQueryContent(pos2, "contains(<s>,[base=Mann])"));
 		
 		// contains(<s>,[orth=der][orth=Mann])
-		String pos3 = "{@type=korap:group, relation=position, position=contains, operands=[" +
-				  	"{@type=korap:element, @value=s}," +
-				  	"{@type=korap:sequence, operands=[" +
-				  		"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-				  		"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+		String pos3 = "{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+				  	"{@type=korap:span, @value=s}," +
+				  	"{@type=korap:sequence, @operands=[" +
+				  		"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+				  		"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 				  	"]}" +
 				  "]}";
 		ppt = new PoliqarpPlusTree("contains(<s>,[orth=der][orth=Mann])");
@@ -445,11 +485,11 @@
 		
 		// [base=Auto]contains(<s>,[base=Mann])
 		String pos4 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=base:Auto, relation==}}," +
-					"{@type=korap:group, relation=position, position=contains, operands=[" +
-				  		"{@type=korap:element, @value=s}," +
-				  		"{@type=korap:token, @value={@type=korap:term, @value=base:Mann, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Auto, @attr=base, @relation==}}," +
+					"{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+				  		"{@type=korap:span, @value=s}," +
+				  		"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @relation==}}" +
 				  	"]}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("[base=Auto]contains(<s>,[base=Mann])");
@@ -461,11 +501,11 @@
 	public void testNestedPositions() throws QueryException {
 		// contains(<s>,startswith(<np>,[orth=Der]))
 		String npos1 = 
-			"{@type=korap:group, relation=position, position=contains, operands=[" +
-				"{@type=korap:element, @value=s}," +
-				"{@type=korap:group, relation=position, position=startswith, operands=[" +
-					"{@type=korap:element, @value=np}," +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}" +
+			"{@type=korap:group, @relation=position, @position=contains, @operands=[" +
+				"{@type=korap:span, @value=s}," +
+				"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+					"{@type=korap:span, @value=np}," +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}" +
 				"]}" +
 			"]}";
 		ppt = new PoliqarpPlusTree("contains(<s>, startswith(<np>,[orth=Der]))");
@@ -477,11 +517,11 @@
 	public void testShrinkSplit() throws QueryException {
 		// shrink([orth=Der]{[orth=Mann]})
 		String shr1 = 
-			"{@type=korap:group, relation=shrink, shrink=0, operands=[" +
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
-					"{@type=korap:group, class=0, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+			"{@type=korap:group, @relation=shrink, classRef=0, @operands=[" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}," +
+					"{@type=korap:group, class=0, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}" +
 			"]}";
@@ -491,13 +531,13 @@
 		
 		// shrink([orth=Der]{[orth=Mann][orth=geht]})
 		String shr2 = 
-			"{@type=korap:group, relation=shrink, shrink=0, operands=[" +
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
-					"{@type=korap:group, class=0, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" +
+			"{@type=korap:group, @relation=shrink, classRef=0, @operands=[" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}," +
+					"{@type=korap:group, class=0, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=geht, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}" +
 				"]}" +
@@ -508,13 +548,13 @@
 		
 		// shrink(1:[orth=Der]{1:[orth=Mann][orth=geht]})
 		String shr3 = 
-			"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}," +
-					"{@type=korap:group, class=1, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=orth:geht, relation==}}" +
+			"{@type=korap:group, @relation=shrink, classRef=1, @operands=[" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}," +
+					"{@type=korap:group, class=1, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}," +
+							"{@type=korap:token, @value={@type=korap:term, @value=geht, @attr=orth, @relation==}}" +
 						"]}" +
 					"]}" +
 				"]}" +
@@ -525,11 +565,11 @@
 		
 		// shrink(1:startswith(<s>,{1:<np>}))
 		String shr4 = 
-			"{@type=korap:group, relation=shrink, shrink=1, operands=[" +
-				"{@type=korap:group, relation=position, position=startswith, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:group, class=1, operands=[" +
-						"{@type=korap:element, @value=np}" +
+			"{@type=korap:group, @relation=shrink, classRef=1, @operands=[" +
+				"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:group, class=1, @operands=[" +
+						"{@type=korap:span, @value=np}" +
 					"]}" +
 				"]}" +
 			"]}";
@@ -539,17 +579,17 @@
 		
 		// shrink(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) 
 		String shr5 = 
-			"{@type=korap:group, relation=shrink, shrink=3, operands=[" +
-				"{@type=korap:group, relation=position, position=startswith, operands=[" +
-					"{@type=korap:element, @value=s}," +
-					"{@type=korap:group, class=3, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:der, relation==}}," +
-							"{@type=korap:group, class=1, operands=[" +
-								"{@type=korap:sequence, operands=[" +
-									"{@type=korap:token, @value={@type=korap:term, @value=mate/p:ADJA, relation==}}," +
-									"{@type=korap:group, class=2, operands=[" +
-										"{@type=korap:token, @value={@type=korap:term, @value=tt/p:NN, relation==}}" +
+			"{@type=korap:group, @relation=shrink, classRef=3, @operands=[" +
+				"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:group, class=3, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:sequence, @operands=[" +
+									"{@type=korap:token, @value={@type=korap:term, @value=ADJA, @attr=p, @foundry=mate, @relation==}}," +
+									"{@type=korap:group, class=2, @operands=[" +
+										"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @foundry=tt, @relation==}}" +
 									"]}" + 
 								"]}" +
 							"]}" +
@@ -560,14 +600,40 @@
 		ppt = new PoliqarpPlusTree("shrink(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(shr5.replaceAll(" ", ""), map.replaceAll(" ", ""));
+		
+		// split(3: startswith(<s>, {3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) 
+		String shr6 = 
+			"{@type=korap:group, @relation=split, classRef=3, @operands=[" +
+				"{@type=korap:group, @relation=position, @position=startswith, @operands=[" +
+					"{@type=korap:span, @value=s}," +
+					"{@type=korap:group, class=3, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=base, @relation==}}," +
+							"{@type=korap:group, class=1, @operands=[" +
+								"{@type=korap:sequence, @operands=[" +
+									"{@type=korap:token, @value={@type=korap:term, @value=ADJA, @attr=p, @foundry=mate, @relation==}}," +
+									"{@type=korap:group, class=2, @operands=[" +
+										"{@type=korap:token, @value={@type=korap:term, @value=NN, @attr=p, @foundry=tt, @relation==}}" +
+									"]}" + 
+								"]}" +
+							"]}" +
+						"]}" +
+					"]}" +
+				"]}" +
+			"]}";
+		ppt = new PoliqarpPlusTree("split(3:startswith(<s>,{3:[base=der]{1:[mate/p=ADJA]{2:[tt/p=NN]}}})) ");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(shr6.replaceAll(" ", ""), map.replaceAll(" ", ""));
 	}
 	
 	
 	@Test
-	public void testLayers() throws QueryException {
-		// [base=Mann]
-		String layer1 = "{@type=korap:token, @value={@type=korap:term, @value=tt/base:Mann, relation==}}";
-		assertTrue(equalsQueryContent(layer1, "[tt/base=Mann]"));
+	public void testFoundries() throws QueryException {
+		// [tt/base=Mann]
+		String layer1 = "{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=base, @foundry=tt, @relation==}}";
+		ppt = new PoliqarpPlusTree("[tt/base=Mann]");
+		map = ppt.getRequestMap().get("query").toString();
+		assertEquals(layer1.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 	}
 	
@@ -575,10 +641,10 @@
 	public void testAlign() {
 		// [orth=der]^[orth=Mann]
 		String align1 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:der, relation==}}," +
-					"{@type=korap:group, relation=left-align, operands=[" +
-						"{@type=korap:token, @value={@type=korap:term, @value=orth:Mann, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=der, @attr=orth, @relation==}}," +
+					"{@type=korap:group, @relation=left-align, @operands=[" +
+						"{@type=korap:token, @value={@type=korap:term, @value=Mann, @attr=orth, @relation==}}" +
 					"]}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("[orth=der]^[orth=Mann]");
@@ -587,14 +653,14 @@
 		
 		// "([base=a]^[base=b])|[base=c]",
 		String align2 = 
-				"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," +
-							"{@type=korap:group, relation=left-align, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" +
+				"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=a, @attr=base, @relation==}}," +
+							"{@type=korap:group, @relation=left-align, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=b, @attr=base, @relation==}}" +
 							"]}" +
 						"]}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" +
+						"{@type=korap:token, @value={@type=korap:term, @value=c, @attr=base, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("([base=a]^[base=b])|[base=c]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -602,15 +668,15 @@
 		
 		// "([base=a]^[base=b][base=c])|[base=d]",
 		String align3 = 
-				"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," +
-							"{@type=korap:group, relation=left-align, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" +
+				"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=a, @attr=base, @relation==}}," +
+							"{@type=korap:group, @relation=left-align, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=b, @attr=base, @relation==}}" +
 							"]}," +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" +
+							"{@type=korap:token, @value={@type=korap:term, @value=c, @attr=base, @relation==}}" +
 						"]}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:d, relation==}}" +
+						"{@type=korap:token, @value={@type=korap:term, @value=d, @attr=base, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("([base=a]^[base=b][base=c])|[base=d]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -618,17 +684,17 @@
 		
 		// "([base=a]^[base=b]^[base=c])|[base=d]",
 		String align4 = 
-				"{@type=korap:group, relation=or, operands=[" +
-						"{@type=korap:sequence, operands=[" +
-							"{@type=korap:token, @value={@type=korap:term, @value=base:a, relation==}}," +
-							"{@type=korap:group, relation=left-align, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=base:b, relation==}}" +
+				"{@type=korap:group, @relation=or, @operands=[" +
+						"{@type=korap:sequence, @operands=[" +
+							"{@type=korap:token, @value={@type=korap:term, @value=a, @attr=base, @relation==}}," +
+							"{@type=korap:group, @relation=left-align, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=b, @attr=base, @relation==}}" +
 							"]}," +
-							"{@type=korap:group, relation=left-align, operands=[" +
-								"{@type=korap:token, @value={@type=korap:term, @value=base:c, relation==}}" +
+							"{@type=korap:group, @relation=left-align, @operands=[" +
+								"{@type=korap:token, @value={@type=korap:term, @value=c, @attr=base, @relation==}}" +
 							"]}" +
 						"]}," +
-						"{@type=korap:token, @value={@type=korap:term, @value=base:d, relation==}}" +
+						"{@type=korap:token, @value={@type=korap:term, @value=d, @attr=base, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("([base=a]^[base=b]^[base=c])|[base=d]");
 		map = ppt.getRequestMap().get("query").toString();
@@ -641,16 +707,16 @@
 	public void testSimpleQueries() {
 		// Baum
 		String simple1 = 
-				"{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}";
+				"{@type=korap:token, @value={@type=korap:term, @value=Baum, @attr=orth, @relation==}}";
 		ppt = new PoliqarpPlusTree("Baum");
 		map = ppt.getRequestMap().get("query").toString();
 		assertEquals(simple1.replaceAll(" ", ""), map.replaceAll(" ", ""));
 		
 		// Der Baum
 		String simple2 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}, " +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}, " +
+					"{@type=korap:token, @value={@type=korap:term, @value=Baum, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("Der Baum");
 		map = ppt.getRequestMap().get("query").toString();
@@ -658,10 +724,10 @@
 		
 		// Der große Baum
 		String simple3 = 
-				"{@type=korap:sequence, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Der, relation==}}, " +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:große, relation==}}, " +						
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}" +
+				"{@type=korap:sequence, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Der, @attr=orth, @relation==}}, " +
+					"{@type=korap:token, @value={@type=korap:term, @value=große, @attr=orth, @relation==}}, " +						
+					"{@type=korap:token, @value={@type=korap:term, @value=Baum, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("Der große Baum");
 		map = ppt.getRequestMap().get("query").toString();
@@ -669,9 +735,9 @@
 		
 		// Baum | Stein
 		String simple4 = 
-				"{@type=korap:group, relation=or, operands=[" +
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Baum, relation==}}, " +						
-					"{@type=korap:token, @value={@type=korap:term, @value=orth:Stein, relation==}}" +
+				"{@type=korap:group, @relation=or, @operands=[" +
+					"{@type=korap:token, @value={@type=korap:term, @value=Baum, @attr=orth, @relation==}}, " +						
+					"{@type=korap:token, @value={@type=korap:term, @value=Stein, @attr=orth, @relation==}}" +
 				"]}";
 		ppt = new PoliqarpPlusTree("Baum | Stein");
 		map = ppt.getRequestMap().get("query").toString();