Index: applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java
===================================================================
--- applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java	(revision 19084)
+++ applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputDialog.java	(revision 19085)
@@ -1,4 +1,8 @@
 /**
- * 
+ * Terracer: A JOSM Plugin for terraced houses.
+ *
+ * Copyright 2009 CloudMade Ltd.
+ *
+ * Released under the GPLv2, see LICENSE file for details.
  */
 package terracer;
@@ -30,5 +34,6 @@
  * Created with the Eclipse Visual Editor.
  * 
- *  This dialog is concerned with the layout.
+ *  This dialog is concerned with the layout, all logic goes into the
+ *  HouseNumberinputHandler class.
  * 
  * @author casualwalker
@@ -256,4 +261,9 @@
 	}
 
+	/**
+	 * Registers the handler as a listener to all relevant events.
+	 * 
+	 * @param handler the handler
+	 */
 	public void addHandler(HouseNumberInputHandler handler) {
 		this.hi.addActionListener(handler);
Index: applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java
===================================================================
--- applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java	(revision 19084)
+++ applications/editors/josm/plugins/terracer/src/terracer/HouseNumberInputHandler.java	(revision 19085)
@@ -1,4 +1,8 @@
 /**
- * 
+ * Terracer: A JOSM Plugin for terraced houses.
+ *
+ * Copyright 2009 CloudMade Ltd.
+ *
+ * Released under the GPLv2, see LICENSE file for details.
  */
 package terracer;
@@ -27,5 +31,5 @@
  * From a refactoring viewpoint, this class is indeed more interested in the fields
  * of the HouseNumberInputDialog. This is desired design, as the HouseNumberInputDialog 
- * is already cluttered with auto-generated layout code.  
+ * is already cluttered with auto-generated layout code.
  * 
  * @author casualwalker
@@ -34,10 +38,17 @@
 		ActionListener, FocusListener {
 
-	TerracerAction terracerAction;
-	Way way;
-	HouseNumberInputDialog dialog;
-
-	public HouseNumberInputHandler(TerracerAction terracerAction, Way way,
-			String title) {
+	private TerracerAction terracerAction;
+	private Way way;
+	private HouseNumberInputDialog dialog;
+
+	/**
+	 * Instantiates a new house number input handler.
+	 * 
+	 * @param terracerAction the terracer action
+	 * @param way the way
+	 * @param title the title
+	 */
+	public HouseNumberInputHandler(final TerracerAction terracerAction,
+			final Way way, final String title) {
 		this.terracerAction = terracerAction;
 		this.way = way;
@@ -50,4 +61,11 @@
 	}
 
+	/**
+	 * Validate the current input fields.
+	 * When the validation fails, a red message is 
+	 * displayed and the OK button is disabled.
+	 * 
+	 * Should be triggered each time the input changes.
+	 */
 	private void validateInput() {
 		boolean isOk = true;
@@ -58,14 +76,18 @@
 		isOk = isOk && checkSegments(message);
 		isOk = isOk
-				&& checkNumberStringField(dialog.lo, "Lowest number", message);
+				&& checkNumberStringField(dialog.lo, tr("Lowest number"),
+						message);
 		isOk = isOk
-				&& checkNumberStringField(dialog.hi, "Highest number", message);
+				&& checkNumberStringField(dialog.hi, tr("Highest number"),
+						message);
 		isOk = isOk
-				&& checkNumberStringField(dialog.segments, "Segments", message);
+				&& checkNumberStringField(dialog.segments, tr("Segments"),
+						message);
 
 		if (isOk) {
 			dialog.okButton.setEnabled(true);
 			dialog.messageLabel.setForeground(Color.black);
-			dialog.messageLabel.setText(HouseNumberInputDialog.DEFAULT_MESSAGE);
+			dialog.messageLabel
+					.setText(tr(HouseNumberInputDialog.DEFAULT_MESSAGE));
 
 		} else {
@@ -76,10 +98,19 @@
 	}
 
-	private boolean checkNumberOrder(StringBuffer message) {
+	/**
+	 * Checks, if the lowest house number is indeed lower than the 
+	 * highest house number.
+	 * This check applies only, if the house number fields are used at all. 
+	 * 
+	 * @param message the message
+	 * 
+	 * @return true, if successful
+	 */
+	private boolean checkNumberOrder(final StringBuffer message) {
 		if (numberFrom() != null && numberTo() != null) {
 			if (numberFrom().intValue() > numberTo().intValue()) {
 				appendMessageNewLine(message);
 				message
-						.append("Lowest housenumber cannot be higher than highest housenumber");
+						.append(tr("Lowest housenumber cannot be higher than highest housenumber"));
 				return false;
 			}
@@ -88,17 +119,32 @@
 	}
 
-	private boolean checkSegmentsFromHousenumber(StringBuffer message) {
+	/**
+	 * Obtain the number segments from the house number fields and check, 
+	 * if they are valid.
+	 * 
+	 * Also disables the segments field, if the house numbers contain
+	 * valid information.
+	 * 
+	 * @param message the message
+	 * 
+	 * @return true, if successful
+	 */
+	private boolean checkSegmentsFromHousenumber(final StringBuffer message) {
 		dialog.segments.setEditable(true);
 
 		if (numberFrom() != null && numberTo() != null) {
+
 			int segments = numberTo().intValue() - numberFrom().intValue();
 
 			if (segments % stepSize() != 0) {
 				appendMessageNewLine(message);
-				message.append("Housenumbers do not match odd/even setting");
+				message
+						.append(tr("Housenumbers do not match odd/even setting"));
 				return false;
 			}
 
 			int steps = segments / stepSize();
+			steps++; // difference 0 means 1 building, see
+			// TerracerActon.terraceBuilding
 			dialog.segments.setText(String.valueOf(steps));
 			dialog.segments.setEditable(false);
@@ -108,8 +154,16 @@
 	}
 
-	private boolean checkSegments(StringBuffer message) {
+	/**
+	 * Check the number of segments.
+	 * It must be a number and greater than 1. 
+	 * 
+	 * @param message the message
+	 * 
+	 * @return true, if successful
+	 */
+	private boolean checkSegments(final StringBuffer message) {
 		if (segments() == null || segments().intValue() < 1) {
 			appendMessageNewLine(message);
-			message.append("Segment must be a number greater 1");
+			message.append(tr("Segment must be a number greater 1"));
 			return false;
 
@@ -127,7 +181,7 @@
 	 * @return true, if successful
 	 */
-	private boolean checkNumberStringField(JTextField field, String label,
-			StringBuffer message) {
-		String content = field.getText();
+	private boolean checkNumberStringField(final JTextField field,
+			final String label, final StringBuffer message) {
+		final String content = field.getText();
 		if (content != null && !content.isEmpty()) {
 			try {
@@ -135,10 +189,10 @@
 				if (i < 0) {
 					appendMessageNewLine(message);
-					message.append(label + " must be greater than 0");
+					message.append(label + tr(" must be greater than 0"));
 					return false;
 				}
 			} catch (NumberFormatException e) {
 				appendMessageNewLine(message);
-				message.append(label + " is not a number");
+				message.append(label + tr(" is not a number"));
 				return false;
 			}
@@ -149,7 +203,9 @@
 
 	/**
-	 * @param message
-	 */
-	private void appendMessageNewLine(StringBuffer message) {
+	 * Append a new line to the message, if the message is not empty.
+	 * 
+	 * @param message the message
+	 */
+	private void appendMessageNewLine(final StringBuffer message) {
 		if (message.length() > 0) {
 			message.append("\n");
@@ -157,4 +213,7 @@
 	}
 
+	/* (non-Javadoc)
+	 * @see javax.swing.event.ChangeListener#stateChanged(javax.swing.event.ChangeEvent)
+	 */
 	@Override
 	public void stateChanged(ChangeEvent e) {
@@ -163,4 +222,7 @@
 	}
 
+	/* (non-Javadoc)
+	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
+	 */
 	@Override
 	public void itemStateChanged(ItemEvent e) {
@@ -168,7 +230,11 @@
 	}
 
-	@Override
-	public void actionPerformed(ActionEvent e) {
-
+	/* (non-Javadoc)
+	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+	 */
+	@Override
+	public void actionPerformed(final ActionEvent e) {
+
+		// OK or Cancel button-actions
 		if (e.getSource() instanceof JButton) {
 			JButton button = (JButton) e.getSource();
@@ -182,4 +248,5 @@
 			}
 		} else {
+			// anything else is a change in the input
 			validateInput();
 		}
@@ -187,8 +254,20 @@
 	}
 
+	/**
+	 * Calculate the step size between two house numbers,
+	 * based on the interpolation setting.
+	 * 
+	 * @return the stepSize (1 for all, 2 for odd /even)
+	 */
 	public int stepSize() {
-		return (dialog.interpolation.getSelectedItem() == tr("All")) ? 1 : 2;
-	}
-
+		return (dialog.interpolation.getSelectedItem().equals(tr("All"))) ? 1
+				: 2;
+	}
+
+	/**
+	 * Gets the number of segments, if set.
+	 * 
+	 * @return the number of segments or null, if not set / invalid.
+	 */
 	public Integer segments() {
 		try {
@@ -199,4 +278,9 @@
 	}
 
+	/**
+	 * Gets the lowest house number.
+	 * 
+	 * @return the number of lowest house number or null, if not set / invalid.
+	 */
 	public Integer numberFrom() {
 		try {
@@ -207,4 +291,9 @@
 	}
 
+	/**
+	 * Gets the highest house number.
+	 * 
+	 * @return the number of highest house number or null, if not set / invalid.
+	 */
 	public Integer numberTo() {
 		try {
@@ -215,4 +304,9 @@
 	}
 
+	/**
+	 * Gets the street name.
+	 * 
+	 * @return the  street name or null, if not set / invalid.
+	 */
 	public String streetName() {
 		// Object selected = street.getSelectedItem();
@@ -230,4 +324,7 @@
 	}
 
+	/* (non-Javadoc)
+	 * @see java.awt.event.FocusListener#focusGained(java.awt.event.FocusEvent)
+	 */
 	@Override
 	public void focusGained(FocusEvent e) {
@@ -235,4 +332,7 @@
 	}
 
+	/* (non-Javadoc)
+	 * @see java.awt.event.FocusListener#focusLost(java.awt.event.FocusEvent)
+	 */
 	@Override
 	public void focusLost(FocusEvent e) {
@@ -240,12 +340,3 @@
 	}
 
-	/**
-	 * Indicates, if house numbers should be used (instead of segments).
-	 * 
-	 * @return true, if if both number values are set to a number.
-	 */
-	private boolean useHouseNumbers() {
-		return numberFrom() != null && numberTo() != null;
-
-	}
 }
Index: applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java
===================================================================
--- applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java	(revision 19084)
+++ applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java	(revision 19085)
@@ -17,5 +17,4 @@
 import java.util.Collections;
 import java.util.LinkedList;
-import java.util.TreeSet;
 
 import javax.swing.JOptionPane;
@@ -80,39 +79,7 @@
 						title = tr("Nothing selected!");
 
-					// first ask the user how many buildings to terrace into
-					HouseNumberInputHandler handler = new HouseNumberInputHandler(
-							this, way, title);
-
-					// IntermediateInputDialog inputDialog = new
-					// IntermediateInputDialog(
-					// this, way);
-					// inputDialog.pack();
-					// inputDialog.setVisible(true);
-
-					// HouseNumberDialog dialog = new HouseNumberDialog(this);
-					// final JOptionPane optionPane = new JOptionPane(dialog,
-					// JOptionPane.PLAIN_MESSAGE,
-					// JOptionPane.OK_CANCEL_OPTION);
-					//
-					// String title = trn("Change {0} object",
-					// "Change {0} objects", sel.size(), sel.size());
-					// if (sel.size() == 0)
-					// title = tr("Nothing selected!");
-					//
-					// optionPane.createDialog(Main.parent, title)
-					// .setVisible(true);
-					// Object answerObj = optionPane.getValue();
-					// if (answerObj != null
-					// && answerObj != JOptionPane.UNINITIALIZED_VALUE
-					// && (answerObj instanceof Integer && (Integer) answerObj
-					// == JOptionPane.OK_OPTION)) {
-					//
-					// // call out to the method which does the actual
-					// // terracing.
-					// terraceBuilding(way, dialog.numberFrom(), dialog
-					// .numberTo(), dialog.stepSize(), dialog
-					// .streetName());
-					//
-					// }
+					// show input dialog.
+					new HouseNumberInputHandler(this, way, title);
+
 				} else {
 					badSelect = true;
@@ -149,7 +116,9 @@
 			nb = segments.intValue();
 		} else {
-			// TODO: we're in trouble.
-			// do exception handling.
-			nb = 0;
+			// if we get here, there is is a bug in the input validation.
+			throw new TerracerRuntimeException(
+					"Could not determine segments from parameters, this is a bug. "
+							+ "Parameters were: segments " + segments
+							+ " from " + from + " to " + to + " step " + step);
 		}
 
@@ -419,22 +388,4 @@
 
 	/**
-	 * Generates a list of all visible names of highways in order to do
-	 * autocompletion on the road name.
-	 * 
-	 * TODO: REMOVE this method here!
-	 */
-	TreeSet<String> createAutoCompletionInfo() {
-		final TreeSet<String> names = new TreeSet<String>();
-		for (OsmPrimitive osm : Main.main.getCurrentDataSet()
-				.allNonDeletedPrimitives()) {
-			if (osm.getKeys() != null && osm.keySet().contains("highway")
-					&& osm.keySet().contains("name")) {
-				names.add(osm.get("name"));
-			}
-		}
-		return names;
-	}
-
-	/**
 	 * Creates a new node at the interpolated position between the argument
 	 * nodes. Interpolates linearly in Lat/Lon coordinates.
Index: applications/editors/josm/plugins/terracer/src/terracer/TerracerRuntimeException.java
===================================================================
--- applications/editors/josm/plugins/terracer/src/terracer/TerracerRuntimeException.java	(revision 19085)
+++ applications/editors/josm/plugins/terracer/src/terracer/TerracerRuntimeException.java	(revision 19085)
@@ -0,0 +1,49 @@
+/**
+ * Terracer: A JOSM Plugin for terraced houses.
+ *
+ * Copyright 2009 CloudMade Ltd.
+ *
+ * Released under the GPLv2, see LICENSE file for details.
+ */
+package terracer;
+
+/**
+ * The Class TerracerRuntimeException indicates errors from the Terracer Plugin.
+ * 
+ * @author casualwalker
+ */
+public class TerracerRuntimeException extends RuntimeException {
+
+	/** The Constant serialVersionUID. */
+	private static final long serialVersionUID = 857926026580277816L;
+
+	/**
+	 * Default constructor.
+	 */
+	public TerracerRuntimeException() {
+		super();
+	}
+
+	/**
+	 * @param message
+	 * @param cause
+	 */
+	public TerracerRuntimeException(String message, Throwable cause) {
+		super(message, cause);
+	}
+
+	/**
+	 * @param message
+	 */
+	public TerracerRuntimeException(String message) {
+		super(message);
+	}
+
+	/**
+	 * @param cause
+	 */
+	public TerracerRuntimeException(Throwable cause) {
+		super(cause);
+	}
+
+}
