Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 23758)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 23759)
@@ -63,4 +63,5 @@
 		ComponentListener {
 
+	private static final String EMPTY_DATA_STRING = "-";
 	/**
 	 * 
@@ -246,10 +247,8 @@
 	public void setModel(IElevationProfile model) {
 		if (this.profile != model) {
-			if (model != null) {
-				// System.out.println("Set model " + model);
-				this.profile = model;
-				profPanel.setElevationModel(model);
-				updateView();
-			}
+			this.profile = model;
+			profPanel.setElevationModel(model);
+			
+			updateView();
 		}
 	}
@@ -282,13 +281,9 @@
 	 */
 	private void updateView() {
-		if (profile == null) { // emergency exit
-			setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
-			return;
-		}
-		
-		// Show name of profile in title 
-		setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
-		
-		if (profile.hasElevationData()) {
+		if (profile != null) {
+			// Show name of profile in title 
+			setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
+
+			if (profile.hasElevationData()) {
 			// Show elevation data
 			minHeightLabel.setText(
@@ -300,21 +295,26 @@
 			elevationGainLabel.setText(
 					NavigatableComponent.getSystemOfMeasurement().getDistText(profile.getGain()));
-		} else { // no elevation data
-			minHeightLabel.setText("-");
-			maxHeightLabel.setText("-");
-			avrgHeightLabel.setText("-");
-			elevationGainLabel.setText("-");
-		}
-
-		// compute values for time and distance
-		long diff = profile.getTimeDifference();
-		long minutes = diff / (1000 * 60);
-		long hours = minutes / 60;
-		minutes = minutes % 60;
-		
-		double dist = profile.getDistance();
-
-		totalTimeLabel.setText(String.format("%d:%d h", hours, minutes));
-		distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
+			}
+			
+			// compute values for time and distance
+			long diff = profile.getTimeDifference();
+			long minutes = diff / (1000 * 60);
+			long hours = minutes / 60;
+			minutes = minutes % 60;
+			
+			double dist = profile.getDistance();
+
+			totalTimeLabel.setText(String.format("%d:%d h", hours, minutes));
+			distLabel.setText(NavigatableComponent.getSystemOfMeasurement().getDistText(dist));
+		} else { // no elevation data, -> switch back to empty view
+			setTitle(String.format("%s: (No data)", tr("Elevation Profile")));
+			
+			minHeightLabel.setText(EMPTY_DATA_STRING);
+			maxHeightLabel.setText(EMPTY_DATA_STRING);
+			avrgHeightLabel.setText(EMPTY_DATA_STRING);
+			elevationGainLabel.setText(EMPTY_DATA_STRING);
+			totalTimeLabel.setText(EMPTY_DATA_STRING);
+			distLabel.setText(EMPTY_DATA_STRING);
+		}
 		
 		fireModelChanged();
@@ -414,5 +414,4 @@
 			}
 			
-			System.out.println("Active layer: " + newLayer.getName());
 			ElevationModel em = layerMap.get(newLayer);
 			em.setSliceSize(slices);
@@ -424,5 +423,4 @@
 	public void layerAdded(Layer newLayer) {
 		createLayer(newLayer);
-		System.out.println("layerAdded: " + newLayer.getName());
 	}
 
@@ -432,5 +430,8 @@
 			layerMap.remove(oldLayer);
 		}
-
+		if (layerMap.size() == 0) {
+			setModel(null);
+			profileLayer.setProfile(null);
+		}
 	}
 
Index: /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java
===================================================================
--- /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 23758)
+++ /applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 23759)
@@ -158,6 +158,6 @@
 		int index = 0;
 
-		if (profile != null) {
-			renderer.beginRendering();
+		renderer.beginRendering();
+		if (profile != null) {			
 			for (WayPoint wpt : profile.getWayPoints()) {
 				int ele = (int) WayPointHelper.getElevation(wpt);
@@ -206,7 +206,5 @@
 			renderer.renderWayPoint(g, profile, mv, profile.getMinWayPoint(),
 					ElevationWayPointKind.MinElevation);
-		} else {
-			System.err.println("Layer#paint: No profile");
-		}
+		} 
 		
 		renderer.finishRendering();
