Index: trunk/src/org/openstreetmap/josm/command/SequenceCommand.java
===================================================================
--- trunk/src/org/openstreetmap/josm/command/SequenceCommand.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/command/SequenceCommand.java	(revision 6450)
@@ -116,5 +116,5 @@
     
     protected final void setSequence(Command[] sequence) {
-        this.sequence = sequence;
+        this.sequence = Arrays.copyOf(sequence, sequence.length);
     }
     
Index: trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/gui/io/BasicUploadSettingsPanel.java	(revision 6450)
@@ -162,5 +162,5 @@
      * Updates the changeset comment model upon changes in the input field.
      */
-    class CommentModelListener extends FocusAdapter implements ActionListener {
+    static class CommentModelListener extends FocusAdapter implements ActionListener {
 
         final HistoryComboBox source;
@@ -186,5 +186,5 @@
      * in sync with the current changeset comment
      */
-    class ChangesetCommentObserver implements Observer {
+    static class ChangesetCommentObserver implements Observer {
 
         private final HistoryComboBox destination;
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java	(revision 6450)
@@ -1074,5 +1074,5 @@
         List<ImageEntry> dateImgLst = new ArrayList<ImageEntry>(yLayer.data.size());
         for (ImageEntry e : yLayer.data) {
-            if (e.getExifTime() == null) {
+            if (!e.hasExifTime()) {
                 continue;
             }
@@ -1159,4 +1159,16 @@
     }
 
+    private static Double getElevation(WayPoint wp) {
+        String value = (String) wp.attr.get("ele");
+        if (value != null) {
+            try {
+                return new Double(value);
+            } catch (NumberFormatException e) {
+                Main.warn(e);
+            }
+        }
+        return null;
+    }
+    
     private int matchPoints(List<ImageEntry> images, WayPoint prevWp, long prevWpTime,
             WayPoint curWp, long curWpTime, long offset) {
@@ -1175,5 +1187,4 @@
         Double speed = null;
         Double prevElevation = null;
-        Double curElevation = null;
 
         if (prevWp != null) {
@@ -1183,16 +1194,12 @@
                 speed = 3600 * distance / (curWpTime - prevWpTime);
             }
-            try {
-                prevElevation = new Double((String) prevWp.attr.get("ele"));
-            } catch(Exception e) {}
-        }
-
-        try {
-            curElevation = new Double((String) curWp.attr.get("ele"));
-        } catch (Exception e) {}
+            prevElevation = getElevation(prevWp);
+        }
+
+        Double curElevation = getElevation(curWp);
 
         // First trackpoint, then interval is set to five seconds, i.e. photos up to five seconds
         // before the first point will be geotagged with the starting point
-        if(prevWpTime == 0 || curWpTime <= prevWpTime) {
+        if (prevWpTime == 0 || curWpTime <= prevWpTime) {
             while (true) {
                 if (i < 0) {
@@ -1200,9 +1207,9 @@
                 }
                 final ImageEntry curImg = images.get(i);
-                if (curImg.getExifTime().getTime() > curWpTime
-                        || curImg.getExifTime().getTime() < curWpTime - interval) {
+                long time = curImg.getExifTime().getTime();
+                if (time > curWpTime || time < curWpTime - interval) {
                     break;
                 }
-                if(curImg.tmp.getPos() == null) {
+                if (curImg.tmp.getPos() == null) {
                     curImg.tmp.setPos(curWp.getCoor());
                     curImg.tmp.setSpeed(speed);
@@ -1229,7 +1236,6 @@
             }
 
-            if(curImg.tmp.getPos() == null) {
-                // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless
-                // variable
+            if (curImg.tmp.getPos() == null) {
+                // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless variable
                 double timeDiff = (double)(imgTime - prevWpTime) / interval;
                 curImg.tmp.setPos(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff));
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java	(revision 6450)
@@ -26,5 +26,4 @@
 import java.util.Collection;
 import java.util.Collections;
-import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.HashSet;
@@ -154,5 +153,5 @@
                 try {
                     e.setExifTime(ExifReader.readTime(f));
-                } catch (ParseException e1) {
+                } catch (ParseException ex) {
                     e.setExifTime(null);
                 }
@@ -636,10 +635,9 @@
             }
             else {
-                // No GPS date stamp in EXIF data.  Copy it from EXIF time.
+                // No GPS date stamp in EXIF data. Copy it from EXIF time.
                 // Date is not set if EXIF time is not available.
-                Date exifTime = e.getExifTime();
-                if (exifTime != null) {
+                if (e.hasExifTime()) {
                     // Time not set yet, so we can copy everything, not just date.
-                    cal.setTime(exifTime);
+                    cal.setTime(e.getExifTime());
                 }
             }
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageEntry.java	(revision 6450)
@@ -41,5 +41,5 @@
 
     /**
-     * When the corralation dialog is open, we like to show the image position
+     * When the correlation dialog is open, we like to show the image position
      * for the current time offset on the map in real time.
      * On the other hand, when the user aborts this operation, the old values
@@ -68,8 +68,18 @@
         return elevation;
     }
+
     public Date getGpsTime() {
         if (tmp != null)
-            return tmp.gpsTime;
-        return gpsTime;
+            return getDefensiveDate(tmp.gpsTime);
+        return getDefensiveDate(gpsTime);
+    }
+
+    /**
+     * Convenient way to determine if this entry has a GPS time, without the cost of building a defensive copy.
+     * @return {@code true} if this entry has a GPS time
+     * @since 6450
+     */
+    public final boolean hasGpsTime() {
+        return (tmp != null && tmp.gpsTime != null) || gpsTime != null; 
     }
 
@@ -84,5 +94,14 @@
     }
     public Date getExifTime() {
-        return exifTime;
+        return getDefensiveDate(exifTime);
+    }
+    
+    /**
+     * Convenient way to determine if this entry has a EXIF time, without the cost of building a defensive copy.
+     * @return {@code true} if this entry has a EXIF time
+     * @since 6450
+     */
+    public final boolean hasExifTime() {
+        return exifTime != null; 
     }
     
@@ -93,5 +112,20 @@
      */
     public final Date getExifGpsTime() {
-        return exifGpsTime;
+        return getDefensiveDate(exifGpsTime);
+    }
+    
+    /**
+     * Convenient way to determine if this entry has a EXIF GPS time, without the cost of building a defensive copy.
+     * @return {@code true} if this entry has a EXIF GPS time
+     * @since 6450
+     */
+    public final boolean hasExifGpsTime() {
+        return exifGpsTime != null; 
+    }
+    
+    private static Date getDefensiveDate(Date date) {
+        if (date == null)
+            return null;
+        return new Date(date.getTime());
     }
     
@@ -129,5 +163,5 @@
     }
     public void setExifTime(Date exifTime) {
-        this.exifTime = exifTime;
+        this.exifTime = getDefensiveDate(exifTime);
     }
     
@@ -138,9 +172,9 @@
      */
     public final void setExifGpsTime(Date exifGpsTime) {
-        this.exifGpsTime = exifGpsTime;
+        this.exifGpsTime = getDefensiveDate(exifGpsTime);
     }
     
     public void setGpsTime(Date gpsTime) {
-        this.gpsTime = gpsTime;
+        this.gpsTime = getDefensiveDate(gpsTime);
     }
     public void setExifCoor(LatLon exifCoor) {
@@ -228,17 +262,17 @@
         // This can be removed once isNewGpsData is used instead of the GPS time.
         if (gpsTime == null) {
-            Date gpsTime = getExifGpsTime();
-            if (gpsTime == null) {
-                gpsTime = getExifTime();
-                if (gpsTime == null) {
+            Date time = getExifGpsTime();
+            if (time == null) {
+                time = getExifTime();
+                if (time == null) {
                     // Time still not set, take the current time.
-                    gpsTime = new Date();
+                    time = new Date();
                 }
             }
-            setGpsTime(gpsTime);
-        }
-        if (tmp != null && tmp.getGpsTime() == null) {
+            gpsTime = time;
+        }
+        if (tmp != null && !tmp.hasGpsTime()) {
             // tmp.gpsTime overrides gpsTime, so we set it too.
-            tmp.setGpsTime(getGpsTime());
+            tmp.gpsTime = gpsTime;
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java	(revision 6450)
@@ -247,8 +247,8 @@
             }
             DateFormat dtf = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
-            if (entry.getExifTime() != null) {
+            if (entry.hasExifTime()) {
                 osd.append(tr("\nEXIF time: {0}", dtf.format(entry.getExifTime())));
             }
-            if (entry.getGpsTime() != null) {
+            if (entry.hasGpsTime()) {
                 osd.append(tr("\nGPS time: {0}", dtf.format(entry.getGpsTime())));
             }
Index: trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionExporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionExporter.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionExporter.java	(revision 6450)
@@ -93,5 +93,5 @@
                 addAttr("elevation", entry.getElevation().toString(), imgElem, support);
             }
-            if (entry.getGpsTime() != null) {
+            if (entry.hasGpsTime()) {
                 addAttr("gps-time", Long.toString(entry.getGpsTime().getTime()), imgElem, support);
             }
@@ -99,8 +99,8 @@
                 addAttr("exif-orientation", Integer.toString(entry.getExifOrientation()), imgElem, support);
             }
-            if (entry.getExifTime() != null) {
+            if (entry.hasExifTime()) {
                 addAttr("exif-time", Long.toString(entry.getExifTime().getTime()), imgElem, support);
             }
-            if (entry.getExifGpsTime() != null) {
+            if (entry.hasExifGpsTime()) {
                 addAttr("exif-gps-time", Long.toString(entry.getExifGpsTime().getTime()), imgElem, support);
             }
Index: trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java	(revision 6449)
+++ trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java	(revision 6450)
@@ -69,8 +69,6 @@
                                 } else if (attrElem.getTagName().equals("exif-image-direction")) {
                                     entry.setExifImgDir(Double.parseDouble(attrElem.getTextContent()));
-                                } else if (attrElem.getTagName().equals("is-new-gps-data")) {
-                                    if (Boolean.parseBoolean(attrElem.getTextContent())) {
-                                        entry.flagNewGpsData();
-                                    }
+                                } else if (attrElem.getTagName().equals("is-new-gps-data") && Boolean.parseBoolean(attrElem.getTextContent())) {
+                                    entry.flagNewGpsData();
                                 }
                                 // TODO: handle thumbnail loading
