Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java	(revision 32733)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/data/PTStop.java	(revision 32734)
@@ -137,5 +137,5 @@
 		}
 
-		// Look for a stop position within 100 m (around 0.002 degrees) of this
+		// Look for a stop position within 0.002 degrees (around 100 m) of this
 		// platform:
 
@@ -147,6 +147,4 @@
 		BBox platformBBox = new BBox(ax, ay, bx, by);
 
-		// Collection<Node> allNodes =
-		// Main.getLayerManager().getEditDataSet().getNodes();
 		Collection<Node> allNodes = platform.getDataSet().getNodes();
 		for (Node currentNode : allNodes) {
@@ -163,5 +161,6 @@
 	 * stop_position or a platform
 	 * 
-	 * @param other PTStop to be compared
+	 * @param other
+	 *            PTStop to be compared
 	 * @return true if equal, false otherwise
 	 */
@@ -172,9 +171,11 @@
 		}
 
-		if (this.stopPosition != null && (this.stopPosition == other.getStopPosition() || this.stopPosition == other.getPlatform())) {
+		if (this.stopPosition != null
+				&& (this.stopPosition == other.getStopPosition() || this.stopPosition == other.getPlatform())) {
 			return true;
 		}
-		
-		if (this.platform != null && (this.platform == other.getPlatform() || this.platform == other.getStopPosition())) {
+
+		if (this.platform != null
+				&& (this.platform == other.getPlatform() || this.platform == other.getStopPosition())) {
 			return true;
 		}
@@ -182,4 +183,4 @@
 		return false;
 	}
-	
+
 }
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/StopToWayAssigner.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/StopToWayAssigner.java	(revision 32733)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/utils/StopToWayAssigner.java	(revision 32734)
@@ -43,5 +43,5 @@
 	public StopToWayAssigner(List<PTWay> ptways) {
 		ways = new HashSet<Way>();
-		for (PTWay ptway: ptways) {
+		for (PTWay ptway : ptways) {
 			ways.addAll(ptway.getWays());
 		}
@@ -59,5 +59,5 @@
 		if (stopToWay.containsKey(stop)) {
 			List<Way> assignedWays = stopToWay.get(stop);
-			for (Way assignedWay: assignedWays) {
+			for (Way assignedWay : assignedWays) {
 				if (this.ways.contains(assignedWay)) {
 					return assignedWay;
@@ -72,6 +72,4 @@
 			return wayOfStopPosition;
 		}
-
-		// TODO: search if a stop position is in the vicinity of a platform
 
 		// 3) Search if the stop has a stop_area:
@@ -98,5 +96,37 @@
 		}
 
-		// 4) Run the growing-bounding-boxes algorithm:
+		// 4) Search if a stop position is in the vicinity of a platform:
+		if (stop.getPlatform() != null) {
+			List<Node> potentialStopPositionList = stop.findPotentialStopPositions();
+			Node closestStopPosition = null;
+			double minDistanceSq = Double.MAX_VALUE;
+			for (Node potentialStopPosition : potentialStopPositionList) {
+				double distanceSq = potentialStopPosition.getCoor()
+						.distanceSq(stop.getPlatform().getBBox().getCenter());
+				if (distanceSq < minDistanceSq) {
+					closestStopPosition = potentialStopPosition;
+					minDistanceSq = distanceSq;
+				}
+			}
+			if (closestStopPosition != null) {
+				Way closestWay = null;
+				double minDistanceSqToWay = Double.MAX_VALUE;
+				for (Way way: this.ways) {
+					if (way.containsNode(closestStopPosition)) {
+						double distanceSq = calculateMinDistanceToSegment(new Node(stop.getPlatform().getBBox().getCenter()), way);
+						if (distanceSq < minDistanceSqToWay) {
+							closestWay = way;
+							minDistanceSqToWay = distanceSq;
+						}
+					}
+				}
+				if (closestWay != null) {
+					addAssignedWayToMap(stop, closestWay);
+					return closestWay;
+				}
+			}
+		}
+
+		// 5) Run the growing-bounding-boxes algorithm:
 		double searchRadius = 0.001;
 		while (searchRadius < 0.005) {
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 32733)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java	(revision 32734)
@@ -45,5 +45,4 @@
 	public static final int ERROR_CODE_STOP_BY_STOP = 3754;
 
-
 	private PTAssistantLayer layer;
 
@@ -284,12 +283,11 @@
 			// If there is only the sorting error, add it and stop testing.
 			this.errors.addAll(routeChecker.getErrors());
-			return;
-		}
-
-		if (!routeChecker.getHasGap()) {
-			// Variant 1
-//			storeCorrectRouteSegments(r);
-
-		}
+			// return;
+		}
+
+		// if (!routeChecker.getHasGap()) {
+		// // Variant 1
+		// storeCorrectRouteSegments(r);
+		// }
 
 		// Variant 3:
@@ -311,5 +309,16 @@
 		segmentChecker.performFirstStopTest();
 		segmentChecker.performLastStopTest();
-		segmentChecker.performStopByStopTest();
+		segmentChecker.performStopNotServedTest();
+
+		boolean sortingErrorFound = false;
+		for (TestError error : this.errors) {
+			if (error.getCode() == ERROR_CODE_SORTING) {
+				sortingErrorFound = true;
+				break;
+			}
+		}
+		if (!sortingErrorFound) {
+			segmentChecker.performStopByStopTest();
+		}
 
 		this.errors.addAll(segmentChecker.getErrors());
@@ -317,6 +326,9 @@
 
 	/**
-	 * Creates the PTRouteSegments of a route that has been found correct and stores them in the list of correct route segments
-	 * @param r route relation
+	 * Creates the PTRouteSegments of a route that has been found correct and
+	 * stores them in the list of correct route segments
+	 * 
+	 * @param r
+	 *            route relation
 	 */
 	@SuppressWarnings("unused")
@@ -326,5 +338,5 @@
 		if (manager.getPTStops().size() > 1) {
 			for (int i = 1; i < manager.getPTStops().size(); i++) {
-				PTStop segmentStartStop = manager.getPTStops().get(i-1);
+				PTStop segmentStartStop = manager.getPTStops().get(i - 1);
 				PTStop segmentEndStop = manager.getPTStops().get(i);
 				Way segmentStartWay = assigner.get(segmentStartStop);
@@ -348,9 +360,9 @@
 			return true;
 		}
-		
+
 		if (testError.getCode() == ERROR_CODE_STOP_BY_STOP && SegmentChecker.isFixable(testError)) {
 			return true;
 		}
-		
+
 		return false;
 	}
@@ -378,5 +390,5 @@
 			commands.add(NodeChecker.fixError(testError));
 		}
-		
+
 		if (testError.getCode() == ERROR_CODE_STOP_BY_STOP) {
 			commands.add(SegmentChecker.fixError(testError));
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 32733)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java	(revision 32734)
@@ -219,6 +219,19 @@
 	}
 
+	public void performStopNotServedTest() {
+		for (PTStop stop : manager.getPTStops()) {
+			Way way = assigner.get(stop);
+			if (way == null) {
+				createStopError(stop);
+			}
+		}
+	}
+
+	/**
+	 * Performs the stop-by-stop test by visiting each segment between two
+	 * consecutive stops and checking if the ways between them are correct
+	 */
 	public void performStopByStopTest() {
-		
+
 		if (manager.getPTStopCount() < 2) {
 			return;
@@ -233,18 +246,12 @@
 			Way startWay = assigner.get(startStop);
 			Way endWay = assigner.get(endStop);
-			if (startWay == null) {
+			if (startWay == null || endWay == null) {
 				this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
-				if (i == 0) {
-					createStopError(startStop);
-				}
 				continue;
 			}
-			if (endWay == null) {
-				this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
-				if (i != 0) {
-					createStopError(endStop);
-				}
-				continue;
-			}
+//
+//			System.out.println();
+//			System.out.println("start way: " + startWay.getId());
+//			System.out.println("end way: " + endWay.getId());
 
 			List<PTWay> segmentWays = manager.getPTWaysBetween(startWay, endWay);
@@ -267,4 +274,5 @@
 				correctSegments.add(routeSegment);
 			} else {
+//				System.out.println("ERROR");
 				PTRouteSegment routeSegment = new PTRouteSegment(startStop, endStop, segmentWays);
 				TestError error = this.errors.get(this.errors.size() - 1);
@@ -366,4 +374,5 @@
 		if (start == end) {
 			// if both PTStops are on the same PTWay
+			this.firstNodeOfRouteSegmentInDirectionOfTravel = null;
 			return true;
 		}
@@ -397,6 +406,18 @@
 				// find the next node in direction of travel (which is part of
 				// the PTWay start):
+//				if (firstNodeOfRouteSegmentInDirectionOfTravel != null) {
+//					System.out.println("previous node in direction of travel: "
+//							+ firstNodeOfRouteSegmentInDirectionOfTravel.getId());
+//				} else {
+//					System.out.println("previous node in direction of travel: null");
+//				}
 				firstNodeOfRouteSegmentInDirectionOfTravel = getOppositeEndNode(current,
 						firstNodeOfRouteSegmentInDirectionOfTravel);
+//				if (firstNodeOfRouteSegmentInDirectionOfTravel != null) {
+//					System.out.println(
+//							"next node in direction of travel: " + firstNodeOfRouteSegmentInDirectionOfTravel.getId());
+//				} else {
+//					System.out.println("next node in direction of travel: null");
+//				}
 
 				List<PTWay> nextWaysInDirectionOfTravel = this.findNextPTWaysInDirectionOfTravel(current,
@@ -551,7 +572,7 @@
 			List<RelationMember> originalRelationMembers = originalRelation.getMembers();
 			List<RelationMember> modifiedRelationMembers = new ArrayList<>();
-			
+
 			// copy stops first:
-			for (RelationMember rm: originalRelationMembers) {
+			for (RelationMember rm : originalRelationMembers) {
 				if (RouteUtils.isPTStop(rm)) {
 					if (rm.getRole().equals("stop_position")) {
@@ -568,28 +589,40 @@
 						modifiedRelationMembers.add(rm);
 					}
-				} 
-			}
-			
+				}
+			}
+
 			// copy PTWays next:
 			List<RelationMember> waysOfOriginalRelation = new ArrayList<>();
-			for (RelationMember rm: originalRelation.getMembers()) {
+			for (RelationMember rm : originalRelation.getMembers()) {
 				if (RouteUtils.isPTWay(rm)) {
 					waysOfOriginalRelation.add(rm);
 				}
 			}
-			
+
 			for (int i = 0; i < waysOfOriginalRelation.size(); i++) {
 				if (waysOfOriginalRelation.get(i).getWay() == wrongSegment.getPTWays().get(0).getWays().get(0)) {
-//				if (waysOfOriginalRelation.get(i) == wrongSegment.getPTWays().get(0)) {
-					modifiedRelationMembers.addAll(correctSegment.getPTWays());
+					// if (waysOfOriginalRelation.get(i) ==
+					// wrongSegment.getPTWays().get(0)) {
+					for (PTWay ptway : correctSegment.getPTWays()) {
+						if (ptway.getRole().equals("forward") || ptway.getRole().equals("backward")) {
+							modifiedRelationMembers.add(new RelationMember("", ptway.getMember()));
+						} else {
+							modifiedRelationMembers.add(ptway);
+						}
+					}
 					i = i + wrongSegment.getPTWays().size() - 1;
 				} else {
-					modifiedRelationMembers.add(waysOfOriginalRelation.get(i));
-				}
-			}
-
+					if (waysOfOriginalRelation.get(i).getRole().equals("forward")
+							|| waysOfOriginalRelation.get(i).getRole().equals("backward")) {
+						modifiedRelationMembers.add(new RelationMember("", waysOfOriginalRelation.get(i).getMember()));
+					} else {
+						modifiedRelationMembers.add(waysOfOriginalRelation.get(i));
+					}
+				}
+			}
 
 			modifiedRelation.setMembers(modifiedRelationMembers);
 			// TODO: change the data model too
+			wrongSegments.remove(testError);
 			ChangeCommand changeCommand = new ChangeCommand(originalRelation, modifiedRelation);
 			return changeCommand;
