PQ alignment
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 6f471e4..2eaff8b 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
@@ -440,8 +440,8 @@
 			submatchgroup.put("@operands", submatchoperands);
 			submatchoperands.add(posgroup);
 			posgroup.put("@type", "korap:group");
-			String relation = nodeCat.equals("OPIN") ? "position" : "overlaps";
-			posgroup.put("@relation", relation);
+//			String relation = nodeCat.equals("OPIN") ? "position" : "overlaps";
+			posgroup.put("@relation", "position");
 			
 			if (nodeCat.equals("OPIN")) {
 				parseOPINOptions(node, posgroup);
@@ -616,7 +616,7 @@
 		String position = "";
 		if (posnode != null) {
 			String value = posnode.getChild(0).toStringTree();
-			position = translateTextAreaArgument(value);
+			position = translateTextAreaArgument(value, "in");
 			if (value.equals("N")) {
 				negatePosition = !negatePosition;
 			}
@@ -656,12 +656,9 @@
 		String position = "";
 		if (posnode != null) {
 			String value = posnode.getChild(0).toStringTree();
-			position = translateTextAreaArgument(value);
-		} else {
-			position = "any";
+			position = "-"+translateTextAreaArgument(value, "ov");
 		}
-		posgroup.put("@position", position);
-		position = openNodeCats.get(1).equals("OPIN") ? "contains" : "full";
+		posgroup.put("@position", "overlaps"+position);
 		
 		if (exclnode != null) {
 			if (exclnode.getChild(0).toStringTree().equals("YES")) {
@@ -681,22 +678,23 @@
 	 * http://www.ids-mannheim.de/cosmas2/win-app/hilfe/suchanfrage/eingabe-grafisch/syntax/ARGUMENT_I.html or
 	 * http://www.ids-mannheim.de/cosmas2/win-app/hilfe/suchanfrage/eingabe-grafisch/syntax/ARGUMENT_O.html, respectively.
 	 * @param argument
+	 * @param mode 
 	 * @return
 	 */
-	private String translateTextAreaArgument(String argument) {
+	private String translateTextAreaArgument(String argument, String mode) {
 		String position = "";
 		switch (argument) {
 		case "L":
-			position = "startswith";
+			position = mode.equals("in") ? "startswith" : "left";
 			break;
 		case "R":
-			position = "endswith";
+			position = mode.equals("in") ? "endswith" : "right";
 			break;
 		case "F":
 			position = "leftrightmatch";
 			break;
 		case "FE":
-			position = "ident";
+			position = "matches";
 			break;
 		case "FI":
 			position = "leftrightmatch-noident";
@@ -767,7 +765,8 @@
 				"wegen #IN(%, L) <s>",
 				"wegen #IN(%) <s>",
 				"(Mann oder Frau) #IN <s>",
-				"#BEG(der /w3:5 Mann) /+w10 kommt"
+				"#BEG(der /w3:5 Mann) /+w10 kommt",
+				"&würde /w0 MORPH(V)"
 				};
 		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 530f597..6679466 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
@@ -260,7 +260,8 @@
 			ignoreCq_segment = (node.getChildCount() == 1 && (node.getChild(0).toStringTree(poliqarpParser).equals(" ") || QueryUtils.getNodeCat(node.getChild(0)).equals("spanclass") || QueryUtils.getNodeCat(node.getChild(0)).equals("position")));
 			// ignore this node if it only serves as an aligned sequence container
 			if (node.getChildCount()>1) {
-				if (QueryUtils.getNodeCat(node.getChild(1)).equals("cq_segments") && QueryUtils.hasChild(node.getChild(1), "align")) {
+				if (QueryUtils.getNodeCat(node.getChild(1)).equals("cq_segments") && QueryUtils.hasChild(node.getChild(1), "alignment")) {
+//				if (QueryUtils.getNodeCat(node.getChild(0)).equals("align")) {	
 					ignoreCq_segment = true;
 				}
 			}
@@ -594,7 +595,7 @@
 			} 
 		}
 		
-		if (nodeCat.equals("align")) {
+		if (nodeCat.equals("alignment")) {
 			alignNext = true;
 			LinkedHashMap<String,Object> alignGroup = new LinkedHashMap<String,Object>();
 			// push but don't increase the stackedObjects counter in order to keep this
@@ -602,16 +603,17 @@
 			// operands are siblings of this align node rather than children, i.e. the group
 			// would be removed from the stack before seeing its operands.
 			objectStack.push(alignGroup);
+			stackedObjects++;
 			// Step I: get info
 			// fill group
 			alignGroup.put("@type", "korap:group");
-			alignGroup.put("@relation", "left-align");
+			alignGroup.put("@alignment", "left");
 			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");
-				topSequenceOperands.add(alignGroup); 
+				topSequenceOperands.add(alignGroup);
 			} else if (openNodeCats.get(2).equals("query")) {
 				requestMap.put("query", alignGroup);	
 			} else {
@@ -801,10 +803,10 @@
 		}
 		
 		// pop the align group that was introduced by previous 'align' but never closed
-		if (isAligned) {
-			isAligned=false;
-			objectStack.pop();
-		}
+//		if (isAligned) {
+//			isAligned=false;
+//			objectStack.pop();
+//		}
 		
 		// Stuff that happens when leaving a node (taking items off the stacks)
 		for (int i=0; i<objectsToPop.get(0); i++) {
@@ -935,13 +937,25 @@
 		/*
 		 * For testing
 		 */
+		
+		PoliqarpPlusTree pt1 = new PoliqarpPlusTree("[base=Hund] | [base=Katze][base=Maus]");
+		PoliqarpPlusTree pt2 = new PoliqarpPlusTree("[base=Hund] | [base=Katze] [base=Maus]");
+		System.err.println(pt1.getRequestMap().equals(pt2.getRequestMap()));
+		
 		String[] queries = new String[] {
-				"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]"
+//				"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]",
+//				"[base=Hund] | [base=Katze][base=Maus]",
+//				"Baum | Haus",
+//				"Baum | Stein Haus",
+//				"^contains(<s>,<np>)",
+//				"([base=a]^[base=b][base=c])|[base=d]",
+				"[orth=der]^[orth=große][orth=Mann]",
+				"([base=a]^[base=b]^[base=c])|[base=d]"
 		};
 		PoliqarpPlusTree.debug=true;
 		for (String q : queries) {