Index: /applications/editors/josm/plugins/pt_assistant/images/next.svg
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/images/next.svg	(revision 32567)
+++ /applications/editors/josm/plugins/pt_assistant/images/next.svg	(revision 32567)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="16px" height="16px" viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
+<g>
+	<polygon points="8,4.646 7.323,5.323 10,8 3,8 3,9 10,9 7.323,11.677 8,12.354 11.854,8.5 	"/>
+</g>
+</svg>
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java	(revision 32567)
@@ -2,8 +2,15 @@
 package org.openstreetmap.josm.plugins.pt_assistant;
 
+import javax.swing.JMenuItem;
+
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.validation.OsmValidator;
+import org.openstreetmap.josm.gui.MainMenu;
+import org.openstreetmap.josm.gui.MapFrame;
 import org.openstreetmap.josm.plugins.Plugin;
 import org.openstreetmap.josm.plugins.PluginInformation;
-import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssitantValidatorTest;
+import org.openstreetmap.josm.plugins.pt_assistant.actions.AddStopPositionAction;
+import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssistantValidatorTest;
+import org.openstreetmap.josm.tools.ImageProvider;
 
 /**
@@ -14,5 +21,7 @@
  */
 public class PTAssistantPlugin extends Plugin {
-	
+
+	private JMenuItem addStopPositionMenu;
+
 	/**
 	 * Main constructor.
@@ -25,17 +34,37 @@
 		super(info);
 
-//		OsmValidator.addTest(PlatformsFirstTest.class);
-//		OsmValidator.addTest(RoadTypeTest.class);
-//		OsmValidator.addTest(DirectionTest.class);
-//		OsmValidator.addTest(GapTest.class);
+		OsmValidator.addTest(PTAssistantValidatorTest.class);
 		
-		OsmValidator.addTest(PTAssitantValidatorTest.class);
-		
+		AddStopPositionAction addStopPositionAction = new AddStopPositionAction();
+		addStopPositionMenu = MainMenu.add(Main.main.menu.toolsMenu, addStopPositionAction, false);
 
 	}
+
+	/**
+	 * Called when the JOSM map frame is created or destroyed.
+	 */
+	@Override
+	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+		if (oldFrame == null && newFrame != null) {
+			addStopPositionMenu.setEnabled(true);
+		} else if (oldFrame != null && newFrame == null) {
+			addStopPositionMenu.setEnabled(false);
+		}
+	}
 	
-
-
-
+	/**
+	 * Returns a ImageProvider for the given string or null if in headless mode.
+	 *
+	 * @param s
+	 *            The name of the file where the picture is.
+	 * @return A ImageProvider object for the given string or null if in
+	 *         headless mode.
+	 */
+	public static ImageProvider getProvider(String s) {
+		if (Main.main == null) {
+			return null;
+		}
+		return new ImageProvider(s);
+	}
 
 }
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java	(revision 32567)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/AddStopPositionAction.java	(revision 32567)
@@ -0,0 +1,79 @@
+package org.openstreetmap.josm.plugins.pt_assistant.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.plugins.pt_assistant.PTAssistantPlugin;
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ * Action to add stop position and split the relevant way
+ * 
+ * @author darya
+ *
+ */
+public class AddStopPositionAction extends JosmAction {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5140181388906670207L;
+
+	public AddStopPositionAction() {
+		super(tr("Add stop position"), PTAssistantPlugin.getProvider("next.svg"), tr("Add stop position"),
+				Shortcut.registerShortcut("Add stop position", tr("Add stop position"), KeyEvent.VK_T, Shortcut.NONE),
+				false, "addStopPosition", false);
+
+		this.setEnabled(true);
+	}
+
+	@Override
+	public void actionPerformed(ActionEvent e) {
+
+		if (!isEnabled() || !Main.isDisplayingMapView()) {
+			return;
+		}
+
+		Main.map.mapView.addMouseListener(new MouseAdapter() {
+
+			LatLon clickPosition;
+
+			@Override
+			public void mouseClicked(MouseEvent e) {
+				
+				if (clickPosition == null) {
+					clickPosition = Main.map.mapView.getLatLon(e.getX(), e.getY());
+
+					Layer activeLayer = Main.getLayerManager().getActiveLayer();
+
+					if (activeLayer instanceof OsmDataLayer) {
+						OsmDataLayer osmDataLayer = (OsmDataLayer) activeLayer;
+						Node newNode = new Node(clickPosition);
+						newNode.put("bus", "yes");
+						newNode.put("public_transport", "stop_position");
+						osmDataLayer.data.addPrimitive(newNode);
+						osmDataLayer.data.setSelected(newNode);
+						Main.map.mapView.repaint();
+
+					}
+
+					Main.map.mapView.removeMouseListener(this);
+					Main.map.mapView.removeMouseMotionListener(this);
+
+				}
+			}
+		});
+
+	}
+
+}
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/PTAssistantLayer.java	(revision 32567)
@@ -176,5 +176,5 @@
 					}
 
-					Main.map.repaint();
+					Main.map.mapView.repaint();
 				}
 
@@ -200,5 +200,5 @@
 
 			this.primitives.clear();
-			Main.map.repaint();
+			Main.map.mapView.repaint();
 		}
 
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/RouteUtils.java	(revision 32567)
@@ -4,5 +4,4 @@
 import org.openstreetmap.josm.data.osm.Relation;
 import org.openstreetmap.josm.data.osm.RelationMember;
-import org.openstreetmap.josm.data.osm.Way;
 
 /**
@@ -114,51 +113,3 @@
 	}
 
-	/**
-	 * Checks if the type of the way is suitable for buses to go on it. The
-	 * direction of the way (i.e. one-way roads) is irrelevant for this test.
-	 * 
-	 * TODO: this test is duplicated in WayChecker, remove it here when the old
-	 * implementation is not needed anymore.
-	 * 
-	 * @deprecated
-	 * 
-	 * @param way
-	 *            to be checked
-	 * @return true if the way is suitable for buses, false otherwise.
-	 */
-	public static boolean isWaySuitableForBuses(Way way) {
-		if (way.hasTag("highway", "motorway") || way.hasTag("highway", "trunk") || way.hasTag("highway", "primary")
-				|| way.hasTag("highway", "secondary") || way.hasTag("highway", "tertiary")
-				|| way.hasTag("highway", "unclassified") || way.hasTag("highway", "road")
-				|| way.hasTag("highway", "residential") || way.hasTag("highway", "service")
-				|| way.hasTag("highway", "motorway_link") || way.hasTag("highway", "trunk_link")
-				|| way.hasTag("highway", "primary_link") || way.hasTag("highway", "secondary_link")
-				|| way.hasTag("highway", "tertiary_link") || way.hasTag("highway", "living_street")
-				|| way.hasTag("highway", "bus_guideway") || way.hasTag("highway", "road")
-				|| way.hasTag("cycleway", "share_busway") || way.hasTag("cycleway", "shared_lane")) {
-			return true;
-		}
-
-		if (way.hasTag("highway", "pedestrian") && (way.hasTag("bus", "yes") || way.hasTag("psv", "yes")
-				|| way.hasTag("bus", "designated") || way.hasTag("psv", "designated"))) {
-			return true;
-		}
-
-		return false;
-	}
-
-	public static boolean hasIncompleteMembers(Relation r) {
-		if (r == null) {
-			return true;
-		}
-		for (RelationMember rm : r.getMembers()) {
-			if ((rm.isNode() && rm.getNode().isIncomplete()) || (rm.isWay() && rm.getWay().isIncomplete())
-					|| (rm.isRelation() && rm.getRelation().isIncomplete())) {
-				return true;
-			}
-		}
-
-		return false;
-	}
-
 }
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java	(revision 32567)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java	(revision 32567)
@@ -0,0 +1,360 @@
+package org.openstreetmap.josm.plugins.pt_assistant.validation;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import org.openstreetmap.josm.command.Command;
+import org.openstreetmap.josm.command.SequenceCommand;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.validation.Severity;
+import org.openstreetmap.josm.data.validation.Test;
+import org.openstreetmap.josm.data.validation.TestError;
+import org.openstreetmap.josm.plugins.pt_assistant.actions.FixTask;
+import org.openstreetmap.josm.plugins.pt_assistant.actions.IncompleteMembersDownloadThread;
+import org.openstreetmap.josm.plugins.pt_assistant.gui.IncompleteMembersDownloadDialog;
+import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantLayer;
+import org.openstreetmap.josm.plugins.pt_assistant.gui.ProceedDialog;
+import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
+
+public class PTAssistantValidatorTest extends Test {
+
+	public static final int ERROR_CODE_SORTING = 3711;
+	public static final int ERROR_CODE_ROAD_TYPE = 3721;
+	public static final int ERROR_CODE_CONSTRUCTION = 3722;
+	public static final int ERROR_CODE_DIRECTION = 3731;
+	public static final int ERROR_CODE_END_STOP = 3141;
+	public static final int ERROR_CODE_SPLIT_WAY = 3142;
+	public static final int ERROR_CODE_RELAITON_MEMBER_ROLES = 3143;
+
+	private PTAssistantLayer layer;
+
+	public PTAssistantValidatorTest() {
+		super(tr("Public Transport Assistant tests"),
+				tr("Check if route relations are compatible with public transport version 2"));
+
+		layer = new PTAssistantLayer();
+		DataSet.addSelectionListener(layer);
+
+	}
+
+	@Override
+	public void visit(Relation r) {
+
+		if (!RouteUtils.isTwoDirectionRoute(r)) {
+			return;
+		}
+
+		// Download incomplete members. If the download does not work, return
+		// and do not do any testing.
+		if (r.hasIncompleteMembers()) {
+
+			boolean downloadSuccessful = this.downloadIncompleteMembers();
+			if (!downloadSuccessful) {
+				return;
+			}
+
+		}
+
+		if (r.hasIncompleteMembers()) {
+			return;
+		}
+
+		// Check individual ways using the oneway direction test and the road
+		// type test:
+		WayChecker wayChecker = new WayChecker(r, this);
+		if (!r.hasIncompleteMembers()) {
+			wayChecker.performDirectionTest();
+			wayChecker.performRoadTypeTest();
+		}
+		this.errors.addAll(wayChecker.getErrors());
+
+		if (this.errors.isEmpty()) {
+			proceedWithSorting(r);
+		} else {
+			this.proceedAfterWayCheckerErrors(r);
+		}
+
+	}
+
+	/**
+	 * Downloads incomplete relation members in an extra thread (user input
+	 * required)
+	 * 
+	 * @return true if successful, false if not successful
+	 */
+	private boolean downloadIncompleteMembers() {
+
+		final int[] userSelection = { 0 };
+
+		try {
+
+			if (SwingUtilities.isEventDispatchThread()) {
+
+				userSelection[0] = showIncompleteMembersDownloadDialog();
+
+			} else {
+
+				SwingUtilities.invokeAndWait(new Runnable() {
+					@Override
+					public void run() {
+						try {
+							userSelection[0] = showIncompleteMembersDownloadDialog();
+						} catch (InterruptedException e) {
+							e.printStackTrace();
+						}
+
+					}
+				});
+
+			}
+
+		} catch (InterruptedException | InvocationTargetException e) {
+			return false;
+		}
+
+		if (userSelection[0] == JOptionPane.YES_OPTION) {
+
+			Thread t = new IncompleteMembersDownloadThread();
+			t.start();
+			synchronized (t) {
+				try {
+					t.wait();
+				} catch (InterruptedException e) {
+					return false;
+				}
+			}
+
+		}
+
+		return true;
+
+	}
+
+	/**
+	 * Shows the dialog asking the user about an incomplete member download
+	 * 
+	 * @return user's selection
+	 * @throws InterruptedException
+	 */
+	private int showIncompleteMembersDownloadDialog() throws InterruptedException {
+
+		IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog();
+		return incompleteMembersDownloadDialog.getUserSelection();
+
+	}
+
+	/**
+	 * Gets user input after errors were detected by WayChecker (direction
+	 * errors and road type errors)
+	 */
+	private void proceedAfterWayCheckerErrors(Relation r) {
+
+		// count errors of each type:
+		int numberOfDirectionErrors = 0;
+		int numberOfRoadTypeErrors = 0;
+		for (TestError e : this.errors) {
+			if (e.getCode() == ERROR_CODE_DIRECTION) {
+				numberOfDirectionErrors++;
+			}
+			if (e.getCode() == ERROR_CODE_ROAD_TYPE) {
+				numberOfRoadTypeErrors++;
+			}
+		}
+
+		final int[] userInput = { 0 };
+		final long idParameter = r.getId();
+		final int directionErrorParameter = numberOfDirectionErrors;
+		final int roadTypeErrorParameter = numberOfRoadTypeErrors;
+
+		if (SwingUtilities.isEventDispatchThread()) {
+
+			userInput[0] = showProceedDialog(idParameter, directionErrorParameter, roadTypeErrorParameter);
+
+		} else {
+
+			try {
+				SwingUtilities.invokeAndWait(new Runnable() {
+					@Override
+					public void run() {
+						userInput[0] = showProceedDialog(idParameter, roadTypeErrorParameter, roadTypeErrorParameter);
+
+					}
+				});
+			} catch (InvocationTargetException | InterruptedException e1) {
+				// TODO Auto-generated catch block
+				e1.printStackTrace();
+			}
+
+		}
+
+		if (userInput[0] == 0) {
+			this.fixErrorFromPlugin(this.errors);
+			proceedWithSorting(r);
+			return;
+		}
+
+		if (userInput[0] == 1) {
+			// TODO
+			JOptionPane.showMessageDialog(null, "This is not implemented yet!");
+			return;
+		}
+
+		if (userInput[0] == 2) {
+			// TODO: should the errors be removed from the error list?
+			proceedWithSorting(r);
+		}
+
+		// if userInput==-1 (i.e. no input), do nothing and stop testing of the
+		// route.
+
+	}
+
+	private int showProceedDialog(long id, int numberOfDirectionErrors, int numberOfRoadTypeErrors) {
+
+		ProceedDialog proceedDialog = new ProceedDialog(id, numberOfDirectionErrors, numberOfRoadTypeErrors);
+		return proceedDialog.getUserSelection();
+
+	}
+
+	/**
+	 * Carries out the second stage of the testing: sorting
+	 * 
+	 * @param r
+	 */
+	private void proceedWithSorting(Relation r) {
+
+		// Check if the relation is correct, or only has a wrong sorting order:
+		RouteChecker routeChecker = new RouteChecker(r, this);
+		routeChecker.performSortingTest();
+		List<TestError> routeCheckerErrors = routeChecker.getErrors();
+
+		/*- At this point, there are 3 variants: 
+		 * 
+		 * 1) There are no errors => route is correct
+		 * 2) There is only a sorting error (can only be 1), but otherwise
+		 * correct.
+		 * 3) There are some other errors/gaps that cannot be fixed by
+		 * sorting => start further test (stop-by-stop) 
+		 * 
+		 * */
+
+		if (!routeCheckerErrors.isEmpty()) {
+			// Variant 2
+			// If there is only the sorting error, add it and stop testing.
+			this.errors.addAll(routeChecker.getErrors());
+			return;
+		}
+
+		if (!routeChecker.getHasGap()) {
+			// Variant 1
+			// TODO: add the segments of this route to the list correct route
+			// segments
+		}
+
+		// Variant 3:
+		proceedAfterSorting(r);
+
+	}
+
+	private void proceedAfterSorting(Relation r) {
+
+		SegmentChecker segmentChecker = new SegmentChecker(r, this);
+
+		// Check if the creation of the route data model in the segment checker
+		// worked. If it did not, it means the roles in the route relation do
+		// not match the tags of the route members.
+		if (!segmentChecker.getErrors().isEmpty()) {
+			this.errors.addAll(segmentChecker.getErrors());
+		}
+
+		segmentChecker.performFirstStopTest();
+		segmentChecker.performLastStopTest();
+
+		// TODO: perform segment test
+		this.errors.addAll(segmentChecker.getErrors());
+		// performDummyTest(r);
+	}
+
+	/**
+	 * Checks if the test error is fixable
+	 */
+	@Override
+	public boolean isFixable(TestError testError) {
+		if (testError.getCode() == ERROR_CODE_DIRECTION || testError.getCode() == ERROR_CODE_ROAD_TYPE
+				|| testError.getCode() == ERROR_CODE_CONSTRUCTION || testError.getCode() == ERROR_CODE_SORTING) {
+			return true;
+		}
+		return false;
+	}
+
+	@Override
+	public Command fixError(TestError testError) {
+
+		List<Command> commands = new ArrayList<>();
+
+		if (testError.getCode() == ERROR_CODE_ROAD_TYPE || testError.getCode() == ERROR_CODE_CONSTRUCTION) {
+			commands.add(WayChecker.fixErrorByRemovingWay(testError));
+		}
+
+		if (testError.getCode() == ERROR_CODE_DIRECTION) {
+			commands.add(WayChecker.fixErrorByZooming(testError));
+
+		}
+
+		if (testError.getCode() == ERROR_CODE_SORTING) {
+			commands.add(RouteChecker.fixSortingError(testError));
+		}
+
+		if (commands.isEmpty()) {
+			return null;
+		}
+
+		if (commands.size() == 1) {
+			return commands.get(0);
+		}
+
+		return new SequenceCommand(tr("Fix error"), commands);
+	}
+
+	/**
+	 * This method is the counterpart of the fixError(TestError testError)
+	 * method. The fixError method is invoked from the core validator (e.g. when
+	 * user presses the "Fix" button in the validator). This method is invoken
+	 * when the fix is initiated from within the plugin (e.g. automated fixes).
+	 * 
+	 * @return
+	 */
+	private void fixErrorFromPlugin(List<TestError> testErrors) {
+
+		// run fix task asynchronously
+		FixTask fixTask = new FixTask(testErrors);
+		// Main.worker.submit(fixTask);
+
+		Thread t = new Thread(fixTask);
+		t.start();
+		try {
+			t.join();
+			errors.removeAll(testErrors);
+
+		} catch (InterruptedException e) {
+			JOptionPane.showMessageDialog(null, "Error occurred during fixing");
+		}
+
+	}
+
+	@SuppressWarnings("unused")
+	private void performDummyTest(Relation r) {
+		List<Relation> primitives = new ArrayList<>(1);
+		primitives.add(r);
+		errors.add(
+				new TestError(this, Severity.WARNING, tr("PT: dummy test warning"), ERROR_CODE_DIRECTION, primitives));
+	}
+
+}
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/RouteChecker.java	(revision 32567)
@@ -65,5 +65,5 @@
 				TestError e = new TestError(this.test, Severity.WARNING,
 						tr("PT: Route contains a gap that can be fixed by sorting"),
-						PTAssitantValidatorTest.ERROR_CODE_SORTING, relation);
+						PTAssistantValidatorTest.ERROR_CODE_SORTING, relation);
 				this.errors.add(e);
 
@@ -112,5 +112,5 @@
 	
 	protected static Command fixSortingError(TestError testError) {
-		if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_SORTING) {
+		if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_SORTING) {
 			return null;
 		}
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java	(revision 32567)
@@ -52,5 +52,5 @@
 			highlighted.add(rm.getMember());
 			TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Relation member roles do not match tags"),
-					PTAssitantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted);
+					PTAssistantValidatorTest.ERROR_CODE_RELAITON_MEMBER_ROLES, primitives, highlighted);
 			this.errors.add(e);
 		}
@@ -112,5 +112,5 @@
 				TestError e = new TestError(this.test, Severity.WARNING,
 						tr("PT: Route should start and end with a stop_position"),
-						PTAssitantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted);
+						PTAssistantValidatorTest.ERROR_CODE_END_STOP, primitives, highlighted);
 				this.errors.add(e);
 				return;
@@ -130,5 +130,5 @@
 
 				TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"),
-						PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
+						PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
 				this.errors.add(e);
 			}
@@ -146,5 +146,5 @@
 				highlighted.add(endStop.getStopPosition());
 				TestError e = new TestError(this.test, Severity.WARNING, tr("PT: First or last way needs to be split"),
-						PTAssitantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
+						PTAssistantValidatorTest.ERROR_CODE_SPLIT_WAY, primitives, highlighted);
 				this.errors.add(e);
 			}
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/WayChecker.java	(revision 32567)
@@ -121,5 +121,5 @@
 					TestError e = new TestError(this.test, Severity.WARNING,
 							tr("PT: Route type does not match the type of the road it passes on"),
-							PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted);
+							PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE, primitives, highlighted);
 					errors.add(e);
 
@@ -132,5 +132,5 @@
 					highlighted.add(way);
 					TestError e = new TestError(this.test, Severity.WARNING, tr("PT: Road is under construction"),
-							PTAssitantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted);
+							PTAssistantValidatorTest.ERROR_CODE_CONSTRUCTION, primitives, highlighted);
 					errors.add(e);
 				}
@@ -180,5 +180,5 @@
 					TestError e = new TestError(this.test, Severity.WARNING,
 							tr("PT: Route passes a oneway road in the wrong direction"),
-							PTAssitantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted);
+							PTAssistantValidatorTest.ERROR_CODE_DIRECTION, primitives, highlighted);
 					this.errors.add(e);
 					return;
@@ -221,6 +221,6 @@
 	protected static Command fixErrorByRemovingWay(TestError testError) {
 
-		if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE
-				&& testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
+		if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_ROAD_TYPE
+				&& testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
 			return null;
 		}
@@ -279,5 +279,5 @@
 	protected static Command fixErrorByZooming(TestError testError) {
 
-		if (testError.getCode() != PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
+		if (testError.getCode() != PTAssistantValidatorTest.ERROR_CODE_DIRECTION) {
 			return null;
 		}
@@ -337,12 +337,6 @@
 		GenericRelationEditor editor = new GenericRelationEditor(layer, r, r.getMembersFor(primitives));
 		RelationDialogManager.getRelationDialogManager().register(layer, r, editor);
-		
-		
 		editor.setVisible(true);
-//		editor.requestFocus();
-//		editor.requestFocusInWindow();
-		
-//		editor.firePropertyChange("focusedWindow", editor, editor);
-//		editor.setRelation(r);
+
 
 	}
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/RouteRepresentationTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/RouteRepresentationTest.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/data/RouteRepresentationTest.java	(revision 32567)
@@ -2,5 +2,4 @@
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
@@ -31,5 +30,5 @@
          * stop2(platform, Way)
          * way2 (Way)
-         * stop3 (stop_area)
+         * stop3 (platform)
          * way3 (Relation that consists of Ways only)
          * stop4 (stop_position)
@@ -45,4 +44,5 @@
         Node n1 = new Node(); 
         n1.put("name", "Stop1");
+        n1.put("public_transport", "stop_position");
         RelationMember rm1 = new RelationMember("stop", n1);
         members.add(rm1);
@@ -52,20 +52,23 @@
         RelationMember rm2 = new RelationMember("platform", w1);
         members.add(rm2);
-        Relation r1 = new Relation();
-        r1.put("name", "Stop3");
-        RelationMember rm3 = new RelationMember("stop_area", r1);
+        Node n2 = new Node();
+        n2.put("name", "Stop3");
+        n2.put("public_transport", "platform");
+        RelationMember rm3 = new RelationMember("platform", n2);
         members.add(rm3);
-        Node n2 = new Node();
-        n2.put("name", "Stop4");
-        RelationMember rm4 = new RelationMember("stop", n2);
-        members.add(rm4);
         Node n3 = new Node();
         n3.put("name", "Stop4");
-        RelationMember rm5 = new RelationMember("platform", n3);
+        n3.put("public_transport", "stop_position");
+        RelationMember rm4 = new RelationMember("stop", n3);
+        members.add(rm4);
+        Node n4 = new Node();
+        n4.put("name", "Stop4");
+        n4.put("public_transport", "platform");
+        RelationMember rm5 = new RelationMember("platform", n4);
         members.add(rm5);
-        Relation r2 = new Relation();
-        r2.put("name", "Stop5");
-        r2.put("highway", "platform_exit_only");
-        RelationMember rm6 = new RelationMember("platform_exit_only", r2);
+        Node n5 = new Node();
+        n5.put("name", "Stop5");
+        n5.put("highway", "platform");
+        RelationMember rm6 = new RelationMember("platform_exit_only", n5);
         members.add(rm6);
                 
@@ -90,6 +93,4 @@
         members.add(rm10);
         
-
-        
         Relation route = new Relation();
         route.setMembers(members);
@@ -112,4 +113,5 @@
         Node n1 = new Node(); 
         n1.put("name", "Stop1");
+        n1.put("public_transport", "stop_position");
         RelationMember rm1 = new RelationMember("stop", n1);
         members.add(rm1);
@@ -119,20 +121,23 @@
         RelationMember rm2 = new RelationMember("platform", w1);
         members.add(rm2);
-        Relation r1 = new Relation();
-        r1.put("name", "Stop3");
-        RelationMember rm3 = new RelationMember("stop_area", r1);
+        Node n2 = new Node();
+        n2.put("name", "Stop3");
+        n2.put("public_transport", "platform");
+        RelationMember rm3 = new RelationMember("platform", n2);
         members.add(rm3);
-        Node n2 = new Node();
-        n2.put("name", "Stop4");
-        RelationMember rm4 = new RelationMember("stop", n2);
-        members.add(rm4);
         Node n3 = new Node();
         n3.put("name", "Stop4");
-        RelationMember rm5 = new RelationMember("platform", n3);
+        n3.put("public_transport", "stop_position");
+        RelationMember rm4 = new RelationMember("stop", n3);
+        members.add(rm4);
+        Node n4 = new Node();
+        n4.put("name", "Stop4");
+        n4.put("public_transport", "platform");
+        RelationMember rm5 = new RelationMember("platform", n4);
         members.add(rm5);
-        Relation r2 = new Relation();
-        r2.put("name", "Stop5");
-        r2.put("highway", "platform_exit_only");
-        RelationMember rm6 = new RelationMember("platform_exit_only", r2);
+        Node n5 = new Node();
+        n5.put("name", "Stop5");
+        n5.put("highway", "platform");
+        RelationMember rm6 = new RelationMember("platform_exit_only", n5);
         members.add(rm6);
                 
@@ -146,8 +151,8 @@
         Relation r3 = new Relation(); // nested relation
         Way w4 = new Way();
-        Node wrongNode = new Node(); // CHANGED COMPARED TO PREVIOUS TEST
+        Node wrongNode = new Node();
         Way w6 = new Way();
         r3.addMember(new RelationMember("", w4));
-        r3.addMember(new RelationMember("platform", wrongNode));
+        r3.addMember(new RelationMember("", wrongNode));
         r3.addMember(new RelationMember("", w6));
         RelationMember rm9 = new RelationMember("", r3);
@@ -161,86 +166,11 @@
         route.setMembers(members);
         
-        boolean thrown = false;
-        String message = "";
-        try {
-            /*PTRouteDataManager manager =*/ new PTRouteDataManager(route);
-        } catch(IllegalArgumentException e) {
-            thrown = true;
-            message = e.getMessage();
-        }
+        PTRouteDataManager manager = new PTRouteDataManager(route);
         
-        assertTrue(thrown);
-        assertEquals(message, "A route relation member of OsmPrimitiveType.RELATION can only have ways as members");
+        assertEquals(manager.getFailedMembers().size(), 1);
+        assertEquals(manager.getPTStopCount(), 5);
+        assertEquals(manager.getPTWayCount(), 3);
         
     }
     
-    
-    @Test
-    public void multipleStopElementTest() {
-        
-        // Same as correctRouteTest(), but 
-        
-        ArrayList<RelationMember> members = new ArrayList<>();
-        
-        // Create stops:
-        Node n1 = new Node(); 
-        n1.put("name", "Stop1");
-        RelationMember rm1 = new RelationMember("stop", n1);
-        members.add(rm1);
-        Way w1 = new Way();
-        w1.put("name", "Stop2");
-        w1.put("highway", "platform");
-        RelationMember rm2 = new RelationMember("platform", w1);
-        members.add(rm2);
-        Relation r1 = new Relation();
-        r1.put("name", "Stop3");
-        RelationMember rm3 = new RelationMember("stop_area", r1);
-        members.add(rm3);
-        Node n2 = new Node();
-        n2.put("name", "Stop4");
-        RelationMember rm4 = new RelationMember("stop", n2);
-        members.add(rm4);
-        Node n3 = new Node();
-        n3.put("name", "Stop4");
-        RelationMember rm5 = new RelationMember("platform", n3);
-        members.add(rm5);
-        Relation r2 = new Relation();
-        r2.put("name", "Stop5");
-        r2.put("highway", "platform_exit_only");
-        RelationMember rm6 = new RelationMember("platform_exit_only", r2);
-        members.add(rm6);
-                
-        // Create ways:
-        Way w2 = new Way();
-        RelationMember rm7 = new RelationMember("", w2);
-        members.add(rm7);
-        Way w3 = new Way();
-        RelationMember rm8 = new RelationMember("", w3);
-        members.add(rm8);
-        Relation r3 = new Relation(); // nested relation
-        Way w4 = new Way();
-        Way w5 = new Way();
-        Way w6 = new Way();
-        r3.addMember(new RelationMember("", w4));
-        r3.addMember(new RelationMember("", w5));
-        r3.addMember(new RelationMember("", w6));
-        RelationMember rm9 = new RelationMember("", r3);
-        members.add(rm9);
-        Way w7 = new Way();
-        RelationMember rm10 = new RelationMember("", w7);
-        members.add(rm10);
-        
-
-        
-        Relation route = new Relation();
-        route.setMembers(members);
-        
-        PTRouteDataManager manager = new PTRouteDataManager(route);
-    
-        assertEquals(manager.getPTStopCount(), 5);
-        assertEquals(manager.getPTWayCount(), 4);
-        
-    }
-    
-
 }
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/DirecionTestTest.java	(revision 32567)
@@ -5,4 +5,5 @@
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
@@ -19,10 +20,9 @@
     @Test
     public void test() {
-        // this file has:
-        // Way 
-        
         
         File file = new File(AbstractTest.PATH_TO_ROUNDABOUT_ONEWAY);
         DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+        
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
         
         Relation route = null;
@@ -35,14 +35,16 @@
         assertEquals(route.getMembersCount(), 213);
                 
-        DirectionTest directionTest = new DirectionTest();
+        List<TestError> errors = new ArrayList<>();
+        
         for (Relation r: ds.getRelations()) {
-            directionTest.visit(r);
+        	WayChecker wayChecker = new WayChecker(r, test);
+        	wayChecker.performDirectionTest();
+        	errors.addAll(wayChecker.getErrors());
         }
         
-        List<TestError> errors = directionTest.getErrors();
         assertEquals(errors.size(), 1);
         int onewayErrorCaught = 0;
         for (TestError e: errors ) {
-            if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {
+            if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
                 onewayErrorCaught++;
             }
@@ -55,5 +57,5 @@
         boolean detectedErrorsAreCorrect = true;
         for (TestError e: errors) {
-            if (e.getCode() == DirectionTest.ERROR_CODE_DIRECTION) {
+            if (e.getCode() == PTAssitantValidatorTest.ERROR_CODE_DIRECTION) {
                 @SuppressWarnings("unchecked")
                 List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/PlatformAsWayTest.java	(revision 32567)
@@ -4,4 +4,5 @@
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
@@ -20,10 +21,17 @@
         DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
         
-        GapTest gapTest = new GapTest();
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
+        
+        List<TestError> errors = new ArrayList<>();
+        
         for (Relation r: ds.getRelations()) {
-            gapTest.visit(r);
+        	WayChecker wayChecker = new WayChecker(r, test);
+        	wayChecker.performDirectionTest();
+        	wayChecker.performRoadTypeTest();
+        	errors.addAll(wayChecker.getErrors());
+        	RouteChecker routeChecker = new RouteChecker(r, test);
+        	routeChecker.performSortingTest();
+        	errors.addAll(routeChecker.getErrors());
         }
-        
-        List<TestError> errors = gapTest.getErrors();
         
         assertEquals(errors.size(), 0);
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java	(revision 32566)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/RoadTypeTestTest.java	(revision 32567)
@@ -5,4 +5,5 @@
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.List;
 
@@ -24,14 +25,17 @@
         DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
         
-        RoadTypeTest roadTypeTest = new RoadTypeTest();
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
+        List<TestError> errors = new ArrayList<>();
+        
         for (Relation r: ds.getRelations()) {
-            roadTypeTest.visit(r);
+        	WayChecker wayChecker = new WayChecker(r, test);
+        	wayChecker.performRoadTypeTest();
+        	errors.addAll(wayChecker.getErrors());
         }
         
-        List<TestError> errors = roadTypeTest.getErrors();
         assertEquals(errors.size(), 2);
         
         for (TestError e: errors) {
-            assertEquals(e.getCode(), RoadTypeTest.ERROR_CODE_ROAD_TYPE);
+            assertEquals(e.getCode(), PTAssitantValidatorTest.ERROR_CODE_ROAD_TYPE);
             @SuppressWarnings("unchecked")
             List<OsmPrimitive> highlighted = (List<OsmPrimitive>) e.getHighlighted();
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SortingTestTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SortingTestTest.java	(revision 32567)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SortingTestTest.java	(revision 32567)
@@ -0,0 +1,97 @@
+package org.openstreetmap.josm.plugins.pt_assistant.validation;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.data.osm.Relation;
+import org.openstreetmap.josm.data.validation.TestError;
+import org.openstreetmap.josm.plugins.pt_assistant.AbstractTest;
+import org.openstreetmap.josm.plugins.pt_assistant.ImportUtils;
+
+public class SortingTestTest extends AbstractTest {
+
+    @Test
+    public void sortingTestBeforeFile() {
+        File file = new File(AbstractTest.PATH_TO_DL131_BEFORE);
+        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+        
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
+
+        List<TestError> errors = new ArrayList<>();
+        
+        for (Relation r: ds.getRelations()) {
+        	RouteChecker routeChecker = new RouteChecker(r, test);
+        	routeChecker.performSortingTest();
+        	errors.addAll(routeChecker.getErrors());
+        	
+        }
+
+        assertEquals(errors.size(), 1);
+        assertEquals(errors.iterator().next().getCode(), PTAssitantValidatorTest.ERROR_CODE_SORTING);
+        assertEquals(errors.iterator().next().getTester().getClass().getName(), PTAssitantValidatorTest.class.getName());
+    }
+
+    @Test
+    public void sortingTestAfterFile() {
+        File file = new File(AbstractTest.PATH_TO_DL131_AFTER);
+        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+        
+        
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
+
+        List<TestError> errors = new ArrayList<>();
+        
+        for (Relation r: ds.getRelations()) {
+        	RouteChecker routeChecker = new RouteChecker(r, test);
+        	routeChecker.performSortingTest();
+        	errors.addAll(routeChecker.getErrors());
+        	
+        }
+
+
+        assertEquals(errors.size(), 0);
+    }
+
+    // TODO: this test will only pass after the functionality for recognizing
+    // and closing the gap is implemented.
+//    @Test
+//    public void overshootTestBeforeFile() {
+//        File file = new File(AbstractTest.PATH_TO_DL286_BEFORE);
+//        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+//
+//        GapTest gapTest = new GapTest();
+//        for (Relation r : ds.getRelations()) {
+//            gapTest.visit(r);
+//        }
+//
+//        List<TestError> errors = gapTest.getErrors();
+//
+//        assertEquals(errors.size(), 1);
+//        assertEquals(errors.get(0).getCode(), GapTest.ERROR_CODE_OVERSHOOT);
+//
+//    }
+
+    @Test
+    public void overshootTestAfterFile() {
+        File file = new File(AbstractTest.PATH_TO_DL286_AFTER);
+        DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+        
+        PTAssitantValidatorTest test = new PTAssitantValidatorTest();
+
+        List<TestError> errors = new ArrayList<>();
+        
+        for (Relation r: ds.getRelations()) {
+        	RouteChecker routeChecker = new RouteChecker(r, test);
+        	routeChecker.performSortingTest();
+        	errors.addAll(routeChecker.getErrors());
+        }
+
+        assertEquals(errors.size(), 0);
+    }
+
+}
