Index: applications/editors/josm/plugins/livegps/build.xml
===================================================================
--- applications/editors/josm/plugins/livegps/build.xml	(revision 19679)
+++ applications/editors/josm/plugins/livegps/build.xml	(revision 19680)
@@ -28,5 +28,5 @@
 
 	<property name="commit.message" value="Changed the constructor signature of the plugin main class" />
-	<property name="plugin.main.version" value="2830" />
+	<property name="plugin.main.version" value="2907" />
 	
 
Index: applications/editors/josm/plugins/livegps/josm-livegps.launch
===================================================================
--- applications/editors/josm/plugins/livegps/josm-livegps.launch	(revision 19680)
+++ applications/editors/josm/plugins/livegps/josm-livegps.launch	(revision 19680)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/JOSM/src/org/openstreetmap/josm/gui/MainApplication.java"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="1"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 6"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.openstreetmap.josm.gui.MainApplication"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="livegps"/>
+</launchConfiguration>
Index: applications/editors/josm/plugins/livegps/src/livegps/AppendableGpxTrackSegment.java
===================================================================
--- applications/editors/josm/plugins/livegps/src/livegps/AppendableGpxTrackSegment.java	(revision 19680)
+++ applications/editors/josm/plugins/livegps/src/livegps/AppendableGpxTrackSegment.java	(revision 19680)
@@ -0,0 +1,57 @@
+package livegps;
+
+import java.util.Collection;
+
+import org.openstreetmap.josm.data.Bounds;
+import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
+import org.openstreetmap.josm.data.gpx.WayPoint;
+import org.openstreetmap.josm.tools.CopyList;
+
+/**
+ * Thread safe implementation of GpxTrackSegement
+ *
+ */
+public class AppendableGpxTrackSegment implements GpxTrackSegment {
+
+	private WayPoint[] wayPoints = new WayPoint[16];
+	private int size;
+	private Bounds bounds;
+	private double length;
+
+	public Bounds getBounds() {
+		return bounds;
+	}
+
+	public Collection<WayPoint> getWayPoints() {
+		return new CopyList<WayPoint>(wayPoints, size);
+	}
+
+	public void addWaypoint(WayPoint p) {
+		if (wayPoints.length == size) {
+			WayPoint[] newWaypoints = new WayPoint[wayPoints.length * 2];
+			System.arraycopy(wayPoints, 0, newWaypoints, 0, wayPoints.length);
+			wayPoints = newWaypoints;
+		}
+
+		if (size > 0) {
+			Double distance = wayPoints[size - 1].getCoor().greatCircleDistance(p.getCoor());
+			if (!distance.isNaN() && !distance.isInfinite()) {
+				length += distance;
+			}
+		}
+
+		if (bounds == null) {
+			bounds = new Bounds(p.getCoor());
+		} else {
+			bounds.extend(p.getCoor());
+		}
+
+		wayPoints[size] = p;
+		size++;
+	}
+
+	public double length() {
+		return length;
+	}
+
+}
Index: applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
===================================================================
--- applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java	(revision 19679)
+++ applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java	(revision 19680)
@@ -9,5 +9,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.Way;
Index: applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java
===================================================================
--- applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java	(revision 19679)
+++ applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java	(revision 19680)
@@ -9,7 +9,7 @@
 import java.beans.PropertyChangeListener;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.openstreetmap.josm.Main;
@@ -18,4 +18,5 @@
 import org.openstreetmap.josm.data.gpx.GpxData;
 import org.openstreetmap.josm.data.gpx.GpxTrack;
+import org.openstreetmap.josm.data.gpx.SingleSegmentGpxTrack;
 import org.openstreetmap.josm.data.gpx.WayPoint;
 import org.openstreetmap.josm.gui.MapView;
@@ -27,6 +28,5 @@
 	LatLon lastPos;
 	WayPoint lastPoint;
-	GpxTrack trackBeingWritten;
-	Collection<WayPoint> trackSegment;
+	private final AppendableGpxTrackSegment trackSegment;
 	float speed;
 	float course;
@@ -35,5 +35,5 @@
 	boolean autocenter;
 	private SimpleDateFormat dateFormat = new SimpleDateFormat(
-			"yyyy-MM-dd'T'HH:mm:ss.SSS");
+	"yyyy-MM-dd'T'HH:mm:ss.SSS");
 
 	/**
@@ -44,8 +44,10 @@
 	public LiveGpsLayer(GpxData data) {
 		super(data, LAYER_NAME);
-		trackBeingWritten = new GpxTrack();
-		trackBeingWritten.attr.put("desc", "josm live gps");
-		trackSegment = new ArrayList<WayPoint>();
-		trackBeingWritten.trackSegs.add(trackSegment);
+		trackSegment = new AppendableGpxTrackSegment();
+
+		Map<String, Object> attr = new HashMap<String, Object>();
+		attr.put("desc", "josm live gps");
+
+		GpxTrack trackBeingWritten = new SingleSegmentGpxTrack(trackSegment, attr);
 		data.tracks.add(trackBeingWritten);
 	}
@@ -63,9 +65,5 @@
 		lastPoint = new WayPoint(thisPos);
 		lastPoint.attr.put("time", dateFormat.format(new Date()));
-		// synchronize when adding data, as otherwise the autosave action
-		// needs concurrent access and this results in an exception!
-		synchronized (LiveGpsLock.class) {
-			trackSegment.add(lastPoint);
-		}
+		trackSegment.addWaypoint(lastPoint);
 		if (autocenter && allowRedraw()) {
 			center();
@@ -104,34 +102,32 @@
 	public void paint(Graphics2D g, MapView mv, Bounds bounds) {
 		// System.out.println("in paint");
-		synchronized (LiveGpsLock.class) {
-			// System.out.println("in synced paint");
-			super.paint(g, mv, bounds);
-			// int statusHeight = 50;
-			// Rectangle mvs = mv.getBounds();
-			// mvs.y = mvs.y + mvs.height - statusHeight;
-			// mvs.height = statusHeight;
-			// g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.8f));
-			// g.fillRect(mvs.x, mvs.y, mvs.width, mvs.height);
+		// System.out.println("in synced paint");
+		super.paint(g, mv, bounds);
+		// int statusHeight = 50;
+		// Rectangle mvs = mv.getBounds();
+		// mvs.y = mvs.y + mvs.height - statusHeight;
+		// mvs.height = statusHeight;
+		// g.setColor(new Color(1.0f, 1.0f, 1.0f, 0.8f));
+		// g.fillRect(mvs.x, mvs.y, mvs.width, mvs.height);
 
-			if (lastPoint != null) {
-				Point screen = mv.getPoint(lastPoint.getCoor());
-				g.setColor(Main.pref.getColor(KEY_LIVEGPS_COLOR, Color.RED));
-				g.drawOval(screen.x - 10, screen.y - 10, 20, 20);
-				g.drawOval(screen.x - 9, screen.y - 9, 18, 18);
-			}
+		if (lastPoint != null) {
+			Point screen = mv.getPoint(lastPoint.getCoor());
+			g.setColor(Main.pref.getColor(KEY_LIVEGPS_COLOR, Color.RED));
+			g.drawOval(screen.x - 10, screen.y - 10, 20, 20);
+			g.drawOval(screen.x - 9, screen.y - 9, 18, 18);
+		}
 
-			// lbl.setText("gpsd: "+status+" Speed: " + speed +
-			// " Course: "+course);
-			// lbl.setBounds(0, 0, mvs.width-10, mvs.height-10);
-			// Graphics sub = g.create(mvs.x+5, mvs.y+5, mvs.width-10,
-			// mvs.height-10);
-			// lbl.paint(sub);
+		// lbl.setText("gpsd: "+status+" Speed: " + speed +
+		// " Course: "+course);
+		// lbl.setBounds(0, 0, mvs.width-10, mvs.height-10);
+		// Graphics sub = g.create(mvs.x+5, mvs.y+5, mvs.width-10,
+		// mvs.height-10);
+		// lbl.paint(sub);
 
-			// if(status != null) {
-			// g.setColor(Color.WHITE);
-			// g.drawString("gpsd: " + status, 5, mv.getBounds().height - 15);
-			// // lower left corner
-			// }
-		}
+		// if(status != null) {
+		// g.setColor(Color.WHITE);
+		// g.drawString("gpsd: " + status, 5, mv.getBounds().height - 15);
+		// // lower left corner
+		// }
 	}
 
@@ -176,6 +172,6 @@
 	/**
 	 * Check, if a redraw is currently allowed.
-	 * 
-	 * @return true, if a redraw is permitted, false, if a re-draw 
+	 *
+	 * @return true, if a redraw is permitted, false, if a re-draw
 	 * should be suppressed.
 	 */
Index: applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLock.java
===================================================================
--- applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLock.java	(revision 19679)
+++ 	(revision )
@@ -1,16 +1,0 @@
-/**
- *
- */
-package livegps;
-
-/**
- * This class is only used to prevent concurrent object modification. So all classes that
- * read or write live gps data must synchronize to this class. Especially the save action
- * takes quite long, so concurrency problems occur.
- *
- * @author cdaller
- *
- */
-public class LiveGpsLock {
-
-}
