Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java	(revision 31491)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java	(revision 31492)
@@ -17,4 +17,5 @@
 import javax.swing.JSeparator;
 import javax.swing.JTree;
+import javax.swing.SwingUtilities;
 import javax.swing.tree.DefaultTreeCellRenderer;
 import javax.swing.tree.DefaultTreeModel;
@@ -80,8 +81,11 @@
     treesPanel.add(this.spacer, GBC.eol());
     this.spacer.setVisible(false);
-    treesPanel.add(this.undoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
+    treesPanel
+        .add(this.undoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     this.separator.setVisible(false);
-    treesPanel.add(this.separator, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
-    treesPanel.add(this.redoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
+    treesPanel.add(this.separator, GBC.eol()
+        .fill(GridBagConstraints.HORIZONTAL));
+    treesPanel
+        .add(this.redoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL));
     treesPanel.add(Box.createRigidArea(new Dimension(0, 0)),
         GBC.std().weight(0, 1));
@@ -135,5 +139,6 @@
     }
 
-    this.separator.setVisible(!undoCommands.isEmpty() || !redoCommands.isEmpty());
+    this.separator.setVisible(!undoCommands.isEmpty()
+        || !redoCommands.isEmpty());
     this.spacer.setVisible(undoCommands.isEmpty() && !redoCommands.isEmpty());
 
@@ -144,5 +149,14 @@
   @Override
   public void recordChanged() {
-    buildTree();
+    if (!SwingUtilities.isEventDispatchThread()) {
+      SwingUtilities.invokeLater(new Runnable() {
+        @Override
+        public void run() {
+          recordChanged();
+        }
+      });
+    } else {
+      buildTree();
+    }
   }
 
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java	(revision 31491)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecord.java	(revision 31492)
@@ -2,6 +2,4 @@
 
 import java.util.ArrayList;
-
-import javax.swing.SwingUtilities;
 
 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
@@ -73,39 +71,31 @@
    */
   public void addCommand(final MapillaryCommand command) {
-    if (!SwingUtilities.isEventDispatchThread()) {
-      SwingUtilities.invokeLater(new Runnable() {
-        @Override
-        public void run() {
-          addCommand(command);
-        }
-      });
-    } else {
-      if (command instanceof MapillaryExecutableCommand)
-        ((MapillaryExecutableCommand) command).execute();
-      // Checks if it is a continuation of last command
-      if (this.position != -1) {
-        boolean equalSets = true;
-        for (MapillaryAbstractImage img : this.commandList.get(this.position).images)
-          if (!command.images.contains(img))
-            equalSets = false;
-        for (MapillaryAbstractImage img : command.images)
-          if (!this.commandList.get(this.position).images.contains(img))
-            equalSets = false;
-        if (equalSets
-            && this.commandList.get(this.position).getClass() == command
-                .getClass()) {
-          this.commandList.get(this.position).sum(command);
-          fireRecordChanged();
-          return;
-        }
+
+    if (command instanceof MapillaryExecutableCommand)
+      ((MapillaryExecutableCommand) command).execute();
+    // Checks if it is a continuation of last command
+    if (this.position != -1) {
+      boolean equalSets = true;
+      for (MapillaryAbstractImage img : this.commandList.get(this.position).images)
+        if (!command.images.contains(img))
+          equalSets = false;
+      for (MapillaryAbstractImage img : command.images)
+        if (!this.commandList.get(this.position).images.contains(img))
+          equalSets = false;
+      if (equalSets
+          && this.commandList.get(this.position).getClass() == command
+              .getClass()) {
+        this.commandList.get(this.position).sum(command);
+        fireRecordChanged();
+        return;
       }
-      // Adds the command to the last position of the list.
-      this.commandList.add(this.position + 1, command);
-      this.position++;
-      while (this.commandList.size() > this.position + 1) {
-        this.commandList.remove(this.position + 1);
-      }
-      fireRecordChanged();
     }
+    // Adds the command to the last position of the list.
+    this.commandList.add(this.position + 1, command);
+    this.position++;
+    while (this.commandList.size() > this.position + 1) {
+      this.commandList.remove(this.position + 1);
+    }
+    fireRecordChanged();
   }
 
Index: plications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecordTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecordTest.java	(revision 31491)
+++ 	(revision )
@@ -1,163 +1,0 @@
-package org.openstreetmap.josm.plugins.mapillary.commands;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Arrays;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
-import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord;
-import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandMove;
-import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandTurn;
-import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand;
-
-/**
- * Tests the command record system.
- *
- * @author nokutu
- *
- */
-public class MapillaryRecordTest extends AbstractTest {
-
-  MapillaryRecord record;
-  MapillaryImage img1;
-  MapillaryImage img2;
-  MapillaryImage img3;
-
-  /**
-   * Creates a new {@link MapillaryRecord} object and 3 {@link MapillaryImage}
-   * objects.
-   */
-  @Before
-  public void setUp() {
-    this.record = new MapillaryRecord();
-    this.img1 = new MapillaryImage("key1", 0.1, 0.1, 0.1);
-    this.img2 = new MapillaryImage("key2", 0.2, 0.2, 0.2);
-    this.img3 = new MapillaryImage("key3", 0.3, 0.3, 0.3);
-  }
-
-  /**
-   * Test commands in general.
-   */
-  @Test
-  public void commandTest() {
-    MapillaryCommand cmd12 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
-        0.1, 0.1);
-    MapillaryCommand cmd23 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }),
-        0.1, 0.1);
-    MapillaryCommand cmd13 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img3 }),
-        0.1, 0.1);
-    MapillaryCommand cmd1 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }),
-        0.1, 0.1);
-    MapillaryCommand cmd31 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img1 }),
-        0.2, 0.2);
-    this.record.addCommand(cmd12);
-    this.record.addCommand(cmd23);
-
-    assertEquals(1, this.record.position);
-    assertEquals(2, this.record.commandList.size());
-
-    this.record.undo();
-
-    assertEquals(0, this.record.position);
-    assertEquals(2, this.record.commandList.size());
-
-    this.record.addCommand(cmd1);
-
-    assertEquals(1, this.record.position);
-
-    this.record.addCommand(cmd13);
-
-    assertEquals(2, this.record.position);
-    assertEquals(3, this.record.commandList.size());
-
-    this.record.undo();
-    this.record.redo();
-
-    assertEquals(2, this.record.position);
-    assertEquals(3, this.record.commandList.size());
-
-    this.record.addCommand(cmd31);
-
-    assertEquals(2, this.record.position);
-    assertEquals(3, this.record.commandList.size());
-
-    this.record.addCommand(cmd1);
-
-    assertEquals(3, this.record.position);
-    assertEquals(4, this.record.commandList.size());
-  }
-
-  /**
-   * Tests CommandMoveImage class.
-   */
-  @Test
-  public void commandMoveTest() {
-    CommandMove cmd1 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
-        0.1, 0.1);
-    CommandMove cmd2 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
-        0.1, 0.1);
-
-    this.record.addCommand(cmd1);
-
-    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
-
-    this.record.undo();
-
-    assertEquals(0.0, this.img1.getLatLon().lat(), 0.01);
-
-    this.record.redo();
-
-    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
-
-    this.record.addCommand(cmd2);
-    this.record.undo();
-
-    assertEquals(-0.1, this.img1.getLatLon().lat(), 0.01);
-
-    this.record.redo();
-
-    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
-  }
-
-  /**
-   * Tests CommandTurnImage class.
-   */
-  @Test
-  public void commandTurnTest() {
-    CommandTurn cmd1 = new CommandTurn(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
-        0.2);
-    CommandTurn cmd2 = new CommandTurn(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
-        0.1);
-
-    this.record.addCommand(cmd1);
-    this.record.undo();
-
-    assertEquals(-0.1, this.img1.getCa(), 0.01);
-
-    this.record.redo();
-
-    assertEquals(0.1, this.img1.getCa(), 0.01);
-
-    this.record.addCommand(cmd2);
-    this.record.undo();
-
-    assertEquals(-0.2, this.img1.getCa(), 0.01);
-
-    this.record.redo();
-
-    assertEquals(0.1, this.img1.getCa(), 0.01);
-  }
-}
Index: /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java	(revision 31492)
+++ /applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java	(revision 31492)
@@ -0,0 +1,163 @@
+package org.openstreetmap.josm.plugins.mapillary.history;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
+import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandMove;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandTurn;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand;
+
+/**
+ * Tests the command record system.
+ *
+ * @author nokutu
+ *
+ */
+public class MapillaryRecordTest extends AbstractTest {
+
+  MapillaryRecord record;
+  MapillaryImage img1;
+  MapillaryImage img2;
+  MapillaryImage img3;
+
+  /**
+   * Creates a new {@link MapillaryRecord} object and 3 {@link MapillaryImage}
+   * objects.
+   */
+  @Before
+  public void setUp() {
+    this.record = new MapillaryRecord();
+    this.img1 = new MapillaryImage("key1", 0.1, 0.1, 0.1);
+    this.img2 = new MapillaryImage("key2", 0.2, 0.2, 0.2);
+    this.img3 = new MapillaryImage("key3", 0.3, 0.3, 0.3);
+  }
+
+  /**
+   * Test commands in general.
+   */
+  @Test
+  public void commandTest() {
+    MapillaryCommand cmd12 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
+        0.1, 0.1);
+    MapillaryCommand cmd23 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }),
+        0.1, 0.1);
+    MapillaryCommand cmd13 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img3 }),
+        0.1, 0.1);
+    MapillaryCommand cmd1 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }),
+        0.1, 0.1);
+    MapillaryCommand cmd31 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img1 }),
+        0.2, 0.2);
+    this.record.addCommand(cmd12);
+    this.record.addCommand(cmd23);
+
+    assertEquals(1, this.record.position);
+    assertEquals(2, this.record.commandList.size());
+
+    this.record.undo();
+
+    assertEquals(0, this.record.position);
+    assertEquals(2, this.record.commandList.size());
+
+    this.record.addCommand(cmd1);
+
+    assertEquals(1, this.record.position);
+
+    this.record.addCommand(cmd13);
+
+    assertEquals(2, this.record.position);
+    assertEquals(3, this.record.commandList.size());
+
+    this.record.undo();
+    this.record.redo();
+
+    assertEquals(2, this.record.position);
+    assertEquals(3, this.record.commandList.size());
+
+    this.record.addCommand(cmd31);
+
+    assertEquals(2, this.record.position);
+    assertEquals(3, this.record.commandList.size());
+
+    this.record.addCommand(cmd1);
+
+    assertEquals(3, this.record.position);
+    assertEquals(4, this.record.commandList.size());
+  }
+
+  /**
+   * Tests CommandMoveImage class.
+   */
+  @Test
+  public void commandMoveTest() {
+    CommandMove cmd1 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
+        0.1, 0.1);
+    CommandMove cmd2 = new CommandMove(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
+        0.1, 0.1);
+
+    this.record.addCommand(cmd1);
+
+    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
+
+    this.record.undo();
+
+    assertEquals(0.0, this.img1.getLatLon().lat(), 0.01);
+
+    this.record.redo();
+
+    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
+
+    this.record.addCommand(cmd2);
+    this.record.undo();
+
+    assertEquals(-0.1, this.img1.getLatLon().lat(), 0.01);
+
+    this.record.redo();
+
+    assertEquals(0.1, this.img1.getLatLon().lat(), 0.01);
+  }
+
+  /**
+   * Tests CommandTurnImage class.
+   */
+  @Test
+  public void commandTurnTest() {
+    CommandTurn cmd1 = new CommandTurn(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
+        0.2);
+    CommandTurn cmd2 = new CommandTurn(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }),
+        0.1);
+
+    this.record.addCommand(cmd1);
+    this.record.undo();
+
+    assertEquals(-0.1, this.img1.getCa(), 0.01);
+
+    this.record.redo();
+
+    assertEquals(0.1, this.img1.getCa(), 0.01);
+
+    this.record.addCommand(cmd2);
+    this.record.undo();
+
+    assertEquals(-0.2, this.img1.getCa(), 0.01);
+
+    this.record.redo();
+
+    assertEquals(0.1, this.img1.getCa(), 0.01);
+  }
+}
