diff --git a/.settings/.gitignore b/.settings/.gitignore
index 0450880..371a92d 100644
--- a/.settings/.gitignore
+++ b/.settings/.gitignore
@@ -1,2 +1,3 @@
 /org.eclipse.m2e.core.prefs
 /org.eclipse.wst.common.project.facet.core.xml
+/org.eclipse.jdt.ui.prefs
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
new file mode 100644
index 0000000..1ca4edd
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/FCSSRUQueryParser.java
@@ -0,0 +1,217 @@
+package de.ids_mannheim.korap.query.parse.fcsql;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import de.ids_mannheim.korap.query.parse.fcsql.KoralSequence.Distance;
+import de.ids_mannheim.korap.query.serialize.FCSQLQueryProcessor;
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+import eu.clarin.sru.server.fcs.parser.Expression;
+import eu.clarin.sru.server.fcs.parser.ExpressionAnd;
+import eu.clarin.sru.server.fcs.parser.Operator;
+import eu.clarin.sru.server.fcs.parser.QueryNode;
+import eu.clarin.sru.server.fcs.parser.QuerySegment;
+import eu.clarin.sru.server.fcs.parser.RegexFlag;
+
+public class FCSSRUQueryParser {
+
+    private static final String FOUNDRY_CNX = "cnx";
+    private static final String FOUNDRY_OPENNLP = "opennlp";
+    private static final String FOUNDRY_TT = "tt";
+    private static final String FOUNDRY_MATE = "mate";
+    private static final String FOUNDRY_XIP = "xip";
+
+    private List<String> supportedFoundries = Arrays
+            .asList(new String[] { FOUNDRY_CNX, FOUNDRY_OPENNLP, FOUNDRY_TT,
+                    FOUNDRY_MATE, FOUNDRY_XIP });
+
+    private FCSQLQueryProcessor processor;
+
+    public FCSSRUQueryParser (FCSQLQueryProcessor processor) {
+        this.processor = processor;
+    }
+
+    public Object parseQueryNode(QueryNode queryNode) {
+
+        if (queryNode instanceof QuerySegment) {
+            return parseQuerySegment((QuerySegment) queryNode);
+            // } else if (queryNode instanceof QueryGroup) {
+            //
+            // } else if (queryNode instanceof QuerySequence) {
+            //
+            // } else if (queryNode instanceof QueryDisjunction) {
+            //
+            // } else if (queryNode instanceof QueryWithWithin) {
+
+        }
+        else {
+            processor.addError(StatusCodes.QUERY_TOO_COMPLEX,
+                    "FCS diagnostic 11:" + queryNode.getNodeType().name()
+                            + " is currently unsupported.");
+            return null;
+        }
+    }
+
+    private Object parseQuerySegment(QuerySegment segment) {
+        if ((segment.getMinOccurs() == 1) && (segment.getMaxOccurs() == 1)) {
+            return parseExpression(segment.getExpression());
+        }
+        else {
+            processor.addError(StatusCodes.QUERY_TOO_COMPLEX,
+                    "FCS diagnostic 11: Query is too complex.");
+            return null;
+        }
+    }
+
+    private Object parseExpression(QueryNode queryNode) {
+        if (queryNode instanceof Expression) {
+            Expression expression = (Expression) queryNode;
+            return parseSimpleExpression(expression);
+        }
+        else if (queryNode instanceof ExpressionAnd) {
+            ExpressionAnd expressionAnd = (ExpressionAnd) queryNode;
+            return parseExpressionAnd(expressionAnd);
+        }
+        // else if (queryNode instanceof ExpressionGroup) {
+        //
+        // }
+        // else if (queryNode instanceof ExpressionNot) {
+        //
+        // }
+        // else if (queryNode instanceof ExpressionOr) {
+        //
+        // }
+        // else if (queryNode instanceof ExpressionWildcard) {
+        //
+        // }
+        else {
+            processor.addError(StatusCodes.QUERY_TOO_COMPLEX,
+                    "FCS diagnostic 11: Query is too complex.");
+            return null;
+        }
+    }
+
+    private Object parseExpressionAnd(ExpressionAnd expressionAnd) {
+        KoralSequence koralSequence = new KoralSequence();
+        List<Object> operands = new ArrayList<Object>();
+        for (QueryNode child : expressionAnd.getChildren()) {
+            operands.add(parseExpression(child));
+        }
+
+        List<Distance> distances = new ArrayList<Distance>();
+        Distance d = koralSequence.new Distance("s", 0, 0);
+        distances.add(d);
+
+        koralSequence.setOperands(operands);
+        koralSequence.setDistances(distances);
+        return koralSequence;
+    }
+
+    private Object parseSimpleExpression(Expression expression) {
+        KoralTerm koralTerm = new KoralTerm();
+        koralTerm.setQueryTerm(expression.getRegexValue());
+        parseLayerIdentifier(koralTerm, expression.getLayerIdentifier());
+        parseQualifier(koralTerm, expression.getLayerQualifier());
+        parseOperator(koralTerm, expression.getOperator());
+        parseRegexFlags(koralTerm, expression.getRegexFlags());
+        return koralTerm;
+    }
+
+    private void parseLayerIdentifier(KoralTerm koralTerm, String identifier) {
+        String layer = null;
+        if (identifier == null) {
+            processor.addError(StatusCodes.MALFORMED_QUERY,
+                    "FCS diagnostic 10: Layer identifier is missing.");
+            koralTerm.setInvalid(true);
+        }
+        else if (identifier.equals("text")) {
+            layer = "orth";
+        }
+        else if (identifier.equals("pos")) {
+            layer = "p";
+        }
+        else if (identifier.equals("lemma")) {
+            layer = "l";
+        }
+        else {
+            processor.addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
+                    "SRU diagnostic 48: Layer " + identifier
+                            + " is unsupported.");
+            koralTerm.setInvalid(true);
+        }
+
+        koralTerm.setLayer(layer);
+    }
+
+    private void parseQualifier(KoralTerm koralTerm, String qualifier) {
+        String layer = koralTerm.getLayer();
+        if (layer == null) {
+            koralTerm.setInvalid(true);
+            return;
+        }
+        // Set default foundry
+        if (qualifier == null) {
+            if (layer.equals("orth")) {
+                qualifier = FOUNDRY_OPENNLP;
+            }
+            else {
+                qualifier = FOUNDRY_TT;
+            }
+        }
+        else if (qualifier.equals(FOUNDRY_OPENNLP) && layer.equals("l")) {
+            processor
+                    .addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
+                            "SRU diagnostic 48: Layer lemma with qualifier opennlp is unsupported.");
+            koralTerm.setInvalid(true);
+        }
+        else if (!supportedFoundries.contains(qualifier)) {
+            processor.addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
+                    "SRU diagnostic 48: Qualifier " + qualifier
+                            + " is unsupported.");
+            koralTerm.setInvalid(true);
+        }
+
+        koralTerm.setFoundry(qualifier);
+    }
+
+    private void parseOperator(KoralTerm koralTerm, Operator operator) {
+        String matchOperator = null;
+        if (operator == null || operator == Operator.EQUALS) {
+            matchOperator = "match:eq";
+        }
+        else if (operator == Operator.NOT_EQUALS) {
+            matchOperator = "match:ne";
+        }
+        else {
+            processor
+                    .addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
+                            "SRU diagnostic 37:" + operator.name()
+                                    + " is unsupported.");
+            koralTerm.setInvalid(true);
+        }
+        koralTerm.setOperator(matchOperator);
+    }
+
+    private void parseRegexFlags(KoralTerm koralTerm, Set<RegexFlag> set) {
+        // default case sensitive
+        if (set != null) {
+            for (RegexFlag f : set) {
+                if (f == RegexFlag.CASE_SENSITVE) {
+                    koralTerm.setCaseSensitive(true);
+                }
+                else if (f == RegexFlag.CASE_INSENSITVE) {
+                    koralTerm.setCaseSensitive(false);
+                }
+                else {
+                    processor.addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
+                            "SRU diagnostic 48:" + f.name()
+                                    + " is unsupported.");
+                    koralTerm.setInvalid(true);
+                }
+            }
+        }
+    }
+
+}
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralSequence.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralSequence.java
new file mode 100644
index 0000000..31bd159
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralSequence.java
@@ -0,0 +1,71 @@
+package de.ids_mannheim.korap.query.parse.fcsql;
+
+import java.util.List;
+
+public class KoralSequence {
+
+    private boolean inOrder = false;
+    private List<Object> operands;
+    private List<Distance> distances;
+
+    public boolean isInOrder() {
+        return inOrder;
+    }
+
+    public void setInOrder(boolean inOrder) {
+        this.inOrder = inOrder;
+    }
+
+    public List<Object> getOperands() {
+        return operands;
+    }
+
+    public void setOperands(List<Object> operands) {
+        this.operands = operands;
+    }
+
+    public List<Distance> getDistances() {
+        return distances;
+    }
+
+    public void setDistances(List<Distance> distances) {
+        this.distances = distances;
+    }
+
+    public class Distance {
+        private String key;
+        private String min;
+        private String max;
+
+        public Distance (String key, int min, int max) {
+            this.key = key;
+            this.min = String.valueOf(min);
+            this.max = String.valueOf(max);
+        }
+
+        public String getKey() {
+            return key;
+        }
+
+        public void setKey(String key) {
+            this.key = key;
+        }
+
+        public String getMin() {
+            return min;
+        }
+
+        public void setMin(String min) {
+            this.min = min;
+        }
+
+        public String getMax() {
+            return max;
+        }
+
+        public void setMax(String max) {
+            this.max = max;
+        }
+
+    }
+}
diff --git a/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralTerm.java b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralTerm.java
new file mode 100644
index 0000000..1ae2e09
--- /dev/null
+++ b/src/main/java/de/ids_mannheim/korap/query/parse/fcsql/KoralTerm.java
@@ -0,0 +1,61 @@
+package de.ids_mannheim.korap.query.parse.fcsql;
+
+import java.util.Arrays;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import de.ids_mannheim.korap.query.serialize.FCSQLQueryProcessor;
+import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
+import eu.clarin.sru.server.fcs.parser.Operator;
+import eu.clarin.sru.server.fcs.parser.RegexFlag;
+
+public class KoralTerm {
+
+	private String layer;
+	private String foundry;
+	private String operator;
+	private String queryTerm;
+	private boolean caseSensitive = true;
+	private boolean invalid = false;
+	
+	
+	public String getLayer() {
+		return layer;
+	}
+	public void setLayer(String layer) {
+		this.layer = layer;
+	}
+	public String getFoundry() {
+		return foundry;
+	}
+	public void setFoundry(String foundry) {
+		this.foundry = foundry;
+	}
+	public String getOperator() {
+		return operator;
+	}
+	public void setOperator(String operator) {
+		this.operator = operator;
+	}
+	public String getQueryTerm() {
+		return queryTerm;
+	}
+	public void setQueryTerm(String queryTerm) {
+		this.queryTerm = queryTerm;
+	}
+	public boolean isCaseSensitive() {
+		return caseSensitive;
+	}
+	public void setCaseSensitive(boolean isCaseSensitive) {
+		this.caseSensitive = isCaseSensitive;
+	}
+	public boolean isInvalid() {
+		return invalid;
+	}
+	public void setInvalid(boolean invalid) {
+		this.invalid = invalid;
+	}
+	
+}
diff --git a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
index 7e0c199..0785237 100644
--- a/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
+++ b/src/main/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessor.java
@@ -4,266 +4,168 @@
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
+import de.ids_mannheim.korap.query.parse.fcsql.FCSSRUQueryParser;
+import de.ids_mannheim.korap.query.parse.fcsql.KoralSequence;
+import de.ids_mannheim.korap.query.parse.fcsql.KoralSequence.Distance;
+import de.ids_mannheim.korap.query.parse.fcsql.KoralTerm;
 import de.ids_mannheim.korap.query.serialize.util.StatusCodes;
 import eu.clarin.sru.server.SRUQueryBase;
-import eu.clarin.sru.server.SRUVersion;
 import eu.clarin.sru.server.fcs.Constants;
-import eu.clarin.sru.server.fcs.parser.Expression;
-import eu.clarin.sru.server.fcs.parser.Operator;
 import eu.clarin.sru.server.fcs.parser.QueryNode;
 import eu.clarin.sru.server.fcs.parser.QueryParser;
 import eu.clarin.sru.server.fcs.parser.QueryParserException;
-import eu.clarin.sru.server.fcs.parser.QuerySegment;
-import eu.clarin.sru.server.fcs.parser.RegexFlag;
 
+/**
+ * @author margaretha
+ * 
+ */
 public class FCSQLQueryProcessor extends AbstractQueryProcessor {
 
-	public static final class FCSQuery extends SRUQueryBase<QueryNode> {
+    public static final class FCSSRUQuery extends SRUQueryBase<QueryNode> {
 
-		private FCSQuery(String rawQuery, QueryNode parsedQuery) {
-			super(rawQuery, parsedQuery);
-		}
+        private FCSSRUQuery (String rawQuery, QueryNode parsedQuery) {
+            super(rawQuery, parsedQuery);
+        }
 
-		@Override
-		public String getQueryType() {
-			return Constants.FCS_QUERY_TYPE_FCS;
-		}
-	}
+        @Override
+        public String getQueryType() {
+            return Constants.FCS_QUERY_TYPE_FCS;
+        }
+    }
 
-	public enum Foundry {
-		CNX, OPENNLP, TT, MATE, XIP;
-	}
+    private static final String VERSION_2_0 = "2.0";
+    private static final String OPERATION_OR = "operation:or";
+    private static final String OPERATION_SEQUENCE = "operation:sequence";
+    private static final String OPERATION_POSITION = "operation:position";
 
-	private static final String KORAP_CONTEXT = "http://ids-mannheim.de/ns/KorAP/json-ld/v0.1/context.jsonld";
-	private String version;
-	private List<Foundry> supportedFoundries;
-	private final QueryParser parser = new QueryParser();
+    private final QueryParser fcsParser = new QueryParser();
+    private String version;
 
-	public FCSQLQueryProcessor(String query, String version) {
-		if (version == null) {
-			addError(StatusCodes.MISSING_VERSION,
-					"SRU Diagnostic 7: Version number is missing.");
-		} else if (!version.equals(SRUVersion.VERSION_2_0)) {
-			addError(StatusCodes.MISSING_VERSION,
-					"SRU Diagnostic 5: Only supports SRU version 2.0.");
-		}
-		this.version = version;
+    public FCSQLQueryProcessor (String query, String version) {
+        super();
+        this.version = version;
+        process(query);
+    }
 
-		this.requestMap = new LinkedHashMap<>();
-		requestMap.put("@context", KORAP_CONTEXT);
+    @Override
+    public Map<String, Object> getRequestMap() {
+        return this.requestMap;
+    }
 
-		this.supportedFoundries = new ArrayList<Foundry>(5);
-		supportedFoundries.add(Foundry.CNX);
-		supportedFoundries.add(Foundry.OPENNLP);
-		supportedFoundries.add(Foundry.TT);
-		supportedFoundries.add(Foundry.MATE);
-		supportedFoundries.add(Foundry.XIP);
+    @Override
+    public void process(String query) {
+        if (isVersionValid()) {
+            FCSSRUQuery fcsSruQuery = parseQueryStringtoFCSQuery(query);
+            QueryNode fcsQueryNode = fcsSruQuery.getParsedQuery();
+            parseFCSQueryToKoralQuery(fcsQueryNode);
+        }
+    }
 
-		process(query);
-	}
+    private boolean isVersionValid() {
+        if (version == null || version.isEmpty()) {
+            addError(StatusCodes.MISSING_VERSION,
+                    "SRU diagnostic 7: Version number is missing.");
+            return false;
+        }
+        else if (!version.equals(VERSION_2_0)) {
+            addError(StatusCodes.MISSING_VERSION,
+                    "SRU diagnostic 5: Only supports SRU version 2.0.");
+            return false;
+        }
+        return true;
+    }
 
-	@Override
-	public Map<String, Object> getRequestMap() {
-		return this.requestMap;
-	}
+    private FCSSRUQuery parseQueryStringtoFCSQuery(String query) {
+        if ((query == null) || query.isEmpty())
+            addError(StatusCodes.NO_QUERY,
+                    "SRU diagnostic 1: No query has been passed.");
+        FCSSRUQuery fcsQuery = null;
+        try {
+            QueryNode parsedQuery = fcsParser.parse(query);
+            fcsQuery = new FCSSRUQuery(query, parsedQuery);
+        }
+        catch (QueryParserException e) {
+            addError(StatusCodes.UNKNOWN_QUERY_ERROR, "FCS diagnostic 10: +"
+                    + e.getMessage());
+        }
+        catch (Exception e) {
+            addError(StatusCodes.UNKNOWN_QUERY_ERROR, "FCS diagnostic 10: +"
+                    + "Unexpected error while parsing query.");
+        }
+        return fcsQuery;
+    }
 
-	@Override
-	public void process(String query) {
-		FCSQuery fcsQuery = parseQueryStringtoFCSQuery(query);
-		QueryNode fcsQueryNode = fcsQuery.getParsedQuery();
-		Map<String, Object> queryMap = parseFCSQuery(fcsQueryNode);
-		requestMap.put("query", queryMap);
-	}
+    private void parseFCSQueryToKoralQuery(QueryNode queryNode) {
+        FCSSRUQueryParser parser = new FCSSRUQueryParser(this);
+        Object o = parser.parseQueryNode(queryNode);
+        Map<String, Object> queryMap = buildQueryMap(o);
+        if (queryMap != null) requestMap.put("query", queryMap);
+    }
 
-	private FCSQuery parseQueryStringtoFCSQuery(String query) {
-		if ((query == null) || query.isEmpty())
-			addError(StatusCodes.MALFORMED_QUERY,
-					"SRU diagnostic 1: No query has been passed.");
-		FCSQuery fcsQuery = null;
-		try {
-			QueryNode parsedQuery = parser.parse(query);
-			fcsQuery = new FCSQuery(query, parsedQuery);
-		} catch (QueryParserException e) {
-			addError(StatusCodes.UNKNOWN_QUERY_ERROR, "FCS Diagnostic 10: +"
-					+ e.getMessage());
-		}
-		catch (Exception e) {
-			addError(StatusCodes.UNKNOWN_QUERY_ERROR, "FCS Diagnostic 10: +"
-					+ "Unexpected error while parsing query.");
-		}
-		return fcsQuery;
-	}
+    private Map<String, Object> buildQueryMap(Object o) {
+        if (o != null) {
+            if (o instanceof KoralTerm) {
+                KoralTerm koralTerm = (KoralTerm) o;
+                if (!koralTerm.isInvalid()) {
+                    return createTermMap(koralTerm);
+                }
+            }
+            else if (o instanceof KoralSequence) {
+                KoralSequence koralSequence = (KoralSequence) o;
+                return createSequenceMap(koralSequence);
+            }
+        }
+        return null;
+    }
 
-	private Map<String, Object> parseFCSQuery(QueryNode queryNode) {
-		Map<String, Object> queryMap = parseQueryNode(queryNode);
-		if (queryMap == null) {
-			addError(StatusCodes.UNKNOWN_QUERY_ERROR, "SRU diagnostic 47:"
-					+ " Failed parsing query for unknown reasons.");
-		}
-		return queryMap;
+    private Map<String, Object> createSequenceMap(KoralSequence koralSequence) {
+        Map<String, Object> map = new LinkedHashMap<String, Object>();
+        map.put("@type", "koral:group");
+        map.put("operation", OPERATION_SEQUENCE);
+        map.put("inOrder", koralSequence.isInOrder());
 
-	}
+        if (koralSequence.getDistances() != null) {
+            List<Map<String, Object>> distanceList = new ArrayList<Map<String, Object>>();
+            for (Distance d : koralSequence.getDistances()) {
+                distanceList.add(createDistanceMap(d));
+            }
+            map.put("distances", distanceList);
+        }
 
-	private Map<String, Object> parseQueryNode(QueryNode queryNode) {
-		Map<String, Object> queryMap = null;
+        List<Map<String, Object>> operandList = new ArrayList<Map<String, Object>>();
+        for (Object o : koralSequence.getOperands()) {
+            operandList.add(buildQueryMap(o));
+        }
+        map.put("operands", operandList);
+        return map;
+    }
 
-		if (queryNode instanceof QuerySegment) {
-			queryMap = parseQuerySegment((QuerySegment) queryNode);
-//		} else if (queryNode instanceof QueryGroup) {
-//
-//		} else if (queryNode instanceof QuerySequence) {
-//
-//		} else if (queryNode instanceof QueryDisjunction) {
-//
-//		} else if (queryNode instanceof QueryWithWithin) {
+    private Map<String, Object> createDistanceMap(Distance distance) {
+        Map<String, Object> distanceMap = new LinkedHashMap<String, Object>();
+        distanceMap.put("@type", "koral:distance");
+        distanceMap.put("key", distance.getKey());
+        distanceMap.put("min", distance.getMin());
+        distanceMap.put("max", distance.getMax());
+        return distanceMap;
 
-		}else {
-			addError(StatusCodes.QUERY_TOO_COMPLEX, "FCS diagnostic 11:"
-					+ queryNode.getNodeType().name()
-					+ " is currently unsupported.");
-		}
+    }
 
-		return queryMap;
-	}
+    private Map<String, Object> createTermMap(KoralTerm fcsQuery) {
+        Map<String, Object> map = new LinkedHashMap<String, Object>();
+        map.put("@type", "koral:term");
+        if (!fcsQuery.isCaseSensitive()) {
+            map.put("caseInsensitive", "true");
+        }
+        map.put("key", fcsQuery.getQueryTerm());
+        map.put("foundry", fcsQuery.getFoundry());
+        map.put("layer", fcsQuery.getLayer());
+        map.put("match", fcsQuery.getOperator());
 
-	private Map<String, Object> parseQuerySegment(QuerySegment segment) {
-		Map<String, Object> queryMap = null;
-
-		if ((segment.getMinOccurs() == 1) && (segment.getMaxOccurs() == 1)) {
-			queryMap = parseExpression(segment.getExpression());
-		} else {
-			addError(StatusCodes.QUERY_TOO_COMPLEX, "FCS diagnostic 11:"
-					+ "Query is too complex.");
-		}
-		return queryMap;
-	}
-
-	private Map<String, Object> parseExpression(QueryNode queryNode) {
-		Map<String, Object> queryMap = null;
-
-		if (queryNode instanceof Expression) {
-			Expression expression = (Expression) queryNode;
-			queryMap = parseLayer(expression);
-		}
-		// else if (queryNode instanceof ExpressionAnd) {
-		//
-		// }
-		// else if (queryNode instanceof ExpressionGroup) {
-		//
-		// }
-		// else if (queryNode instanceof ExpressionNot) {
-		//
-		// }
-		// else if (queryNode instanceof ExpressionOr) {
-		//
-		// }
-		// else if (queryNode instanceof ExpressionWildcard) {
-		//
-		// }
-		else {
-			addError(StatusCodes.QUERY_TOO_COMPLEX, "FCS diagnostic 11:"
-					+ "Query is too complex.");
-		}
-		return queryMap;
-	}
-
-	private Map<String, Object> parseLayer(Expression expression) {
-		String layer = parseLayerIdentifier(expression.getLayerIdentifier());
-		String foundry = parseQualifier(expression.getLayerQualifier(), layer);
-		String operator = parseOperator(expression.getOperator());
-		boolean isCaseSensitive = parseRegexFlags(expression.getRegexFlags());		
-		String term = expression.getRegexValue();
-		
-		return writeTerm(term, foundry, layer, operator, isCaseSensitive);
-	}
-	private String parseLayerIdentifier(String identifier) {
-		String layer = null;
-		if (identifier == null) {
-			// throw exception
-		} else if (identifier.equals("text")) {
-			layer = "orth";
-		} else if (identifier.equals("pos")) {
-			layer = "p";
-		} else if (identifier.equals("lemma")) {
-			layer = "l";
-		} else {
-			addError(StatusCodes.UNKNOWN_QUERY_ELEMENT, "SRU diagnostic 48:"
-					+ identifier + " is unsupported.");
-		}
-
-		return layer;
-	}
-	
-	private String parseQualifier(String qualifier, String layer) {
-		// Set default foundry
-		if (qualifier == null) {
-			if (layer.equals("orth")) {
-				qualifier = Foundry.OPENNLP.name().toLowerCase();
-			} else {
-				qualifier = Foundry.TT.name().toLowerCase();
-			}
-		} else if (qualifier.equals(Foundry.OPENNLP.name().toLowerCase())
-				&& layer.equals("lemma")) {
-			addError(StatusCodes.UNKNOWN_QUERY_ELEMENT, "SRU diagnostic 48:"
-					+ "Layer lemma with qualifier opennlp is unsupported.");
-		} else if (!supportedFoundries.contains(qualifier)) {
-			addError(StatusCodes.UNKNOWN_QUERY_ELEMENT, "SRU diagnostic 48:"
-					+ "Layer " + layer + " with qualifier" + qualifier
-					+ " is unsupported.");
-		}
-		return qualifier;
-	}
-	
-	private String parseOperator(Operator operator) {
-		String matchOperator = null;
-		if (operator == null || operator == Operator.EQUALS) {
-			matchOperator = "match:eq";
-		} else if (operator == Operator.NOT_EQUALS) {
-			matchOperator = "match:ne";
-		} else {
-			addError(StatusCodes.UNKNOWN_QUERY_ELEMENT, "SRU diagnostic 37:"
-					+ operator.name() + " is unsupported.");
-		}
-		return matchOperator;
-	}
-	
-	private boolean parseRegexFlags(Set<RegexFlag> set) {
-		// default case sensitive
-		boolean flag = true;
-		if (set != null) {
-			for (RegexFlag f : set) {
-				if (f == RegexFlag.CASE_SENSITVE) {
-					continue;
-				} else if (f == RegexFlag.CASE_INSENSITVE) {
-					flag = false;
-				} else {
-					addError(StatusCodes.UNKNOWN_QUERY_ELEMENT,
-							"SRU diagnostic 48:" + f.name()
-									+ " is unsupported.");
-				}
-			}
-		}
-		return flag;
-	}
-
-	private Map<String, Object> writeTerm(String term, String foundry,
-			String layer, String operator, boolean isCaseSensitive) {
-		Map<String, Object> map = new LinkedHashMap<String, Object>();
-		map.put("@type", "koral:term");
-		if (!isCaseSensitive) {
-			map.put("caseInsensitive", "true");
-		}
-		map.put("key", term);
-		map.put("foundry", foundry);
-		map.put("layer", layer);
-		map.put("match", operator);
-
-		Map<String, Object> tokenMap = new LinkedHashMap<String, Object>();
-		tokenMap.put("@type", "koral:token");
-		tokenMap.put("wrap", map);
-		return tokenMap;
-	}
+        Map<String, Object> tokenMap = new LinkedHashMap<String, Object>();
+        tokenMap.put("@type", "koral:token");
+        tokenMap.put("wrap", map);
+        return tokenMap;
+    }
 
 }
diff --git a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
index 729381e..9b7da8b 100644
--- a/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
+++ b/src/test/java/de/ids_mannheim/korap/query/serialize/FCSQLQueryProcessorTest.java
@@ -2,89 +2,147 @@
 
 import static org.junit.Assert.assertEquals;
 
+import java.util.List;
 
 import org.junit.Test;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-public class FcsqlQueryProcessorTest {
-	ObjectMapper mapper = new ObjectMapper();
+public class FCSQLQueryProcessorTest {
 
-	private void runAndValidate(String query, String jsonLD)
-			throws JsonProcessingException {
-		FCSQLQueryProcessor tree = new FCSQLQueryProcessor(query, "2.0");
-		String serializedQuery = mapper.writeValueAsString(tree.getRequestMap()
-				.get("query"));
-		assertEquals(jsonLD.replace(" ", ""), serializedQuery.replace("\"", ""));
-	}
+    ObjectMapper mapper = new ObjectMapper();
 
-	@Test
-	public void testTermQuery() throws JsonProcessingException {
-		String query = "\"Sonne\"";
-		String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
-				+ "foundry:opennlp, layer:orth, match:match:eq}}";
-		runAndValidate(query, jsonLd);
-	}
+    private void runAndValidate(String query, String jsonLD)
+            throws JsonProcessingException {
+        FCSQLQueryProcessor processor = new FCSQLQueryProcessor(query, "2.0");
+        String serializedQuery = mapper.writeValueAsString(processor
+                .getRequestMap().get("query"));
+        assertEquals(jsonLD.replace(" ", ""), serializedQuery.replace("\"", ""));
+    }
 
-	@Test
-	public void testTermQueryWithRegexFlag() throws JsonProcessingException {
-		String query = "\"Fliegen\" /c";
-		String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, caseInsensitive:true, "
-				+ "key:Fliegen, foundry:opennlp, layer:orth, match:match:eq}}";
-		runAndValidate(query, jsonLd);
-	}
+    private List<Object> getError(FCSQLQueryProcessor processor) {
+        List<Object> errors = (List<Object>) processor.requestMap.get("errors");
+        return (List<Object>) errors.get(0);
+    }
 
-	@Test
-	public void testTermQueryWithSpecificLayer() throws JsonProcessingException {
-		String query = "[text = \"Sonne\"]";
-		String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
-				+ "foundry:opennlp, layer:orth, match:match:eq}}";
-		runAndValidate(query, jsonLd);
+    @Test
+    public void testTermQuery() throws JsonProcessingException {
+        String query = "\"Sonne\"";
+        String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
+                + "foundry:opennlp, layer:orth, match:match:eq}}";
+        runAndValidate(query, jsonLd);
+    }
 
-		query = "[lemma = \"sein\"]";
-		jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
-				+ "foundry:tt, layer:l, match:match:eq}}";
-		runAndValidate(query, jsonLd);
+    @Test
+    public void testTermQueryWithRegexFlag() throws JsonProcessingException {
+        String query = "\"Fliegen\" /c";
+        String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, caseInsensitive:true, "
+                + "key:Fliegen, foundry:opennlp, layer:orth, match:match:eq}}";
+        runAndValidate(query, jsonLd);
+    }
 
-		query = "[pos = \"NN\"]";
-		jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:NN, "
-				+ "foundry:tt, layer:p, match:match:eq}}";
-		runAndValidate(query, jsonLd);
-	}
+    @Test
+    public void testTermQueryWithSpecificLayer() throws JsonProcessingException {
+        String query = "[text = \"Sonne\"]";
+        String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, "
+                + "foundry:opennlp, layer:orth, match:match:eq}}";
+        runAndValidate(query, jsonLd);
 
-	@Test
-	public void testTermQueryWithQualifier() throws JsonProcessingException {
-		String query = "[mate:lemma = \"sein\"]";
-		String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
-				+ "foundry:mate, layer:l, match:match:eq}}";
-		runAndValidate(query, jsonLd);
+        query = "[lemma = \"sein\"]";
+        jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
+                + "foundry:tt, layer:l, match:match:eq}}";
+        runAndValidate(query, jsonLd);
 
-		query = "[cnx:pos = \"N\"]";
-		jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
-				+ "foundry:cnx, layer:p, match:match:eq}}";
-		runAndValidate(query, jsonLd);
-	}
+        query = "[pos = \"NN\"]";
+        jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:NN, "
+                + "foundry:tt, layer:p, match:match:eq}}";
+        runAndValidate(query, jsonLd);
+    }
 
-	@Test
-	public void testMatchOperation() throws JsonProcessingException {
-		String query = "[cnx:pos != \"N\"]";
-		String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
-				+ "foundry:cnx, layer:p, match:match:ne}}";
-		runAndValidate(query, jsonLd);
-	}
+    @Test
+    public void testTermQueryWithQualifier() throws JsonProcessingException {
+        String query = "[mate:lemma = \"sein\"]";
+        String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:sein, "
+                + "foundry:mate, layer:l, match:match:eq}}";
+        runAndValidate(query, jsonLd);
 
-	// @Test
-	// public void testSequenceQuery() throws JsonProcessingException {
-	// String query = "\"blaue\" [pos = \"NN\"]";
-	// String jsonLd =
-	// "{@type:koral:group, operation:operation:sequence, operands:["
-	// +
-	// "{@type:koral:token, wrap:{@type:koral:term, key:blaue, foundry:opennlp, layer:orth, match:match:eq}},"
-	// +
-	// "{@type:koral:token, wrap:{@type:koral:term, key:NN, foundry:tt, layer:p, match:match:eq}}"
-	// + "]}";
-	// runAndValidate(query, jsonLd);
-	// }
+        query = "[cnx:pos = \"N\"]";
+        jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
+                + "foundry:cnx, layer:p, match:match:eq}}";
+        runAndValidate(query, jsonLd);
+    }
+
+    @Test
+    public void testTermQueryException() throws JsonProcessingException {
+        String query = "[opennlp:lemma = \"sein\"]";
+        List<Object> error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        assertEquals(306, error.get(0));
+        assertEquals(
+                "SRU diagnostic 48: Layer lemma with qualifier opennlp is unsupported.",
+                error.get(1));
+
+        query = "[malt:lemma = \"sein\"]";
+        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        assertEquals(306, error.get(0));
+        assertEquals("SRU diagnostic 48: Qualifier malt is unsupported.",
+                error.get(1));
+
+        query = "[cnx:morph = \"heit\"]";
+        error = getError(new FCSQLQueryProcessor(query, "2.0"));
+        assertEquals(306, error.get(0));
+        assertEquals("SRU diagnostic 48: Layer morph is unsupported.",
+                error.get(1));
+
+    }
+
+    @Test
+    public void testMatchOperation() throws JsonProcessingException {
+        String query = "[cnx:pos != \"N\"]";
+        String jsonLd = "{@type:koral:token, wrap:{@type:koral:term, key:N, "
+                + "foundry:cnx, layer:p, match:match:ne}}";
+        runAndValidate(query, jsonLd);
+    }
+
+    @Test
+    public void testSequenceQuery() throws JsonProcessingException {
+        String query = "\"blaue\" [pos = \"NN\"]";
+        String jsonLd = "{@type:koral:group, operation:operation:sequence, operands:["
+                + "{@type:koral:token, wrap:{@type:koral:term, key:blaue, foundry:opennlp, layer:orth, match:match:eq}},"
+                + "{@type:koral:token, wrap:{@type:koral:term, key:NN, foundry:tt, layer:p, match:match:eq}}"
+                + "]}";
+        runAndValidate(query, jsonLd);
+    }
+
+    @Test
+    public void testAndQuery() throws JsonProcessingException {
+        String query = "[text=\"Sonne\" & text=\"scheint\"]";
+        String jsonLd = "{@type:koral:group, operation:operation:sequence, inOrder:false,"
+                + "distances:["
+                + "{@type:koral:distance, key:s, min:0, max:0}],"
+                + "operands:["
+                + "{@type:koral:token, wrap:{@type:koral:term, key:Sonne, foundry: opennlp, layer:orth, match:match:eq}},"
+                + "{@type:koral:token,wrap:{@type:koral:term, key:scheint, foundry: opennlp, layer:orth,match:match:eq}"
+                + "}]}";
+        runAndValidate(query, jsonLd);
+
+        // sru parser doesnt work for the following queries:
+        // String query = "\"Sonne & scheint\"";
+        // String query = "\"Sonne&scheint\"";
+    }
+
+    @Test
+    public void testVersion() throws JsonProcessingException {
+        List<Object> error = getError(new FCSQLQueryProcessor("\"Sonne\"",
+                "1.0"));
+        assertEquals(309, error.get(0));
+        assertEquals("SRU diagnostic 5: Only supports SRU version 2.0.",
+                error.get(1));
+
+        error = getError(new FCSQLQueryProcessor("\"Sonne\"", null));
+        assertEquals(309, error.get(0));
+        assertEquals("SRU diagnostic 7: Version number is missing.",
+                error.get(1));
+    }
 
 }
