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 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/PTAssistantPlugin.java	(revision 32871)
@@ -1,6 +1,4 @@
 //License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.plugins.pt_assistant;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 
 import javax.swing.JMenuItem;
@@ -11,5 +9,5 @@
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
-import org.openstreetmap.josm.gui.Notification;
+import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
 import org.openstreetmap.josm.plugins.Plugin;
 import org.openstreetmap.josm.plugins.PluginInformation;
@@ -17,4 +15,5 @@
 import org.openstreetmap.josm.plugins.pt_assistant.actions.RepeatLastFixAction;
 import org.openstreetmap.josm.plugins.pt_assistant.data.PTRouteSegment;
+import org.openstreetmap.josm.plugins.pt_assistant.gui.PTAssistantPreferenceSetting;
 import org.openstreetmap.josm.plugins.pt_assistant.validation.PTAssistantValidatorTest;
 
@@ -68,5 +67,13 @@
 		}
 	}
-	
+
+	/**
+	 * Sets up the pt_assistant tab in JOSM Preferences
+	 */
+	@Override
+	public PreferenceSetting getPreferenceSetting() {
+		return new PTAssistantPreferenceSetting();
+	}
+
 	public static PTRouteSegment getLastFix() {
 		return lastFix;
@@ -81,5 +88,5 @@
 	public static void setLastFix(PTRouteSegment segment) {
 		lastFix = segment;
-		
+
 		SwingUtilities.invokeLater(new Runnable() {
 			@Override
@@ -90,3 +97,12 @@
 	}
 
+	/**
+	 * Used in unit tests
+	 * 
+	 * @param segment
+	 */
+	public static void setLastFixNoGui(PTRouteSegment segment) {
+		lastFix = segment;
+	}
+
 }
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java	(revision 32871)
@@ -21,5 +21,4 @@
 	}
 
-
 	@Override
 	public void run() {
@@ -30,10 +29,20 @@
 				ArrayList<PrimitiveId> list = new ArrayList<>();
 
-				// add all route relations that are of public_transport version
-				// 2:
-				Collection<Relation> allRelations = Main.getLayerManager().getEditDataSet().getRelations();
-				for (Relation currentRelation : allRelations) {
-					if (RouteUtils.isTwoDirectionRoute(currentRelation)) {
-						list.add(currentRelation);
+				// if there are selected routes, try adding them first:
+				for (Relation currentSelectedRelation : Main.getLayerManager().getEditDataSet()
+						.getSelectedRelations()) {
+					if (RouteUtils.isTwoDirectionRoute(currentSelectedRelation)) {
+						list.add(currentSelectedRelation);
+					}
+				}
+
+				if (list.isEmpty()) {
+					// add all route relations that are of public_transport
+					// version 2:
+					Collection<Relation> allRelations = Main.getLayerManager().getEditDataSet().getRelations();
+					for (Relation currentRelation : allRelations) {
+						if (RouteUtils.isTwoDirectionRoute(currentRelation)) {
+							list.add(currentRelation);
+						}
 					}
 				}
@@ -68,7 +77,5 @@
 
 		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-
+			// do nothing in case the download was interrupted
 		}
 
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/RepeatLastFixAction.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/RepeatLastFixAction.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/RepeatLastFixAction.java	(revision 32871)
@@ -16,5 +16,5 @@
 
 	private static final long serialVersionUID = 2681464946469047054L;
-	
+
 	public RepeatLastFixAction() {
 		super(tr("Repeat last fix"), new ImageProvider("presets/transport", "bus.svg"), tr("Repeat last fix"),
@@ -26,17 +26,13 @@
 	@Override
 	public void actionPerformed(ActionEvent e) {
-		
-		System.out.println("in actionPerformed");
-		
+
 		if (!isEnabled() || !Main.isDisplayingMapView()) {
 			return;
 		}
-		
-		System.out.println("performing action");
-		
+
 		SegmentChecker.carryOutRepeatLastFix(PTAssistantPlugin.getLastFix());
-		
+
 		PTAssistantPlugin.setLastFix(null);
-		
+
 	}
 
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java	(revision 32871)
@@ -13,10 +13,10 @@
 	// indicates if the user needs to be asked before fetching incomplete
 	// members of a relation.
-	private enum ASK_TO_FETCH {
+	public enum ASK_TO_FETCH {
 		DO_ASK, DONT_ASK_AND_FETCH, DONT_ASK_AND_DONT_FETCH
 	};
 
 	// by default, the user should be asked
-	private static ASK_TO_FETCH askToFetch = ASK_TO_FETCH.DO_ASK;
+	public static ASK_TO_FETCH askToFetch;
 
 	String message;
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/ProceedDialog.java	(revision 32871)
@@ -19,10 +19,10 @@
 	private static final long serialVersionUID = 2986537034076698693L;
 
-	private enum ASK_TO_PROCEED {
+	public enum ASK_TO_PROCEED {
 		DO_ASK, DONT_ASK_AND_FIX_AUTOMATICALLY, DONT_ASK_AND_FIX_MANUALLY, DONT_ASK_AND_DONT_FIX
 	};
 
 	// by default, the user should be asked
-	private static ASK_TO_PROCEED askToProceed = ASK_TO_PROCEED.DO_ASK;
+	public static ASK_TO_PROCEED askToProceed;
 
 	private JRadioButton radioButtonFixAutomatically;
@@ -43,5 +43,5 @@
 		label1.setAlignmentX(Component.LEFT_ALIGNMENT);
 
-		if (numberOfDirectionErrors != 0) {
+		if (true) {
 			JLabel label2 = new JLabel("     " + trn("{0} direction error", "{0} direction errors", numberOfDirectionErrors, numberOfDirectionErrors));
 			panel.add(label2);
@@ -67,5 +67,5 @@
 		fixOptionButtonGroup.add(radioButtonDontFix);
 		panel.add(radioButtonFixAutomatically);
-		panel.add(radioButtonFixManually);
+//		panel.add(radioButtonFixManually);
 		panel.add(radioButtonDontFix);
 		radioButtonFixAutomatically.setAlignmentX(Component.LEFT_ALIGNMENT);
Index: /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/NodeChecker.java	(revision 32871)
@@ -85,5 +85,5 @@
 	/**
 	 * Checks if the given stop_position node belongs to any stop_area relation
-	 * 
+	 * @author xamanu
 	 * @param n
 	 */
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 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssistantValidatorTest.java	(revision 32871)
@@ -11,4 +11,5 @@
 import javax.swing.SwingUtilities;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.Command;
 import org.openstreetmap.josm.command.SelectCommand;
@@ -23,5 +24,4 @@
 import org.openstreetmap.josm.data.validation.Test;
 import org.openstreetmap.josm.data.validation.TestError;
-import org.openstreetmap.josm.gui.Notification;
 import org.openstreetmap.josm.plugins.pt_assistant.PTAssistantPlugin;
 import org.openstreetmap.josm.plugins.pt_assistant.actions.FixTask;
@@ -82,6 +82,8 @@
 			nodeChecker.performSolitaryStopPositionTest();
 
-			// check if stop positions are in any stop_area relation:
-			nodeChecker.performNodePartOfStopAreaTest();
+			if (Main.pref.getBoolean("pt_assistant.stop-area-tests", true) == true) {
+				// check if stop positions are in any stop_area relation:
+				nodeChecker.performNodePartOfStopAreaTest();
+			}
 
 		}
@@ -93,6 +95,9 @@
 			nodeChecker.performPlatformPartOfWayTest();
 
-			// check if platforms are in any stop_area relation:
-			nodeChecker.performNodePartOfStopAreaTest();
+			if (Main.pref.getBoolean("pt_assistant.stop-area-tests", true) == true) {
+				// check if platforms are in any stop_area relation:
+				nodeChecker.performNodePartOfStopAreaTest();
+			}
+
 		}
 
@@ -105,5 +110,5 @@
 
 		// Do some testing on stop area relations
-		if (StopUtils.isStopArea(r)) {
+		if (Main.pref.getBoolean("pt_assistant.stop-area-tests", true) == true && StopUtils.isStopArea(r)) {
 
 			StopChecker stopChecker = new StopChecker(r, this);
@@ -144,15 +149,17 @@
 		// type test:
 		WayChecker wayChecker = new WayChecker(r, this);
-		if (!r.hasIncompleteMembers()) {
-			wayChecker.performDirectionTest();
-			wayChecker.performRoadTypeTest();
-		}
+		wayChecker.performDirectionTest();
+		wayChecker.performRoadTypeTest();
 		this.errors.addAll(wayChecker.getErrors());
 
-		if (this.errors.isEmpty()) {
-			proceedWithSorting(r);
-		} else {
-			this.proceedAfterWayCheckerErrors(r);
-		}
+		proceedWithSorting(r);
+
+		// This allows to modify the route before the sorting and
+		// SegmentChecker are carried out:
+		// if (this.errors.isEmpty()) {
+		// proceedWithSorting(r);
+		// } else {
+		// this.proceedAfterWayCheckerErrors(r);
+		// }
 
 	}
@@ -220,4 +227,12 @@
 	private int showIncompleteMembersDownloadDialog() throws InterruptedException {
 
+		if (Main.pref.getBoolean("pt_assistant.download-incomplete", false) == true) {
+			return JOptionPane.YES_OPTION;
+		}
+
+		if (Main.pref.getBoolean("pt_assistant.download-incomplete", false) == false) {
+			return JOptionPane.NO_OPTION;
+		}
+
 		IncompleteMembersDownloadDialog incompleteMembersDownloadDialog = new IncompleteMembersDownloadDialog();
 		return incompleteMembersDownloadDialog.getUserSelection();
@@ -226,7 +241,10 @@
 
 	/**
-	 * Gets user input after errors were detected by WayChecker (direction
-	 * errors and road type errors)
-	 */
+	 * Gets user input after errors were detected by WayChecker. Although this
+	 * method is not used in the current implementation, it can be used to fix
+	 * errors from the previous testing stage and modify the route before the
+	 * second stage of testing is carried out.
+	 */
+	@SuppressWarnings("unused")
 	private void proceedAfterWayCheckerErrors(Relation r) {
 
@@ -258,10 +276,9 @@
 					@Override
 					public void run() {
-						userInput[0] = showProceedDialog(idParameter, roadTypeErrorParameter, roadTypeErrorParameter);
+						userInput[0] = showProceedDialog(idParameter, directionErrorParameter, roadTypeErrorParameter);
 
 					}
 				});
 			} catch (InvocationTargetException | InterruptedException e1) {
-				// TODO Auto-generated catch block
 				e1.printStackTrace();
 			}
@@ -276,5 +293,4 @@
 
 		if (userInput[0] == 1) {
-			// TODO
 			JOptionPane.showMessageDialog(null, "This is not implemented yet!");
 			return;
@@ -282,5 +298,4 @@
 
 		if (userInput[0] == 2) {
-			// TODO: should the errors be removed from the error list?
 			proceedWithSorting(r);
 		}
@@ -292,4 +307,16 @@
 
 	private int showProceedDialog(long id, int numberOfDirectionErrors, int numberOfRoadTypeErrors) {
+
+		if (numberOfDirectionErrors == 0 && numberOfDirectionErrors == 0) {
+			return 2;
+		}
+
+		if (Main.pref.getBoolean("pt_assistant.proceed-without-fix", true) == false) {
+			return 0;
+		}
+
+		if (Main.pref.getBoolean("pt_assistant.proceed-without-fix", true) == true) {
+			return 2;
+		}
 
 		ProceedDialog proceedDialog = new ProceedDialog(id, numberOfDirectionErrors, numberOfRoadTypeErrors);
@@ -322,7 +349,6 @@
 		if (!routeCheckerErrors.isEmpty()) {
 			// Variant 2
-			// If there is only the sorting error, add it and stop testing.
+			// If there is only the sorting error, add it
 			this.errors.addAll(routeChecker.getErrors());
-			// return;
 		}
 
@@ -337,4 +363,10 @@
 	}
 
+	/**
+	 * Carries out the stop-by-stop testing which includes building the route
+	 * data model.
+	 * 
+	 * @param r route relation
+	 */
 	private void proceedAfterSorting(Relation r) {
 
@@ -409,5 +441,8 @@
 		return false;
 	}
-
+	
+	/**
+	 * Fixes the given error
+	 */
 	@Override
 	public Command fixError(TestError testError) {
@@ -425,5 +460,5 @@
 
 		if (testError.getCode() == ERROR_CODE_ROAD_TYPE || testError.getCode() == ERROR_CODE_CONSTRUCTION) {
-			commands.add(WayChecker.fixErrorByRemovingWay(testError));
+			commands.add(WayChecker.fixErrorByZooming(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 32870)
+++ /applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentChecker.java	(revision 32871)
@@ -103,4 +103,13 @@
 		correctSegments.add(segment);
 	}
+	
+	/**
+	 * Used for unit tests
+	 * @param error
+	 * @return
+	 */
+	protected static PTRouteSegment getWrongSegment(TestError error) {
+		return wrongSegments.get(error);
+	}
 
 	public void performFirstStopTest() {
@@ -908,5 +917,5 @@
 		wrongSegment.setPTWays(fix);
 		addCorrectSegment(wrongSegment);
-		PTAssistantPlugin.setLastFix(wrongSegment);
+		PTAssistantPlugin.setLastFixNoGui(wrongSegment);
 
 		// get ways for the fix:
@@ -1014,14 +1023,10 @@
 	public static void carryOutRepeatLastFix(PTRouteSegment segment) {
 		
-		System.out.println("last fix relation: " + segment.getRelation().getId());
 		List<TestError> wrongSegmentsToRemove = new ArrayList<>();
 		
-		int counter = 0;
 		// find all wrong ways that have the same segment:
 		for (TestError testError: wrongSegments.keySet()) {
 			PTRouteSegment wrongSegment = wrongSegments.get(testError);
 			if (wrongSegment.getFirstWay() == segment.getFirstWay() && wrongSegment.getLastWay() == segment.getLastWay()) {
-				counter++;
-				System.out.println("wrong segment: " + wrongSegment.getRelation().getId());
 				// modify the route:
 				Relation originalRelation = wrongSegment.getRelation();
@@ -1049,10 +1054,12 @@
 		}
 		
-		System.out.println("wrong segments found: " + counter);
-		System.out.println();
-		
-		
-		
-		
+	}
+	
+	/**
+	 * Resets the static list variables (used for unit testing)
+	 */
+	protected static void reset() {
+		correctSegments.clear();
+		wrongSegments.clear();
 	}
 
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/AbstractTest.java	(revision 32871)
@@ -54,6 +54,6 @@
  public static final String PATH_TO_STOP_AREA_MANY_PLATFORMS = "test/data/stop-area-many-platforms.osm";
 
- 
  public static final String PATH_TO_SEGMENT_TEST = "test/data/segment-test.osm";
+ public static final String PATH_TO_REPEAT_FIX = "test/data/repeat-fix.osm";
 
   /**
Index: /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java
===================================================================
--- /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java	(revision 32870)
+++ /applications/editors/josm/plugins/pt_assistant/test/unit/org/openstreetmap/josm/plugins/pt_assistant/validation/SegmentCheckerTest.java	(revision 32871)
@@ -13,16 +13,15 @@
 
 public class SegmentCheckerTest extends AbstractTest {
-	
+
 	@Test
-	public void test() {
-		
-		
+	public void testStopByStopTest() {
+
 		File file = new File(AbstractTest.PATH_TO_SEGMENT_TEST);
 		DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
 		PTAssistantValidatorTest test = new PTAssistantValidatorTest();
-		
+
 		Relation route = null;
-		
-		for (Relation r: ds.getRelations()) {
+
+		for (Relation r : ds.getRelations()) {
 			if (RouteUtils.isTwoDirectionRoute(r)) {
 				route = r;
@@ -30,13 +29,55 @@
 			}
 		}
-		
+
+		SegmentChecker.reset();
 		SegmentChecker segmentChecker = new SegmentChecker(route, test);
 		segmentChecker.performStopByStopTest();
 		assertEquals(SegmentChecker.getCorrectSegmentCount(), 27);
 		assertEquals(segmentChecker.getErrors().size(), 0);
-		
-		
-		
-		
+	}
+
+	/**
+	 * Tests the stop-by-stop test
+	 */
+	@Test
+	public void testRepeatLastFix() {
+		File file = new File(AbstractTest.PATH_TO_REPEAT_FIX);
+		DataSet ds = ImportUtils.importOsmFile(file, "testLayer");
+		PTAssistantValidatorTest test = new PTAssistantValidatorTest();
+
+		Relation route123 = null;
+		Relation route130 = null;
+		Relation route168 = null;
+		Relation route184 = null;
+
+		for (Relation r : ds.getRelations()) {
+			if (r.getId() == 5379737) {
+				route123 = r;
+			} else if (r.getId() == 5379738) {
+				route130 = r;
+			} else if (r.getId() == 5379739) {
+				route168 = r;
+			} else if (r.getId() == 5379740) {
+				route184 = r;
+			}
+		}
+
+		SegmentChecker.reset();
+		SegmentChecker segmentChecker123 = new SegmentChecker(route123, test);
+		SegmentChecker segmentChecker130 = new SegmentChecker(route130, test);
+		SegmentChecker segmentChecker168 = new SegmentChecker(route168, test);
+		SegmentChecker segmentChecker184 = new SegmentChecker(route184, test);
+		segmentChecker123.performStopByStopTest();
+//		TestError error123 = segmentChecker123.getErrors().get(0);
+//		PTRouteSegment wrongSegment123 = SegmentChecker.getWrongSegment(error123);
+		segmentChecker130.performStopByStopTest();
+		segmentChecker168.performStopByStopTest();
+		segmentChecker184.performStopByStopTest();
+
+		// Check the error number:
+		assertEquals(segmentChecker123.getErrors().size(), 1);
+		assertEquals(segmentChecker130.getErrors().size(), 1);
+		assertEquals(segmentChecker168.getErrors().size(), 1);
+		assertEquals(segmentChecker184.getErrors().size(), 0);
 	}
 }
