Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java	(revision 31391)
@@ -33,5 +33,6 @@
    * 
    * @param ex {@link ExecutorService} object that is executing this thread.
-   * @param url
+   * @param queryString 
+   * @param layer 
    */
   public MapillaryImageInfoDownloaderThread(ExecutorService ex, String queryString, MapillaryLayer layer) {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31391)
@@ -38,6 +38,15 @@
   private final MapillarySquareDownloadManagerThread manager;
 
-  public MapillarySequenceDownloadThread(ExecutorService ex, String queryString,
-      MapillaryLayer layer, MapillarySquareDownloadManagerThread manager) {
+  /**
+   * Main constructor.
+   * 
+   * @param ex
+   * @param queryString
+   * @param layer
+   * @param manager
+   */
+  public MapillarySequenceDownloadThread(ExecutorService ex,
+      String queryString, MapillaryLayer layer,
+      MapillarySquareDownloadManagerThread manager) {
     this.queryString = queryString;
     this.ex = ex;
@@ -51,5 +60,6 @@
     try {
       BufferedReader br;
-      br = new BufferedReader(new InputStreamReader(new URL(URL + queryString).openStream(), "UTF-8"));
+      br = new BufferedReader(new InputStreamReader(
+          new URL(URL + queryString).openStream(), "UTF-8"));
       JsonObject jsonall = Json.createReader(br).readObject();
 
@@ -94,10 +104,11 @@
           if (layer.getMapillaryData().getImages().contains(img)) {
             sequence.add(img);
-            ((MapillaryImage) layer.getMapillaryData().getImages().get(
-                layer.getMapillaryData().getImages().indexOf(img))).setSequence(sequence);
+            ((MapillaryImage) layer.getMapillaryData().getImages()
+                .get(layer.getMapillaryData().getImages().indexOf(img)))
+                .setSequence(sequence);
             finalImages.set(
                 finalImages.indexOf(img),
-                (MapillaryImage) layer.getMapillaryData().getImages().get(
-                    layer.getMapillaryData().getImages().indexOf(img)));
+                (MapillaryImage) layer.getMapillaryData().getImages()
+                    .get(layer.getMapillaryData().getImages().indexOf(img)));
           } else {
             img.setSequence(sequence);
@@ -110,6 +121,6 @@
           manager.imagesAdded = imagesAdded;
         }
-        layer.getMapillaryData().addWithoutUpdate(new ArrayList<MapillaryAbstractImage>(
-            finalImages));
+        layer.getMapillaryData().addWithoutUpdate(
+            new ArrayList<MapillaryAbstractImage>(finalImages));
       }
     } catch (IOException e) {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySignDownloaderThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySignDownloaderThread.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySignDownloaderThread.java	(revision 31391)
@@ -17,6 +17,13 @@
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 
+/**
+ * Downloads the signs information in a given area.
+ * 
+ * @author nokutu
+ *
+ */
 public class MapillarySignDownloaderThread extends Thread {
-  private static final String URL = MapillaryDownloader.BASE_URL + "search/im/or/";
+  private static final String URL = MapillaryDownloader.BASE_URL
+      + "search/im/or/";
   private final String queryString;
   private final ExecutorService ex;
@@ -26,8 +33,11 @@
    * Main constructor.
    * 
-   * @param ex {@link ExecutorService} object that is executing this thread.
-   * @param url
+   * @param ex
+   *          {@link ExecutorService} object that is executing this thread.
+   * @param queryString
+   * @param layer
    */
-  public MapillarySignDownloaderThread(ExecutorService ex, String queryString, MapillaryLayer layer) {
+  public MapillarySignDownloaderThread(ExecutorService ex, String queryString,
+      MapillaryLayer layer) {
     this.ex = ex;
     this.queryString = queryString;
@@ -39,5 +49,6 @@
     BufferedReader br;
     try {
-      br = new BufferedReader(new InputStreamReader(new URL(URL + queryString).openStream(), "UTF-8"));
+      br = new BufferedReader(new InputStreamReader(
+          new URL(URL + queryString).openStream(), "UTF-8"));
       JsonObject jsonobj = Json.createReader(br).readObject();
       if (!jsonobj.getBoolean("more")) {
@@ -55,5 +66,6 @@
             for (int k = 0; k < rects.size(); k++) {
               JsonObject data = rects.getJsonObject(k);
-              for (MapillaryAbstractImage image : layer.getMapillaryData().getImages())
+              for (MapillaryAbstractImage image : layer.getMapillaryData()
+                  .getImages())
                 if (image instanceof MapillaryImage
                     && ((MapillaryImage) image).getKey().equals(key))
@@ -67,5 +79,6 @@
           for (int j = 0; j < rects.size(); j++) {
             JsonObject data = rects.getJsonObject(j);
-            for (MapillaryAbstractImage image : layer.getMapillaryData().getImages())
+            for (MapillaryAbstractImage image : layer.getMapillaryData()
+                .getImages())
               if (image instanceof MapillaryImage
                   && ((MapillaryImage) image).getKey().equals(key))
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31391)
@@ -31,4 +31,5 @@
   private final String signQueryString;
   private final MapillaryLayer layer;
+  /** Whether if new images have been added in the download or not. */
   public boolean imagesAdded = false;
 
@@ -36,26 +37,31 @@
    * Main constructor.
    * 
-   * @param urlImages URL used to download the images.
-   * @param urlSequences URL used to download the sequences.
-   * @param urlSigns URL used to download the signs.
+   * @param queryStringParts
+   * @param layer
+   * 
    */
-  public MapillarySquareDownloadManagerThread(ConcurrentHashMap<String, Double> queryStringParts, MapillaryLayer layer) {
+  public MapillarySquareDownloadManagerThread(
+      ConcurrentHashMap<String, Double> queryStringParts, MapillaryLayer layer) {
     this.imageQueryString = buildQueryString(queryStringParts);
     this.sequenceQueryString = buildQueryString(queryStringParts);
     this.signQueryString = buildQueryString(queryStringParts);
 
-    Main.info("GET " + sequenceQueryString + " (Mapillary plugin)"); // TODO: Move this line to the appropriate place, here's no GET-request
+    // TODO: Move this line to the appropriate place, here's no GET-request
+    Main.info("GET " + sequenceQueryString + " (Mapillary plugin)");
 
     this.layer = layer;
   }
 
-  //TODO: Maybe move into a separate utility class?
+  // TODO: Maybe move into a separate utility class?
   private String buildQueryString(ConcurrentHashMap<String, Double> hash) {
-    StringBuilder ret = new StringBuilder("?client_id=" + MapillaryDownloader.CLIENT_ID);
+    StringBuilder ret = new StringBuilder("?client_id="
+        + MapillaryDownloader.CLIENT_ID);
     for (String key : hash.keySet())
       if (key != null)
         try {
-          ret.append("&" + URLEncoder.encode(key, "UTF-8"))
-             .append("=" + URLEncoder.encode(String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));
+          ret.append("&" + URLEncoder.encode(key, "UTF-8")).append(
+              "="
+                  + URLEncoder.encode(
+                      String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));
         } catch (UnsupportedEncodingException e) {
           // This should not happen, as the encoding is hard-coded
@@ -90,12 +96,6 @@
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(
-        new MapillarySequenceDownloadThread(
-          ex,
-          sequenceQueryString + "&page=" + page + "&limit=10",
-          layer,
-          this
-        )
-      );
+      ex.execute(new MapillarySequenceDownloadThread(ex, sequenceQueryString
+          + "&page=" + page + "&limit=10", layer, this));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(500);
@@ -125,6 +125,6 @@
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillarySignDownloaderThread(ex, signQueryString + "&page="
-          + page + "&limit=20", layer));
+      ex.execute(new MapillarySignDownloaderThread(ex, signQueryString
+          + "&page=" + page + "&limit=20", layer));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(100);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java	(revision 31391)
@@ -51,4 +51,5 @@
   /**
    * Main constructor.
+   * @param ok 
    */
   public MapillaryExportDialog(JButton ok) {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31391)
@@ -64,5 +64,8 @@
     panel.add(moveTo);
     JButton oauth = new JButton(new OAuthAction());
-    oauth.setText("Login");
+    if (Main.pref.get("mapillary.access-token") == null)
+      oauth.setText("Login");
+    else
+       oauth.setText("Already loged in, click to relogin");
     panel.add(oauth);
     gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java	(revision 31391)
@@ -13,7 +13,5 @@
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 import org.openstreetmap.josm.plugins.mapillary.commands.CommandMoveImage;
@@ -51,5 +49,5 @@
       return;
     MapillaryAbstractImage closest = getClosest(e.getPoint());
-    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closestTemp != null
+    if (Main.map.mapView.getActiveLayer() instanceof OsmDataLayer && closest != null
         && Main.map.mapMode == Main.map.mapModeSelect) {
       this.lastClicked = this.closest;
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/PortListener.java	(revision 31391)
@@ -4,4 +4,5 @@
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.net.BindException;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -47,4 +48,6 @@
       in.close();
       serverSocket.close();
+    } catch (BindException e) {
+      return;
     } catch (IOException e) {
       Main.error(e);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoGlyph.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoGlyph.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoGlyph.java	(revision 31391)
@@ -11,6 +11,8 @@
 public class TrafficoGlyph {
   private static Map<String, Character> glyphs;
+
   private static Map<String, Character> readGlyphsFromResources() {
-    JsonReader reader = Json.createReader(TrafficoSignElement.class.getResourceAsStream("/data/fonts/traffico/glyphs.json"));
+    JsonReader reader = Json.createReader(TrafficoSignElement.class
+        .getResourceAsStream("/data/fonts/traffico/glyphs.json"));
     JsonObject glyphObject = reader.readObject().getJsonObject("glyphs");
     Set<String> glyphNames = glyphObject.keySet();
@@ -21,4 +23,5 @@
     return glyphs;
   }
+
   public static Character getGlyph(String key) {
     if (glyphs == null) {
@@ -27,4 +30,5 @@
     return glyphs.get(key);
   }
+
   public static void main(String[] args) {
     System.out.println(TrafficoGlyph.getGlyph("h"));
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java	(revision 31391)
@@ -30,6 +30,9 @@
       System.out.println("Read signs for " + country);
       InputStream countryStream = TrafficoSign.class
-          .getResourceAsStream("/data/fonts/traffico/signs/" + country + ".json");
-      if (countryStream == null) { return null; }
+          .getResourceAsStream("/data/fonts/traffico/signs/" + country
+              + ".json");
+      if (countryStream == null) {
+        return null;
+      }
       JsonObject countrySigns = Json.createReader(countryStream).readObject();
       Set<String> countrySignNames = countrySigns.keySet();
@@ -38,11 +41,17 @@
       for (String name : countrySignNames) {
         System.out.println(" * sign " + name);
-        JsonArray elements = countrySigns.getJsonObject(name).getJsonArray("elements");
-        List<TrafficoSignElement> layers = new ArrayList<>(); // TODO: Replace by an array when all types of sign
-                                                              // elements (text!) are supported
+        JsonArray elements = countrySigns.getJsonObject(name).getJsonArray(
+            "elements");
+
+        // TODO: Replace by an array when all types of sign elements (text!) are
+        // supported
+        List<TrafficoSignElement> layers = new ArrayList<>();
+
         for (int i = 0; i < elements.size(); i++) {
-          System.out.println("   - " + elements.getJsonObject(i).getString("color") + " layer "
+          System.out.println("   - "
+              + elements.getJsonObject(i).getString("color") + " layer "
               + elements.getJsonObject(i).getString("type"));
-          Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i).getString("type"));
+          Character glyph = TrafficoGlyph.getGlyph(elements.getJsonObject(i)
+              .getString("type"));
           if (glyph != null) {
             Color c;
@@ -76,6 +85,10 @@
       signs.put(country, countryMap);
     }
-    if (signs.get(country).get(signName) != null) { return signs.get(country).get(signName); }
-    if (isIn.containsKey(country)) { return TrafficoSign.getSign(isIn.get(country), signName); }
+    if (signs.get(country).get(signName) != null) {
+      return signs.get(country).get(signName);
+    }
+    if (isIn.containsKey(country)) {
+      return TrafficoSign.getSign(isIn.get(country), signName);
+    }
     return null;
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSignElement.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSignElement.java	(revision 31390)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSignElement.java	(revision 31391)
@@ -9,9 +9,9 @@
 
   public TrafficoSignElement(char glyph, Color c) {
-     if (c == null) {
-       throw new IllegalArgumentException();
-     }
-     this.color = c;
-     this.glyph = glyph;
+    if (c == null) {
+      throw new IllegalArgumentException();
+    }
+    this.color = c;
+    this.glyph = glyph;
   }
 
