Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/ElevationMapMode.java	(revision 29948)
@@ -21,4 +21,5 @@
 import org.openstreetmap.josm.actions.mapmode.MapMode;
 import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 
 /**
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationModelListener.java	(revision 29948)
@@ -16,4 +16,5 @@
 
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationModel;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 
 /**
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/IElevationProfile.java	(revision 29947)
+++ 	(revision )
@@ -1,158 +1,0 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-
-package org.openstreetmap.josm.plugins.elevation;
-
-import java.util.Date;
-import java.util.List;
-
-import org.openstreetmap.josm.data.gpx.WayPoint;
-
-/**
- * @author Oliver Wieland <oliver.wieland@online.de>
- * Interface for an elevation profile providing special properties/values.
- */
-public interface IElevationProfile {
-	/**
-	 * Gets the slice size for the detail view.
-	 * @return
-	 */
-	public int getSliceSize();
-	
-	public void setSliceSize(int sliceSize);
-	
-	/**
-	 * Gets the name of the elevation profile.
-	 * @return
-	 */
-	public abstract String getName();
-	
-	/**
-	 * Gets the time stamp of first recorded track point.
-	 * @return
-	 */
-	public abstract Date getStart();
-
-	/**
-	 * Gets the time stamp of last recorded track point.
-	 * @return
-	 */
-	public abstract Date getEnd();
-	
-	/**
-	 * Gets the minimum elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getMinHeight();
-
-	/**
-	 * Gets the maximum elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getMaxHeight();
-	
-	/**
-	 * Gets the distance of the track in kilometers.
-	 */
-	public abstract double getDistance();
-	
-	/**
-	 * Gets the average elevation height of all tracks and routes.
-	 * @return
-	 */
-	public abstract int getAverageHeight();
-	
-	/**
-	 * Gets the difference between min and max elevation.
-	 * @return
-	 */
-	public int getHeightDifference();
-	
-	/**
-	 * Gets the elevation gain.
-	 * 
-	 * @return
-	 */
-	public int getGain();
-
-	/**
-	 * Gets the total number of way points (sum of all way points of all tracks and routes). 
-	 * @return
-	 */
-	public abstract int getNumberOfWayPoints();
-	
-	/**
-	 * Gets the list containing the way points.
-	 * @return
-	 */
-	public List<WayPoint> getWayPoints();
-	
-	/**
-	 * Gets the first recorded way point.
-	 * @return
-	 */
-	public WayPoint getStartWayPoint();
-	
-	/**
-	 * Gets the last recorded way point.
-	 * @return
-	 */
-	public WayPoint getEndWayPoint();
-	
-	/**
-	 * Gets the way point with the highest elevation value.
-	 * @return
-	 */
-	public WayPoint getMaxWayPoint();
-	
-	/**
-	 * Gets the way point with the lowest elevation value.
-	 * @return
-	 */
-	public WayPoint getMinWayPoint();
-	
-	/**
-	 * Gets a flag indicating whether the associated way points 
-	 * contained elevation data or not. This is the case if min
-	 * and max height are equal.
-	 * @return
-	 */
-	public boolean hasElevationData();
-
-	/**
-	 * Returns the time between start and end of the track.
-	 * @return
-	 */
-	public long getTimeDifference();
-	
-	/**
-	 * Gets the elevation value for at the given data index point.
-	 */
-	public int elevationValueAt(int i);
-	
-	/**
-	 * Gets the children of the segment (maybe null).
-	 */
-	public List<IElevationProfile> getChildren();
-	
-	/**
-	 * Gets the parent of the elevation profile.
-	 */
-	public IElevationProfile getParent();
-	
-	/**
-	 * Triggers model refresh.
-	 */
-	public void updateElevationData();
-}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationModel.java	(revision 29948)
@@ -24,50 +24,41 @@
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
-import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
 
 /**
  * Represents the top-level part of the elevation model. The elevation model
- * breaks done into the tracks/routes of a GPX file (see
- * {@link ElevationProfileNode}). Each track is divided into 'slices' (see
- * {@link ElevationProfileLeaf}) - a set of fixed number of way points. This
- * structure allows as well an overview over a single track as a detailed
- * elevation view of a track part.
+ * breaks done into the tracks/routes of a GPX file.
  * 
- * @see ElevationProfileNode
- * @see ElevationProfileLeaf
  * @see IElevationModelTrackListener
- * @see IElevationModelSliceListener
  * @author Oliver Wieland <oliver.wieland@online.de>
  */
-public class ElevationModel extends ElevationProfileBase implements IGpxVisitor {
+public class ElevationModel implements IGpxVisitor, IElevationModel {
 	// private int sliceSize;
 	private int trackCounter;
 	private GpxData gpxData;
 
-	private List<IElevationProfile> tracks;
-	private List<WayPoint> buffer = new ArrayList<WayPoint>(1000);
-	private List<WayPoint> tmpWaypoints = new ArrayList<WayPoint>(1000);
-
+	private WayPointMap children = new WayPointMap(); 
 	private List<IElevationModelListener> listeners = new ArrayList<IElevationModelListener>();
-
+	private List<WayPoint> buffer = new ArrayList<WayPoint>();
+	private int currentProfileIndex = 0;
+	
+
+	/**
+	 * Instantiates a new elevation model.
+	 */
 	public ElevationModel() {
-		this("", null, 100);
-	}
-
-	public ElevationModel(String name, GpxData data, int sliceSize) {
-		super(name);
+		this("", null);
+	}
+
+	/**
+	 * Instantiates a new elevation model.
+	 *
+	 * @param name the name of the model
+	 * @param data the GPX data
+	 */
+	public ElevationModel(String name, GpxData data) {
 		gpxData = data;
-		setSliceSize(Math.max(sliceSize, 100));
-	}
-
-	@Override
-	public void setSliceSize(int sliceSize) {
-
-		super.setSliceSize(sliceSize);
-
-		// FIXME: Listener should go in base class
-		updateElevationData();
-		fireModelChanged();
+		
+		GpxIterator.visit(data, this);		
 	}
 
@@ -84,17 +75,6 @@
 	 * @return the tracks
 	 */
-	protected List<IElevationProfile> getTracks() {
-		return tracks;
-	}
-
-	/**
-	 * Gets a flag indicating whether the associated way points contained
-	 * elevation data or not. This is the case if min and max height or both
-	 * zero.
-	 * 
-	 * @return
-	 */
-	public boolean hasElevationData() {
-		return getMaxHeight() != getMinHeight();
+	protected WayPointMap getTracks() {
+		return children;
 	}
 
@@ -102,69 +82,33 @@
 	 * Fires the 'model changed' event to all listeners.
 	 */
-	protected void fireModelChanged() {
+	protected void fireModelChanged() {	    	
 		for (IElevationModelListener listener : listeners) {
-			listener.elevationProfileChanged(this);
+		    if (children != null && children.size() > 0)
+			listener.elevationProfileChanged(getCurrentProfile());
 		}
 	}
 
-	/**
-	 * Adds a model listener to this instance.
-	 * 
-	 * @param listener
-	 *            The listener to add.
-	 */
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#addModelListener(org.openstreetmap.josm.plugins.elevation.IElevationModelListener)
+	 */
+	@Override
 	public void addModelListener(IElevationModelListener listener) {
 		this.listeners.add(listener);
 	}
 
-	/**
-	 * Removes a model listener from this instance.
-	 * 
-	 * @param listener
-	 *            The listener to remove.
-	 */
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#removeModelListener(org.openstreetmap.josm.plugins.elevation.IElevationModelListener)
+	 */
+	@Override
 	public void removeModelListener(IElevationModelListener listener) {
 		this.listeners.remove(listener);
 	}
 
-	/**
-	 * Removes all listeners from this instance.
-	 */
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#removeAllListeners()
+	 */
+	@Override
 	public void removeAllListeners() {
 		this.listeners.clear();
-	}
-
-	/**
-	 * (Re)computes the elevation model.
-	 */
-	private void computeProfile() {
-		if (gpxData == null)
-			return; // nothing to do
-
-		trackCounter = 0;
-
-		super.updateValues();
-		if (tracks == null) {
-			tracks = new ArrayList<IElevationProfile>();
-		} else {
-			tmpWaypoints.clear();
-			buffer.clear();
-			tracks.clear();
-		}
-
-		setDistance(gpxData.length());	// get distance from GPX 
-		GpxIterator.visit(gpxData, this);
-
-		// reduce data
-		setWayPoints(ElevationHelper.downsampleWayPoints(tmpWaypoints,
-				getSliceSize()), false);
-	}
-
-	/**
-	 * Forces the model to refresh itself. Clients (e. g. UI widgets) may use
-	 * this method to notify the model on UI changes.
-	 */
-	public void updateElevationData() {
-		computeProfile();
 	}
 
@@ -189,4 +133,5 @@
 	 */
 	public void visit(GpxTrack track, GpxTrackSegment segment, WayPoint wp) {
+	    	// we ignore the segment here 
 		processWayPoint(wp);
 	}
@@ -197,10 +142,9 @@
 	@Override
 	public void visit(WayPoint wp) {
-		super.visit(wp);
 		processWayPoint(wp);
 	}
 
 	public void start() {
-		buffer.clear();
+		children.clear();		
 	}
 
@@ -211,11 +155,14 @@
 	
 	private void addTrackOrRoute(String trackName) {
-		if (getSliceSize() > 0) {
-			ElevationProfileNode emt = new ElevationProfileNode(trackName,
-					this, buffer, getSliceSize());
-			tracks.add(emt);
-		}
-		trackCounter++;
-		buffer.clear();
+	    	if (buffer.size() > 0) {
+	    	    
+	    	    	System.out.println("Add track " + trackName + ", n =  " + buffer.size()); // TODO: Remove
+	    	    	
+        	    	ElevationProfileBase ep = new ElevationProfileBase(trackName);
+        		ep.setWayPoints(buffer);
+        		ep.setName(trackName);
+        		children.add(ep);
+        		buffer.clear();
+	    	}
 	}
 
@@ -226,17 +173,44 @@
 		
 		buffer.add(wp);
-		tmpWaypoints.add(wp);
-	}
-
-	/*
-	 * (non-Javadoc)
-	 * 
-	 * @see
-	 * org.openstreetmap.josm.plugins.elevation.ElevationProfileBase#getChildren
-	 * ()
-	 */
-	@Override
-	public List<IElevationProfile> getChildren() {
-		return tracks;
+	}
+
+	
+	/* (non-Javadoc)
+	 * @see org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel#getProfiles()
+	 */
+	@Override
+	public List<IElevationProfile> getProfiles() {
+		return children;
+	}
+
+	@Override
+	public IElevationProfile getCurrentProfile() {
+	    if (currentProfileIndex < 0 || currentProfileIndex >= profileCount()) return null;
+	    
+	    return children.get(currentProfileIndex);
+	}
+
+	@Override
+	public void setCurrentProfile(IElevationProfile newProfile) {
+	    CheckParameterUtil.ensureParameterNotNull(newProfile);
+	    
+	    if (!children.contains(newProfile)) {
+		children.add(newProfile);
+	    }
+	    
+	    setCurrentProfile(children.indexOf(newProfile)); 
+	}
+
+	@Override
+	public void setCurrentProfile(int index) {
+	    if (index < 0 || index >= profileCount()) throw new RuntimeException("Invalid arg for setCurrentProfile: " + index + ", value must be 0.." + profileCount());
+	    
+	    currentProfileIndex = index;
+	    fireModelChanged();	    
+	}
+
+	@Override
+	public int profileCount() {
+	    return children != null ? children.size() : 0;
 	}
 }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileBase.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileBase.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileBase.java	(revision 29948)
@@ -20,5 +20,4 @@
 
 import org.openstreetmap.josm.data.gpx.WayPoint;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 
@@ -43,5 +42,5 @@
  * 
  */
-public abstract class ElevationProfileBase implements IElevationProfile,
+public class ElevationProfileBase implements IElevationProfile,
 		IGpxWaypointVisitor {
 	public static final int WAYPOINT_START = 0;
@@ -62,5 +61,4 @@
 	private List<WayPoint> wayPoints;
 	private int numWayPoints; // cached value
-	private int sliceSize;
 	private int gain;
 	private int lastEle;
@@ -93,6 +91,5 @@
 		this.name = name;
 		this.parent = parent;
-		this.sliceSize = sliceSize;
-		setWayPoints(wayPoints, true);
+		setWayPoints(wayPoints);
 	}
 
@@ -225,11 +222,10 @@
 	 * @param wayPoints
 	 */
-	public void setWayPoints(List<WayPoint> wayPoints, boolean revisit) {
+	public void setWayPoints(List<WayPoint> wayPoints) {
 		if (this.wayPoints != wayPoints) {
 			this.wayPoints = new ArrayList<WayPoint>(wayPoints);
 			numWayPoints = wayPoints != null ? wayPoints.size() : 0;
-			if (revisit) {				
-				updateValues();
-			}
+			updateValues();
+			
 		}
 	}
@@ -263,22 +259,4 @@
 	}
 
-	/**
-	 * Gets the slice size for the detail view.
-	 * 
-	 * @return
-	 */
-	public int getSliceSize() {
-		return sliceSize;
-	}
-
-	/**
-	 * Sets the desired size of the elevation profile.
-	 */
-	public void setSliceSize(int sliceSize) {
-		if (this.sliceSize != sliceSize) {
-			this.sliceSize = sliceSize;
-		}
-	}
-
 	/*
 	 * (non-Javadoc)
@@ -298,5 +276,7 @@
 	 * org.openstreetmap.josm.plugins.elevation.IElevationProfile#getChildren()
 	 */
-	public abstract List<IElevationProfile> getChildren();
+	public List<IElevationProfile> getChildren() {
+	    return null;
+	}
 
 	/*
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileLeaf.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileLeaf.java	(revision 29947)
+++ 	(revision )
@@ -1,64 +1,0 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-package org.openstreetmap.josm.plugins.elevation.gpx;
-
-import java.util.List;
-
-import org.openstreetmap.josm.data.gpx.WayPoint;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
-import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
-
-/**
- * This class represents a 'leaf node' in the elevation profile tree. It has no children and ignores
- * the slice size parameter. So no data reduction takes places; every way point is kept.   
- * 
- * ElevationModelSlice is intended to be used internally.
- * @author Oliver Wieland <oliver.wieland@online.de>
- *
- */
-public class ElevationProfileLeaf extends ElevationProfileBase {
-	/**
-	 * Creates a name elevation profile leaf with a given set of way points.
-	 * @param name The name of the profile.
-	 * @param parent The (optional) parent profile.
-	 * @param wayPoints The list containing the way points of the profile.
-	 */
-	public ElevationProfileLeaf(String name, IElevationProfile parent, List<WayPoint> wayPoints) {
-		super(name, parent, wayPoints, 0);		
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationProfile#elevationValueAt(int)
-	 */
-	@Override
-	public int elevationValueAt(int i) {
-		if (i < 0 || i >= getNumberOfWayPoints()) throw new IndexOutOfBoundsException("Wrong index: " + i);
-		return (int)ElevationHelper.getElevation(getWayPoints().get(i));
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.IElevationProfile#getChildren()
-	 */
-	@Override
-	public List<IElevationProfile> getChildren() {
-		return null; // we have no children
-	}
-	
-	@Override
-	public String toString() {
-		return "ElevationModelSlice [avrgEle=" + getAverageHeight() + ", maxEle=" + getMaxHeight()
-				+ ", minEle=" + getMinHeight() + ", name=" + getName() + ", wayPoints="
-				+ getNumberOfWayPoints() + "]";
-	}
-}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileNode.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/ElevationProfileNode.java	(revision 29947)
+++ 	(revision )
@@ -1,126 +1,0 @@
-/**
- * This program is free software: you can redistribute it and/or modify it under 
- * the terms of the GNU General Public License as published by the 
- * Free Software Foundation, either version 3 of the License, or 
- * (at your option) any later version. 
- * 
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
- * See the GNU General Public License for more details. 
- * 
- * You should have received a copy of the GNU General Public License along with this program. 
- * If not, see <http://www.gnu.org/licenses/>.
- */
-package org.openstreetmap.josm.plugins.elevation.gpx;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.openstreetmap.josm.data.gpx.WayPoint;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
-import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
-
-/**
- * Represents a elevation model of a single GPX track, route or collection of
- * way points. It usually breaks down into many slices represented by 
- * {@link ElevationProfileLeaf} which are accessible via {@link ElevationProfileBase#getChildren()}.
- * 
- * @author Oliver Wieland <oliver.wieland@online.de>
- * 
- * @see ElevationProfileBase
- * @see ElevationModel
- * @see ElevationProfileLeaf
- */
-public class ElevationProfileNode extends ElevationProfileBase {
-	private List<IElevationProfile> slices;
-	
-	/**
-	 * Creates a new elevation track model.
-	 * @param trackName The name of the track.
-	 * @param parent The parent elevation profile
-	 * @param sliceSize The (maximum) size of each slice.
-	 * @param wayPoints The way points belonging to this track.
-	 */
-	public ElevationProfileNode(String trackName, IElevationProfile parent, List<WayPoint> wayPoints, int sliceSize) {
-		super(trackName, parent, wayPoints, sliceSize);
-		setSliceSize(sliceSize);
-		// ensure that sliceSize has a reasonable value
-		createsSlices(wayPoints);
-	}
-
-	/**
-	 * Notifies listeners that the active slice has been changed.
-	 * 
-	 * @param oldIndex
-	 *            The index of the previously selected slice.
-	 * @param newIndex
-	 *            The index of the current slice.
-	 * 
-	 *            private void fireSliceChanged(int oldIndex, int newIndex) { if
-	 *            (listeners == null || listeners.size() == 0) { return; }
-	 * 
-	 *            if (!checkIndex(newIndex)) { throw new
-	 *            IndexOutOfBoundsException(
-	 *            String.format("Invalid index: %d (expected 0-%d)", newIndex,
-	 *            getNumberOfSlices())); } ElevationModelSlice oldObj =
-	 *            getSliceAt(oldIndex); ElevationModelSlice newObj =
-	 *            getSliceAt(newIndex);
-	 * 
-	 *            for (IElevationModelSliceListener listener : listeners) {
-	 *            listener.sliceSelectionChanged(oldObj, newObj); } }
-	 */
-
-	/**
-	 * Gets the number of slices.
-	 * 
-	 * @return
-	 */
-	public int getNumberOfSlices() {
-		return slices != null ? slices.size() : 0;
-	}
-
-	/**
-	 * Assign other way points to this track.
-	 * 
-	 * @param waypoints
-	 *            The list containing the way points.
-	 */
-	public void updateTrack(List<WayPoint> waypoints) {
-		createsSlices(waypoints);
-	}
-
-	/**
-	 * Creates the track slices.
-	 * 
-	 * @param wayPoints
-	 *            The way points of the track.
-	 */
-	private void createsSlices(List<WayPoint> wayPoints) {
-		if (wayPoints == null || getSliceSize() <= 0) {
-			return;
-		}
-
-		if (slices == null) {
-			slices = new ArrayList<IElevationProfile>();
-		} else {
-			slices.clear();
-		}
-
-		for (int i = 0; i < wayPoints.size(); i += getSliceSize()) {
-			int to = Math.min(i + getSliceSize(), wayPoints.size());
-			ElevationProfileLeaf ems = new ElevationProfileLeaf(getName(), this, wayPoints.subList(i, to));
-			slices.add(ems);
-		}
-		
-		// downsample
-		setWayPoints(ElevationHelper.downsampleWayPoints(wayPoints, getSliceSize()), false);
-	}
-
-	/* (non-Javadoc)
-	 * @see org.openstreetmap.josm.plugins.elevation.ElevationProfileBase#getChildren()
-	 */
-	@Override
-	public List<IElevationProfile> getChildren() {
-		return slices;
-	}
-}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationModel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationModel.java	(revision 29948)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationModel.java	(revision 29948)
@@ -0,0 +1,65 @@
+package org.openstreetmap.josm.plugins.elevation.gpx;
+
+import java.util.List;
+
+import org.openstreetmap.josm.plugins.elevation.IElevationModelListener;
+
+public interface IElevationModel {
+
+    /**
+     * Adds a model listener to this instance.
+     * 
+     * @param listener
+     *            The listener to add.
+     */
+    public abstract void addModelListener(IElevationModelListener listener);
+
+    /**
+     * Removes a model listener from this instance.
+     * 
+     * @param listener
+     *            The listener to remove.
+     */
+    public abstract void removeModelListener(IElevationModelListener listener);
+
+    /**
+     * Removes all listeners from this instance.
+     */
+    public abstract void removeAllListeners();
+
+    /**
+     * Gets the elevation profiles. In most GPX files there may by
+     *
+     * @return the profiles
+     */
+    public abstract List<IElevationProfile> getProfiles();
+    
+    /**
+     * Gets the current profile.
+     *
+     * @return the current profile
+     */
+    public abstract IElevationProfile getCurrentProfile();
+    
+    /**
+     * Sets the current profile.
+     *
+     * @param newProfile the new current profile
+     */
+    public abstract void setCurrentProfile(IElevationProfile newProfile);
+    
+    /**
+     * Sets the current profile by index.
+     *
+     * @param index the new current profile. Valied numbers are 0 to (profileCount - 1)
+     */
+    public abstract void setCurrentProfile(int index);
+    
+    /**
+     * Gets the number of elevation profiles within the model.
+     *
+     * @return the int
+     */
+    public abstract int profileCount();
+
+}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationProfile.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationProfile.java	(revision 29948)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/IElevationProfile.java	(revision 29948)
@@ -0,0 +1,150 @@
+/**
+ * This program is free software: you can redistribute it and/or modify it under 
+ * the terms of the GNU General Public License as published by the 
+ * Free Software Foundation, either version 3 of the License, or 
+ * (at your option) any later version. 
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
+ * See the GNU General Public License for more details. 
+ * 
+ * You should have received a copy of the GNU General Public License along with this program. 
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.openstreetmap.josm.plugins.elevation.gpx;
+
+import java.util.Date;
+import java.util.List;
+
+import org.openstreetmap.josm.data.gpx.WayPoint;
+
+/**
+ * @author Oliver Wieland <oliver.wieland@online.de>
+ * Interface for an elevation profile providing special properties/values.
+ */
+public interface IElevationProfile {
+	/**
+	 * Gets the name of the elevation profile.
+	 * @return
+	 */
+	public abstract String getName();
+	
+	/**
+	 * Gets the time stamp of first recorded track point.
+	 * @return
+	 */
+	public abstract Date getStart();
+
+	/**
+	 * Gets the time stamp of last recorded track point.
+	 * @return
+	 */
+	public abstract Date getEnd();
+	
+	/**
+	 * Gets the minimum elevation height of all tracks and routes.
+	 * @return
+	 */
+	public abstract int getMinHeight();
+
+	/**
+	 * Gets the maximum elevation height of all tracks and routes.
+	 * @return
+	 */
+	public abstract int getMaxHeight();
+	
+	/**
+	 * Gets the distance of the track in kilometers.
+	 */
+	public abstract double getDistance();
+	
+	/**
+	 * Gets the average elevation height of all tracks and routes.
+	 * @return
+	 */
+	public abstract int getAverageHeight();
+	
+	/**
+	 * Gets the difference between min and max elevation.
+	 * @return
+	 */
+	public int getHeightDifference();
+	
+	/**
+	 * Gets the elevation gain.
+	 * 
+	 * @return
+	 */
+	public int getGain();
+
+	/**
+	 * Gets the total number of way points (sum of all way points of all tracks and routes). 
+	 * @return
+	 */
+	public abstract int getNumberOfWayPoints();
+	
+	/**
+	 * Gets the list containing the way points.
+	 * @return
+	 */
+	public List<WayPoint> getWayPoints();
+	
+	/**
+	 * Gets the first recorded way point.
+	 * @return
+	 */
+	public WayPoint getStartWayPoint();
+	
+	/**
+	 * Gets the last recorded way point.
+	 * @return
+	 */
+	public WayPoint getEndWayPoint();
+	
+	/**
+	 * Gets the way point with the highest elevation value.
+	 * @return
+	 */
+	public WayPoint getMaxWayPoint();
+	
+	/**
+	 * Gets the way point with the lowest elevation value.
+	 * @return
+	 */
+	public WayPoint getMinWayPoint();
+	
+	/**
+	 * Gets a flag indicating whether the associated way points 
+	 * contained elevation data or not. This is the case if min
+	 * and max height are equal.
+	 * @return
+	 */
+	public boolean hasElevationData();
+
+	/**
+	 * Returns the time between start and end of the track.
+	 * @return
+	 */
+	public long getTimeDifference();
+	
+	/**
+	 * Gets the elevation value for at the given data index point.
+	 */
+	public int elevationValueAt(int i);
+	
+	/**
+	 * Gets the children of the segment (maybe null).
+	 */
+	public List<IElevationProfile> getChildren();
+	
+	/**
+	 * Gets the parent of the elevation profile.
+	 */
+	public IElevationProfile getParent();
+	
+	/**
+	 * Triggers model refresh.
+	 */
+	public void updateElevationData();
+}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java	(revision 29948)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gpx/WayPointMap.java	(revision 29948)
@@ -0,0 +1,12 @@
+package org.openstreetmap.josm.plugins.elevation.gpx;
+
+import java.util.ArrayList;
+
+public class WayPointMap extends ArrayList<IElevationProfile> {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+}
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/DefaultElevationProfileRenderer.java	(revision 29948)
@@ -32,7 +32,7 @@
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 import org.openstreetmap.josm.tools.CheckParameterUtil;
 
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 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileDialog.java	(revision 29948)
@@ -15,9 +15,9 @@
 package org.openstreetmap.josm.plugins.elevation.gui;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
+
 import java.awt.BorderLayout;
 import java.awt.Font;
 import java.awt.GridLayout;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
@@ -26,5 +26,4 @@
 import java.util.List;
 
-import javax.swing.ButtonGroup;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
@@ -34,17 +33,17 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.gpx.GpxData;
+import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
-import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.gui.NavigatableComponent;
 import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
 import org.openstreetmap.josm.gui.layer.GpxLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.IElevationModelListener;
-import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationModel;
 import org.openstreetmap.josm.plugins.elevation.gpx.GeoidCorrectionKind;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 import org.openstreetmap.josm.tools.Shortcut;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
 /**
  * @author Oliver Wieland <oliver.wieland@online.de>
@@ -60,5 +59,5 @@
 	private static final long serialVersionUID = -868463893732535577L;
 	/* Elevation profile instance */
-	private ElevationModel profile;
+	private IElevationModel model;
 	/* GPX data */
 	private GpxLayer activeLayer = null;
@@ -73,8 +72,4 @@
 	private JLabel totalTimeLabel;
 	private JLabel distLabel;
-	private JRadioButton geoidNone;
-	private JRadioButton geoidAuto;
-	private JRadioButton geoidFixed;
-	private JTextField geoidFixedValue;
 	/* Listener to the elevation model */
 	private List<IElevationModelListener> listeners = new ArrayList<IElevationModelListener>();
@@ -160,70 +155,10 @@
 		dataPanel.add(totalTimeLabel);
 
-		// Geoid
-		JLabel geoidHead = new JLabel(tr("Geoid"));
-		geoidHead.setFont(getFont().deriveFont(Font.BOLD));
-		dataPanel.add(geoidHead);
-
-		geoidNone = new JRadioButton(tr("None"));
-		// TODO: Obtain value from preferences
-		geoidNone.setSelected(true);
-		geoidNone.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				ElevationHelper.setGeoidKind(GeoidCorrectionKind.None);
-				geoidFixedValue.setEnabled(false);
-				getModel().updateElevationData();
-				updateView();
-			}
-		});
-
-		geoidAuto = new JRadioButton(tr("Automatic"));
-		geoidAuto.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				ElevationHelper.setGeoidKind(GeoidCorrectionKind.Auto);
-				geoidFixedValue.setEnabled(false);
-				getModel().updateElevationData();
-				updateView();
-			}
-		});
-
-		geoidFixed = new JRadioButton(tr("Fixed value"));
-		geoidFixed.setEnabled(false);
-		geoidFixed.addActionListener(new ActionListener() {
-			public void actionPerformed(ActionEvent arg0) {
-				ElevationHelper.setGeoidKind(GeoidCorrectionKind.Fixed);
-				geoidFixedValue.setEnabled(true);
-				getModel().updateElevationData();
-				updateView();
-			}
-		});
-
-		// TODO: Obtain value from preferences
-		geoidFixedValue = new JTextField("0");
-		geoidFixedValue.setEnabled(false);
-		geoidFixedValue.setAlignmentX(RIGHT_ALIGNMENT);
-		ButtonGroup grp = new ButtonGroup();
-		grp.add(geoidAuto);
-		grp.add(geoidNone);
-		grp.add(geoidFixed);
-
-		dataPanel.add(geoidNone);
-		dataPanel.add(geoidAuto);
-		dataPanel.add(geoidFixed);
-		dataPanel.add(geoidFixedValue);
-		dataPanel.add(new JLabel(" m"));
-
 		add(dataPanel, BorderLayout.PAGE_END);
-		profile = new ElevationModel();
+		model = new ElevationModel();
 
 		profPanel = new ElevationProfilePanel(null);
 		add(profPanel, BorderLayout.CENTER);
 		profPanel.addComponentListener(this);
-
-		if (ElevationHelper.getGeoidKind() == GeoidCorrectionKind.Auto) {
-			geoidAuto.setSelected(true);
-		}
-		if (ElevationHelper.getGeoidKind() == GeoidCorrectionKind.Fixed) {
-			geoidFixed.setSelected(true);
-		}
 		
 		dock();
@@ -250,6 +185,6 @@
 	 * @return
 	 */
-	public ElevationModel getModel() {
-		return profile;
+	public IElevationModel getModel() {
+		return model;
 	}
 
@@ -258,9 +193,8 @@
 	 * @param model The new model.
 	 */
-	public void setModel(ElevationModel model) {
-		if (this.profile != model) {
-			this.profile = model;
+	public void setModel(IElevationModel model) {
+		if (this.model != model) {
+		    	this.model = model;
 			profPanel.setElevationModel(model);
-			
 			updateView();
 		}
@@ -294,43 +228,47 @@
 	 */
 	private void updateView() {
+	    	if (model == null) return;
+
+		IElevationProfile profile = model.getCurrentProfile();
+
 		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(
-						ElevationHelper.getElevationText(profile.getMinHeight()));
-				maxHeightLabel.setText(
-						ElevationHelper.getElevationText(profile.getMaxHeight()));
-				avrgHeightLabel.setText(
-						ElevationHelper.getElevationText(profile.getAverageHeight()));
-				elevationGainLabel.setText(
-						ElevationHelper.getElevationText(profile.getGain()));
-			}
-			
-			// 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));
+		    // Show name of profile in title 
+		    setTitle(String.format("%s: %s", tr("Elevation Profile"), profile.getName()));
+
+		    if (profile.hasElevationData()) {
+			// Show elevation data
+			minHeightLabel.setText(
+				ElevationHelper.getElevationText(profile.getMinHeight()));
+			maxHeightLabel.setText(
+				ElevationHelper.getElevationText(profile.getMaxHeight()));
+			avrgHeightLabel.setText(
+				ElevationHelper.getElevationText(profile.getAverageHeight()));
+			elevationGainLabel.setText(
+				ElevationHelper.getElevationText(profile.getGain()));
+		    }
+
+		    // 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);
-		}
-		
+		    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();
-		repaint();
+		repaint();	    
 	}
 
@@ -340,5 +278,5 @@
 	protected void fireModelChanged() {
 		for (IElevationModelListener listener : listeners) {
-			listener.elevationProfileChanged(getModel());
+			listener.elevationProfileChanged(getModel().getCurrentProfile());
 		}
 	}
@@ -383,18 +321,14 @@
 		if (activeLayer != newLayer) {
 			activeLayer = newLayer;
-			int slices = 250;
-			if (profPanel != null && profPanel.getPlotArea().width > 0) {
-				slices = profPanel.getPlotArea().width;
-			}
-
+
+			// layer does not exist -> create
 			if (!layerMap.containsKey(newLayer)) {
 				GpxData gpxData = newLayer.data;
-				ElevationModel em = new ElevationModel(newLayer.getName(),
-						gpxData, slices);
-				layerMap.put(newLayer, em);
+				ElevationModel newEM = new ElevationModel(newLayer.getName(),
+						gpxData);
+				layerMap.put(newLayer, newEM);
 			}
 			
 			ElevationModel em = layerMap.get(newLayer);
-			em.setSliceSize(slices);
 			setModel(em);			
 		}
@@ -418,4 +352,5 @@
 			layerMap.remove(oldLayer);
 		}
+		
 		if (layerMap.size() == 0) {
 			setModel(null);
@@ -433,6 +368,4 @@
 	 */
 	public void componentHidden(ComponentEvent e) {
-		// TODO Auto-generated method stub
-
 	}
 
@@ -445,6 +378,4 @@
 	 */
 	public void componentMoved(ComponentEvent e) {
-		// TODO Auto-generated method stub
-
 	}
 
@@ -456,12 +387,4 @@
 	 */
 	public void componentResized(ComponentEvent e) {
-		int slices = 100;
-		if (profPanel != null) {
-			slices = profPanel.getPlotArea().width;
-		}
-
-		if (profile != null && profile.getSliceSize() != slices) {
-			profile.setSliceSize(slices);
-		}
 	}
 
@@ -474,5 +397,4 @@
 	 */
 	public void componentShown(ComponentEvent e) {
-
 	}
 }
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 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfileLayer.java	(revision 29948)
@@ -29,7 +29,7 @@
 import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
 import org.openstreetmap.josm.gui.layer.Layer;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 import org.openstreetmap.josm.tools.ImageProvider;
 
@@ -74,6 +74,8 @@
      */
     public void setProfile(IElevationProfile profile) {
-	this.profile = profile;
-	Main.map.repaint();
+	if (this.profile != profile) {
+        	this.profile = profile;
+        	Main.map.repaint();
+	}
     }
 
@@ -156,5 +158,4 @@
     public void paint(Graphics2D g, MapView mv, Bounds box) {
 	WayPoint lastWpt = null;
-	int lastEle = 0;
 
 	renderer.beginRendering();
@@ -173,5 +174,4 @@
 
 		// remember some things for next iteration
-		lastEle = (int) ElevationHelper.getElevation(wpt);
 		lastWpt = wpt;
 	    }
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/ElevationProfilePanel.java	(revision 29948)
@@ -37,7 +37,8 @@
 
 import org.openstreetmap.josm.data.gpx.WayPoint;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.ElevationHelper;
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationModel;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 
 /**
@@ -51,5 +52,5 @@
 	 */
 	private static final long serialVersionUID = -7343429725259575319L;
-	private IElevationProfile profile;
+	private IElevationModel model;
 	private Rectangle plotArea;
 	private IElevationProfileRenderer renderer = new DefaultElevationProfileRenderer();
@@ -62,7 +63,7 @@
 	 * @param profile The elevation profile to show in the panel.
 	 */
-	public ElevationProfilePanel(IElevationProfile profile) {
+	public ElevationProfilePanel(IElevationModel profile) {
 		super();
-		this.profile = profile;
+		this.model = profile;
 		setDoubleBuffered(true);
 		setBackground(Color.WHITE);
@@ -76,15 +77,15 @@
 	 * @return
 	 */
-	public IElevationProfile getProfile() {
-		return profile;
+	public IElevationModel getProfile() {
+		return model;
 	}
 
 	/**
 	 * Sets the new elevation profile instance.
-	 * @param profile
-	 */
-	public void setElevationModel(IElevationProfile profile) {
-		if (this.profile != profile) {
-			this.profile = profile;
+	 * @param model
+	 */
+	public void setElevationModel(IElevationModel model) {
+		if (this.model != model) {
+			this.model = model;
 			invalidate();
 		}
@@ -121,4 +122,8 @@
 	public void setSelectedIndex(int selectedIndex) {
 		this.selectedIndex = selectedIndex;
+		
+		if (model != null) {
+		    model.setCurrentProfile(selectedIndex);
+		}
 	}
 	
@@ -128,5 +133,9 @@
 	 */
 	public WayPoint getSelectedWayPoint() {
-		if (this.selectedIndex != -1 && profile != null && profile.getWayPoints() != null && profile.getWayPoints().size() > this.selectedIndex) {
+	    	if (model == null) return null;
+	    	
+	    	IElevationProfile profile = model.getCurrentProfile();
+	    
+		if (profile != null && profile.getWayPoints() != null && profile.getWayPoints().size() > this.selectedIndex) {
 			return profile.getWayPoints().get(this.selectedIndex);
 		} else {
@@ -190,17 +199,20 @@
 	
 			
-		
-			if (profile != null && profile.hasElevationData()) {
+			if (model != null) {
+			    IElevationProfile profile = model.getCurrentProfile();
+			    if (profile != null && profile.hasElevationData()) {
 				drawAlignedString(formatDate(profile.getStart()), 5, y1 + 5,
-						TextAlignment.Left, g);
+					TextAlignment.Left, g);
 				drawAlignedString(formatDate(profile.getEnd()),
-						getPlotRight(), y1 + 5, TextAlignment.Right, g);
-				
-				
+					getPlotRight(), y1 + 5, TextAlignment.Right, g);
+
+
 				drawProfile(g);
 				drawElevationLines(g);
-			} else {
+			    } else {
+				// No profile or profile supports no elevation data
 				drawAlignedString(tr("(No elevation data)"), getPlotHCenter(),
-						getPlotVCenter(), TextAlignment.Centered, g);
+					getPlotVCenter(), TextAlignment.Centered, g);
+			    }
 			}
 		} finally {
@@ -268,4 +280,6 @@
 	 */
 	private void drawElevationLines(Graphics g) {
+	    	IElevationProfile profile = model.getCurrentProfile();
+	    
 		double diff = profile.getHeightDifference();
 
@@ -373,4 +387,6 @@
 	private int getYForEelevation(int elevation) {
 		int y1 = getPlotBottom();
+		
+		IElevationProfile profile = model.getCurrentProfile();
 
 		if (!profile.hasElevationData()) {
@@ -380,7 +396,5 @@
 		double diff = profile.getHeightDifference();
 
-		return y1
-				- (int) Math
-						.round(((elevation - profile.getMinHeight()) / diff * plotArea.height));
+		return y1 - (int) Math.round(((elevation - profile.getMinHeight()) / diff * plotArea.height));
 	}
 
@@ -391,5 +405,11 @@
 	 */
 	private void drawProfile(Graphics g) {
+	    	IElevationProfile profile = model.getCurrentProfile();
+	    	
 		int n = Math.min(plotArea.width, profile.getNumberOfWayPoints());
+		
+		if (n == 0) return; // nothing to draw
+		// step size
+		int step = profile.getNumberOfWayPoints() / n;
 
 		// int y0 = plotArea.y + 1;
@@ -397,5 +417,5 @@
 		Color oldC = g.getColor();
 
-		for (int i = 0; i < n; i++) {
+		for (int i = 0; i < n; i += step) {
 			WayPoint wpt = profile.getWayPoints().get(i);
 			int eleVal = (int) ElevationHelper.getElevation(wpt);
@@ -418,15 +438,5 @@
 			g.setColor(c);
 			g.drawLine(x, yBottom, x, yEle);	
-			
-			int geoidVal = 0;
-			switch(ElevationHelper.getGeoidKind()) {
-				case Auto: geoidVal = ElevationHelper.getGeoidCorrection(wpt); break;
-				case Fixed: // not impl
-			}
-			
 			g.setColor(ElevationColors.EPLightBlue);
-			
-			int yGeoid = getYForEelevation(eleVal - geoidVal);
-			g.drawLine(x, Math.min(yGeoid, yBottom), x, yEle);
 		}
 		g.setColor(oldC);
Index: applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java
===================================================================
--- applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java	(revision 29947)
+++ applications/editors/josm/plugins/ElevationProfile/src/org/openstreetmap/josm/plugins/elevation/gui/IElevationProfileRenderer.java	(revision 29948)
@@ -20,6 +20,6 @@
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.gui.MapView;
-import org.openstreetmap.josm.plugins.elevation.IElevationProfile;
 import org.openstreetmap.josm.plugins.elevation.gpx.ElevationWayPointKind;
+import org.openstreetmap.josm.plugins.elevation.gpx.IElevationProfile;
 
 /**
