Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31445)
@@ -88,5 +88,5 @@
    */
   public LatLon getLatLon() {
-    return movingLatLon;
+    return this.movingLatLon;
   }
 
@@ -97,5 +97,5 @@
    */
   public boolean isVisible() {
-    return visible;
+    return this.visible;
   }
 
@@ -116,5 +116,5 @@
    */
   public LatLon getTempLatLon() {
-    return tempLatLon;
+    return this.tempLatLon;
   }
 
@@ -159,5 +159,5 @@
    */
   public double getCa() {
-    return movingCa;
+    return this.movingCa;
   }
 
@@ -168,5 +168,5 @@
    */
   public double getTempCa() {
-    return tempCa;
+    return this.tempCa;
   }
 
@@ -195,4 +195,5 @@
    *
    * @param capturedAt
+   *          Epoch time when the image was captured.
    */
   public void setCapturedAt(long capturedAt) {
@@ -206,5 +207,5 @@
    */
   public long getCapturedAt() {
-    return capturedAt;
+    return this.capturedAt;
   }
 
@@ -212,5 +213,5 @@
    * Returns the date the picture was taken in the given format.
    *
-   * @param format
+   * @param format Format of the date. See {@link SimpleDateFormat}.
    * @return A String containing the date the picture was taken using the given
    *         format.
@@ -233,5 +234,5 @@
    * @return The date in Epoch format.
    */
-  public long getEpoch(String date, String format) {
+  public static long getEpoch(String date, String format) {
 
     SimpleDateFormat formatter = new SimpleDateFormat(format);
@@ -250,5 +251,5 @@
    * @return The current date in Epoch format.
    */
-  private long currentTime() {
+  private static long currentTime() {
     Calendar cal = Calendar.getInstance();
     return cal.getTimeInMillis();
@@ -271,4 +272,9 @@
    */
   public MapillarySequence getSequence() {
+    if (this.sequence == null) {
+      this.sequence = new MapillarySequence();
+      this.sequence.add(this);
+    }
+
     return this.sequence;
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31445)
@@ -20,6 +20,4 @@
   /** Unique instance of the class */
   public volatile static MapillaryData INSTANCE;
-  /** Enable this if you are using in Unit Tests */
-  public static boolean TEST_MODE = false;
 
   private final List<MapillaryAbstractImage> images;
@@ -35,7 +33,7 @@
    */
   private MapillaryData() {
-    images = new CopyOnWriteArrayList<>();
-    multiSelectedImages = new ArrayList<>();
-    selectedImage = null;
+    this.images = new CopyOnWriteArrayList<>();
+    this.multiSelectedImages = new ArrayList<>();
+    this.selectedImage = null;
 
     addListener(MapillaryPlugin.walkAction);
@@ -88,5 +86,5 @@
    */
   public void addListener(MapillaryDataListener lis) {
-    listeners.add(lis);
+    this.listeners.add(lis);
   }
 
@@ -98,5 +96,5 @@
    */
   public void removeListener(MapillaryDataListener lis) {
-    listeners.remove(lis);
+    this.listeners.remove(lis);
   }
 
@@ -124,5 +122,5 @@
    */
   public void setHighlightedImage(MapillaryAbstractImage image) {
-    highlightedImage = image;
+    this.highlightedImage = image;
   }
 
@@ -133,5 +131,5 @@
    */
   public MapillaryAbstractImage getHighlighted() {
-    return highlightedImage;
+    return this.highlightedImage;
   }
 
@@ -146,5 +144,5 @@
    */
   public synchronized void add(MapillaryAbstractImage image, boolean update) {
-    if (!images.contains(image)) {
+    if (!this.images.contains(image)) {
       this.images.add(image);
     }
@@ -157,6 +155,6 @@
    * Repaints mapView object.
    */
-  public synchronized void dataUpdated() {
-    if (!TEST_MODE)
+  public synchronized static void dataUpdated() {
+    if (Main.main != null)
       Main.map.mapView.repaint();
   }
@@ -168,5 +166,5 @@
    */
   public List<MapillaryAbstractImage> getImages() {
-    return images;
+    return this.images;
   }
 
@@ -177,12 +175,13 @@
    */
   public MapillaryAbstractImage getSelectedImage() {
-    return selectedImage;
+    return this.selectedImage;
   }
 
   private void fireImagesAdded() {
-    if (listeners.isEmpty())
-      return;
-    for (MapillaryDataListener lis : listeners)
-      lis.imagesAdded();
+    if (this.listeners.isEmpty())
+      return;
+    for (MapillaryDataListener lis : this.listeners)
+      if (lis != null)
+        lis.imagesAdded();
   }
 
@@ -197,5 +196,5 @@
     if (getSelectedImage().getSequence() == null)
       return;
-    MapillaryAbstractImage tempImage = selectedImage;
+    MapillaryAbstractImage tempImage = this.selectedImage;
     while (tempImage.next() != null) {
       tempImage = tempImage.next();
@@ -221,5 +220,5 @@
     if (getSelectedImage().getSequence() == null)
       return;
-    MapillaryAbstractImage tempImage = selectedImage;
+    MapillaryAbstractImage tempImage = this.selectedImage;
     while (tempImage.next() != null) {
       tempImage = tempImage.next();
@@ -241,5 +240,5 @@
     if (getSelectedImage().getSequence() == null)
       throw new IllegalStateException();
-    MapillaryAbstractImage tempImage = selectedImage;
+    MapillaryAbstractImage tempImage = this.selectedImage;
     while (tempImage.previous() != null) {
       tempImage = tempImage.previous();
@@ -265,5 +264,5 @@
     if (getSelectedImage().getSequence() == null)
       throw new IllegalStateException();
-    MapillaryAbstractImage tempImage = selectedImage;
+    MapillaryAbstractImage tempImage = this.selectedImage;
     while (tempImage.previous() != null) {
       tempImage = tempImage.previous();
@@ -295,8 +294,8 @@
    */
   public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) {
-    MapillaryAbstractImage oldImage = selectedImage;
-    selectedImage = image;
-    multiSelectedImages.clear();
-    multiSelectedImages.add(image);
+    MapillaryAbstractImage oldImage = this.selectedImage;
+    this.selectedImage = image;
+    this.multiSelectedImages.clear();
+    this.multiSelectedImages.add(image);
     if (image != null) {
       if (image instanceof MapillaryImage) {
@@ -320,15 +319,16 @@
       Main.map.mapView.zoomTo(MapillaryData.getInstance().getSelectedImage()
           .getLatLon());
-    if (Main.map != null)
+    if (Main.main != null)
       Main.map.mapView.repaint();
-    fireSelectedImageChanged(oldImage, selectedImage);
+    fireSelectedImageChanged(oldImage, this.selectedImage);
   }
 
   private void fireSelectedImageChanged(MapillaryAbstractImage oldImage,
       MapillaryAbstractImage newImage) {
-    if (listeners.isEmpty())
-      return;
-    for (MapillaryDataListener lis : listeners)
-      lis.selectedImageChanged(oldImage, newImage);
+    if (this.listeners.isEmpty())
+      return;
+    for (MapillaryDataListener lis : this.listeners)
+      if (lis != null)
+        lis.selectedImageChanged(oldImage, newImage);
   }
 
@@ -375,5 +375,5 @@
    */
   public List<MapillaryAbstractImage> getMultiSelectedImages() {
-    return multiSelectedImages;
+    return this.multiSelectedImages;
   }
 
@@ -384,5 +384,5 @@
    */
   public int size() {
-    return images.size();
+    return this.images.size();
   }
 }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31445)
@@ -27,5 +27,5 @@
    */
   public String getLocation() {
-    return location;
+    return this.location;
   }
 
@@ -34,4 +34,5 @@
    *
    * @param location
+   *          A String object containing the place where the image was taken.
    */
   public void setLocation(String location) {
@@ -73,5 +74,5 @@
    */
   public void addSign(String sign) {
-    signs.add(sign);
+    this.signs.add(sign);
   }
 
@@ -82,5 +83,5 @@
    */
   public List<String> getSigns() {
-    return signs;
+    return this.signs;
   }
 
@@ -102,5 +103,5 @@
    */
   public String getUser() {
-    return user;
+    return this.user;
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31445)
@@ -63,10 +63,11 @@
    * Returns the pictures of the file.
    *
-   * @return A BufferedImage object containing the picture,
-   *           or null if the {@link File} given in the constructor was null.
+   * @return A BufferedImage object containing the picture, or null if the
+   *         {@link File} given in the constructor was null.
    * @throws IOException
+   *           If the file parameter of the object isn't an image.
    */
   public BufferedImage getImage() throws IOException {
-    return file == null ? null : ImageIO.read(file);
+    return this.file == null ? null : ImageIO.read(this.file);
   }
 
@@ -77,5 +78,5 @@
    */
   public File getFile() {
-    return file;
+    return this.file;
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31445)
@@ -98,6 +98,6 @@
   private MapillaryLayer() {
     super(tr("Mapillary Images"));
-    data = MapillaryData.getInstance();
-    bounds = new CopyOnWriteArrayList<>();
+    this.data = MapillaryData.getInstance();
+    this.bounds = new CopyOnWriteArrayList<>();
     init();
   }
@@ -109,5 +109,5 @@
     if (INSTANCE == null)
       INSTANCE = this;
-    if (Main.map != null && Main.map.mapView != null) {
+    if (Main.main != null && Main.map.mapView != null) {
       setMode(new SelectMode());
       Main.map.mapView.addLayer(this);
@@ -119,5 +119,5 @@
         MapillaryDownloader.automaticDownload();
       if (MapillaryDownloader.getMode() == MapillaryDownloader.SEMIAUTOMATIC)
-        mode.zoomChanged();
+        this.mode.zoomChanged();
     }
     if (MapillaryPlugin.EXPORT_MENU != null) { // Does not execute when in
@@ -128,5 +128,6 @@
     }
     createHatchTexture();
-    data.dataUpdated();
+    if (Main.main != null)
+      MapillaryData.dataUpdated();
   }
 
@@ -171,5 +172,5 @@
    */
   public MapillaryData getMapillaryData() {
-    return data;
+    return this.data;
   }
 
@@ -183,6 +184,6 @@
     MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false);
     MapillaryPlugin.setMenuEnabled(MapillaryPlugin.ZOOM_MENU, false);
-    Main.map.mapView.removeMouseListener(mode);
-    Main.map.mapView.removeMouseMotionListener(mode);
+    Main.map.mapView.removeMouseListener(this.mode);
+    Main.map.mapView.removeMouseMotionListener(this.mode);
     MapView.removeEditLayerChangeListener(this);
     if (Main.map.mapView.getEditLayer() != null)
@@ -209,5 +210,5 @@
     double maxLat = -90;
     double maxLon = -180;
-    for (MapillaryAbstractImage img : data.getImages()) {
+    for (MapillaryAbstractImage img : this.data.getImages()) {
       if (img.getLatLon().lat() < minLat)
         minLat = img.getLatLon().lat();
@@ -225,5 +226,5 @@
   @Override
   public boolean isModified() {
-    for (MapillaryAbstractImage image : data.getImages())
+    for (MapillaryAbstractImage image : this.data.getImages())
       if (image.isModified())
         return true;
@@ -234,5 +235,5 @@
   public void setVisible(boolean visible) {
     super.setVisible(visible);
-    for (MapillaryAbstractImage img : data.getImages())
+    for (MapillaryAbstractImage img : this.data.getImages())
       img.setVisible(visible);
     MapillaryFilterDialog.getInstance().refresh();
@@ -244,5 +245,5 @@
    * @return background color for downloaded areas. Black by default
    */
-  private Color getBackgroundColor() {
+  private static Color getBackgroundColor() {
     return Main.pref.getColor(marktr("background"), Color.BLACK);
   }
@@ -253,5 +254,5 @@
    * @return background color for non-downloaded areas. Yellow by default
    */
-  private Color getOutsideColor() {
+  private static Color getOutsideColor() {
     return Main.pref.getColor(marktr("outside downloaded area"), Color.YELLOW);
   }
@@ -270,5 +271,5 @@
     big.drawLine(0, 15, 15, 0);
     Rectangle r = new Rectangle(0, 0, 15, 15);
-    hatched = new TexturePaint(bi, r);
+    this.hatched = new TexturePaint(bi, r);
   }
 
@@ -291,5 +292,5 @@
       }
       // paint remainder
-      g.setPaint(hatched);
+      g.setPaint(this.hatched);
       g.fill(a);
     }
@@ -302,7 +303,7 @@
 
     // Sets blue and red lines and enables/disables the buttons
-    if (data.getSelectedImage() != null) {
+    if (this.data.getSelectedImage() != null) {
       MapillaryImage[] closestImages = getClosestImagesFromDifferentSequences();
-      Point selected = mv.getPoint(data.getSelectedImage().getLatLon());
+      Point selected = mv.getPoint(this.data.getSelectedImage().getLatLon());
       if (closestImages[0] != null) {
         MapillaryLayer.BLUE = closestImages[0];
@@ -321,5 +322,5 @@
     }
     g.setColor(Color.WHITE);
-    for (MapillaryAbstractImage imageAbs : data.getImages()) {
+    for (MapillaryAbstractImage imageAbs : this.data.getImages()) {
       if (!imageAbs.isVisible())
         continue;
@@ -344,5 +345,5 @@
         MapillaryImage image = (MapillaryImage) imageAbs;
         ImageIcon icon;
-        if (!data.getMultiSelectedImages().contains(image))
+        if (!this.data.getMultiSelectedImages().contains(image))
           icon = MapillaryPlugin.MAP_ICON;
         else
@@ -357,5 +358,5 @@
         MapillaryImportedImage image = (MapillaryImportedImage) imageAbs;
         ImageIcon icon;
-        if (!data.getMultiSelectedImages().contains(image))
+        if (!this.data.getMultiSelectedImages().contains(image))
           icon = MapillaryPlugin.MAP_ICON_IMPORTED;
         else
@@ -364,6 +365,6 @@
       }
     }
-    if (mode instanceof JoinMode) {
-      mode.paint(g, mv, box);
+    if (this.mode instanceof JoinMode) {
+      this.mode.paint(g, mv, box);
     }
   }
@@ -382,9 +383,9 @@
         highlightColor.getGreen(), highlightColor.getBlue(), 100);
     g.setColor(highlightColorTransparent);
-    int s = size + highlightPointRadius;
+    int s = size + this.highlightPointRadius;
     while (s >= size) {
       int r = (int) Math.floor(s / 2d);
       g.fillRoundRect(p.x - r, p.y - r, s, s, r, r);
-      s -= highlightStep;
+      s -= this.highlightStep;
     }
     g.setColor(oldColor);
@@ -418,5 +419,5 @@
     g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2),
         Main.map.mapView);
-    if (data.getHighlighted() == image) {
+    if (this.data.getHighlighted() == image) {
       drawPointHighlight(g, p, 16);
     }
@@ -455,12 +456,12 @@
    */
   private MapillaryImage[] getClosestImagesFromDifferentSequences() {
-    if (!(data.getSelectedImage() instanceof MapillaryImage))
+    if (!(this.data.getSelectedImage() instanceof MapillaryImage))
       return new MapillaryImage[2];
-    MapillaryImage selected = (MapillaryImage) data.getSelectedImage();
+    MapillaryImage selected = (MapillaryImage) this.data.getSelectedImage();
     MapillaryImage[] ret = new MapillaryImage[2];
     double[] distances = { SEQUENCE_MAX_JUMP_DISTANCE,
         SEQUENCE_MAX_JUMP_DISTANCE };
-    LatLon selectedCoords = data.getSelectedImage().getLatLon();
-    for (MapillaryAbstractImage imagePrev : data.getImages()) {
+    LatLon selectedCoords = this.data.getSelectedImage().getLatLon();
+    for (MapillaryAbstractImage imagePrev : this.data.getImages()) {
       if (!(imagePrev instanceof MapillaryImage))
         continue;
@@ -498,5 +499,5 @@
     sb.append(tr("Total images:"));
     sb.append(" ");
-    sb.append(data.size());
+    sb.append(this.data.size());
     sb.append("\n");
     return sb.toString();
@@ -505,5 +506,5 @@
   @Override
   public String getToolTipText() {
-    return data.size() + " " + tr("images");
+    return this.data.size() + " " + tr("images");
   }
 
@@ -519,12 +520,8 @@
   }
 
-  /**
-   * When more data is downloaded, a delayed update is thrown, in order to wait
-   * for the data bounds to be set.
-   *
-   * @param event
-   */
   @Override
   public void dataChanged(DataChangedEvent event) {
+    // When more data is downloaded, a delayed update is thrown, in order to
+    // wait for the data bounds to be set.
     Main.worker.submit(new delayedDownload());
   }
@@ -607,10 +604,10 @@
   public void updateHelpText() {
     String ret = "";
-    if (data.size() > 0)
-      ret += tr("Total images: {0}", data.size());
+    if (this.data.size() > 0)
+      ret += tr("Total images: {0}", this.data.size());
     else
       ret += tr("No images found");
-    if (mode != null)
-      ret += " -- " + tr(mode.toString());
+    if (this.mode != null)
+      ret += " -- " + tr(this.mode.toString());
     Main.map.statusLine.setHelpText(ret);
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31445)
@@ -59,4 +59,5 @@
   /** Walk action */
   public static MapillaryWalkAction walkAction;
+  private final MapillaryUploadAction uploadAction;
 
   /** Menu button for the {@link MapillaryDownloadAction} action. */
@@ -76,4 +77,6 @@
   /** Menu button for the {@link MapillaryWalkAction} action. */
   public static JMenuItem WALK_MENU;
+  /** Menu button for the {@link MapillaryUploadAction} action. */
+  public static JMenuItem UPLOAD_MENU;
 
   /**
@@ -81,4 +84,5 @@
    *
    * @param info
+   *          Required information of the plugin. Obtained from the jar file.
    */
   public MapillaryPlugin(PluginInformation info) {
@@ -92,26 +96,30 @@
     MAP_SIGN = new ImageProvider("sign.png").get();
 
-    downloadAction = new MapillaryDownloadAction();
+    this.downloadAction = new MapillaryDownloadAction();
     walkAction = new MapillaryWalkAction();
-    exportAction = new MapillaryExportAction();
+    this.exportAction = new MapillaryExportAction();
     importAction = new MapillaryImportAction();
-    zoomAction = new MapillaryZoomAction();
-    downloadViewAction = new MapillaryDownloadViewAction();
-    importIntoSequenceAction = new MapillaryImportIntoSequenceAction();
-    joinAction = new MapillaryJoinAction();
+    this.zoomAction = new MapillaryZoomAction();
+    this.downloadViewAction = new MapillaryDownloadViewAction();
+    this.importIntoSequenceAction = new MapillaryImportIntoSequenceAction();
+    this.joinAction = new MapillaryJoinAction();
+    this.uploadAction = new MapillaryUploadAction();
 
     if (Main.main != null) { // important for headless mode
-      DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, downloadAction,
-          false);
-      EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, exportAction, false,
-          14);
+      DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu,
+          this.downloadAction, false);
+      EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, this.exportAction,
+          false, 14);
       IMPORT_INTO_SEQUENCE_MENU = MainMenu.add(Main.main.menu.fileMenu,
-          importIntoSequenceAction, false, 14);
+          this.importIntoSequenceAction, false, 14);
       IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false,
           14);
-      ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15);
+      UPLOAD_MENU = MainMenu.add(Main.main.menu.fileMenu, this.uploadAction,
+          false, 14);
+      ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, this.zoomAction, false,
+          15);
       DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu,
-          downloadViewAction, false, 14);
-      JOIN_MENU = MainMenu.add(Main.main.menu.dataMenu, joinAction, false);
+          this.downloadViewAction, false, 14);
+      JOIN_MENU = MainMenu.add(Main.main.menu.dataMenu, this.joinAction, false);
       WALK_MENU = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false);
 
@@ -182,8 +190,10 @@
    *
    * @param s
-   * @return A ImageProvider object for the given string or null if in headless mode.
+   *          The name of the file where the picture is.
+   * @return A ImageProvider object for the given string or null if in headless
+   *         mode.
    */
   public static ImageProvider getProvider(String s) {
-    if (Main.map == null)
+    if (Main.main == null)
       return null;
     else
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillarySequence.java	(revision 31445)
@@ -55,11 +55,12 @@
    */
   public long getCreatedAt() {
-    return created_at;
+    return this.created_at;
   }
 
   /**
-   * Adds a new MapillaryImage object to this object.
+   * Adds a new {@link MapillaryAbstractImage} object to the database.
    *
    * @param image
+   *          The {@link MapillaryAbstractImage} object to be added
    */
   public synchronized void add(MapillaryAbstractImage image) {
@@ -79,7 +80,8 @@
 
   /**
-   * Adds a set of MapillaryImage objects to this object.
+   * Adds a set of {@link MapillaryAbstractImage} objects to the database.
    *
    * @param images
+   *          The set of {@link MapillaryAbstractImage} objects to be added.
    */
   public synchronized void add(List<MapillaryAbstractImage> images) {
@@ -89,7 +91,8 @@
 
   /**
-   * Removes a MapillaryImage object from this object.
+   * Removes a {@link MapillaryAbstractImage} object from the database.
    *
    * @param image
+   *          The {@link MapillaryAbstractImage} object to be removed.
    */
   public void remove(MapillaryAbstractImage image) {
@@ -106,10 +109,10 @@
    */
   public MapillaryAbstractImage next(MapillaryAbstractImage image) {
-    if (!images.contains(image))
+    if (!this.images.contains(image))
       throw new IllegalArgumentException();
-    int i = images.indexOf(image);
-    if (i == images.size() - 1)
+    int i = this.images.indexOf(image);
+    if (i == this.images.size() - 1)
       return null;
-    return images.get(i + 1);
+    return this.images.get(i + 1);
   }
 
@@ -123,10 +126,10 @@
    */
   public MapillaryAbstractImage previous(MapillaryAbstractImage image) {
-    if (!images.contains(image))
+    if (!this.images.contains(image))
       throw new IllegalArgumentException();
-    int i = images.indexOf(image);
+    int i = this.images.indexOf(image);
     if (i == 0)
       return null;
-    return images.get(i - 1);
+    return this.images.get(i - 1);
   }
 
@@ -136,5 +139,7 @@
    *
    * @param image1
+   *          The first image.
    * @param image2
+   *          The second image.
    * @return The distance between two {@link MapillaryAbstractImage} objects
    *         belonging to the same {@link MapillarySequence}.
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryExportAction.java	(revision 31445)
@@ -58,6 +58,6 @@
     cancel.addActionListener(new CancelAction(pane));
 
-    dialog = new MapillaryExportDialog(ok);
-    pane.setMessage(dialog);
+    this.dialog = new MapillaryExportDialog(ok);
+    pane.setMessage(this.dialog);
     pane.setOptions(new JButton[] { ok, cancel });
 
@@ -69,8 +69,8 @@
     if (pane.getValue() != null
         && (int) pane.getValue() == JOptionPane.OK_OPTION
-        && dialog.chooser != null) {
-      if (dialog.group.isSelected(dialog.all.getModel())) {
+        && this.dialog.chooser != null) {
+      if (this.dialog.group.isSelected(this.dialog.all.getModel())) {
         export(MapillaryData.getInstance().getImages());
-      } else if (dialog.group.isSelected(dialog.sequence.getModel())) {
+      } else if (this.dialog.group.isSelected(this.dialog.sequence.getModel())) {
         ArrayList<MapillaryAbstractImage> images = new ArrayList<>();
         for (MapillaryAbstractImage image : MapillaryData.getInstance()
@@ -82,9 +82,9 @@
             images.add(image);
         export(images);
-      } else if (dialog.group.isSelected(dialog.selected.getModel())) {
+      } else if (this.dialog.group.isSelected(this.dialog.selected.getModel())) {
         export(MapillaryData.getInstance().getMultiSelectedImages());
       }
       // This option ignores the selected directory.
-    } else if (dialog.group.isSelected(dialog.rewrite.getModel())) {
+    } else if (this.dialog.group.isSelected(this.dialog.rewrite.getModel())) {
       ArrayList<MapillaryImportedImage> images = new ArrayList<>();
       for (MapillaryAbstractImage image : MapillaryData.getInstance()
@@ -110,5 +110,5 @@
   public void export(List<MapillaryAbstractImage> images) {
     Main.worker.submit(new Thread(new MapillaryExportManager(images,
-        dialog.chooser.getSelectedFile().toString())));
+        this.dialog.chooser.getSelectedFile().toString())));
   }
 
@@ -122,5 +122,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-      pane.setValue(JOptionPane.OK_OPTION);
+      this.pane.setValue(JOptionPane.OK_OPTION);
     }
   }
@@ -135,5 +135,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-      pane.setValue(JOptionPane.CANCEL_OPTION);
+      this.pane.setValue(JOptionPane.CANCEL_OPTION);
     }
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31445)
@@ -59,17 +59,17 @@
   @Override
   public void actionPerformed(ActionEvent e) {
-    chooser = new JFileChooser();
+    this.chooser = new JFileChooser();
     File startDirectory = new File(Main.pref.get("mapillary.start-directory",
         System.getProperty("user.home")));
-    chooser.setCurrentDirectory(startDirectory);
-    chooser.setDialogTitle(tr("Select pictures"));
-    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
-    chooser.setAcceptAllFileFilterUsed(false);
-    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg",
-        "jpeg", "png"));
-    chooser.setMultiSelectionEnabled(true);
-    if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
-      for (int i = 0; i < chooser.getSelectedFiles().length; i++) {
-        File file = chooser.getSelectedFiles()[i];
+    this.chooser.setCurrentDirectory(startDirectory);
+    this.chooser.setDialogTitle(tr("Select pictures"));
+    this.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+    this.chooser.setAcceptAllFileFilterUsed(false);
+    this.chooser.addChoosableFileFilter(new FileNameExtensionFilter("images",
+        "jpg", "jpeg", "png"));
+    this.chooser.setMultiSelectionEnabled(true);
+    if (this.chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
+      for (int i = 0; i < this.chooser.getSelectedFiles().length; i++) {
+        File file = this.chooser.getSelectedFiles()[i];
         Main.pref.put("mapillary.start-directory", file.getParent());
         MapillaryLayer.getInstance();
@@ -121,10 +121,13 @@
    *
    * @param file
+   *          The file where the picture is located.
    * @return The imported image.
    * @throws ImageReadException
+   *           If the file isn't an image.
    * @throws IOException
-   */
-  public MapillaryImportedImage readJPG(File file) throws ImageReadException,
-      IOException {
+   *           If the file doesn't have the valid metadata.
+   */
+  public MapillaryImportedImage readJPG(File file) throws IOException,
+      ImageReadException {
     final ImageMetadata metadata = Imaging.getMetadata(file);
     if (metadata instanceof JpegImageMetadata) {
@@ -170,4 +173,5 @@
    *
    * @param file
+   *          The file where the image is located.
    * @return The imported image.
    */
@@ -184,4 +188,5 @@
    *
    * @param file
+   *          The file where the image is located.
    * @param pos
    *          A {@link LatLon} object indicating the position in the map where
@@ -192,9 +197,9 @@
     double HORIZONTAL_DISTANCE = 0.0001;
     double horDev;
-    if (noTagsPics % 2 == 0)
-      horDev = HORIZONTAL_DISTANCE * noTagsPics / 2;
+    if (this.noTagsPics % 2 == 0)
+      horDev = HORIZONTAL_DISTANCE * this.noTagsPics / 2;
     else
-      horDev = -HORIZONTAL_DISTANCE * ((noTagsPics + 1) / 2);
-    noTagsPics++;
+      horDev = -HORIZONTAL_DISTANCE * ((this.noTagsPics + 1) / 2);
+    this.noTagsPics++;
     return new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file);
   }
@@ -204,4 +209,5 @@
    *
    * @param file
+   *          The file where the image is located.
    * @return The imported image.
    */
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportIntoSequenceAction.java	(revision 31445)
@@ -50,7 +50,7 @@
    */
   public MapillaryImportIntoSequenceAction() {
-    super(tr("Import pictures into sequence"), MapillaryPlugin.getProvider("icon24.png"),
-        tr("Import local pictures"), Shortcut.registerShortcut(
-            "Import Mapillary Sequence",
+    super(tr("Import pictures into sequence"), MapillaryPlugin
+        .getProvider("icon24.png"), tr("Import local pictures"), Shortcut
+        .registerShortcut("Import Mapillary Sequence",
             tr("Import pictures into Mapillary layer in a sequence"),
             KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false,
@@ -61,20 +61,20 @@
   @Override
   public void actionPerformed(ActionEvent arg0) {
-    images = new LinkedList<>();
-
-    chooser = new JFileChooser();
+    this.images = new LinkedList<>();
+
+    this.chooser = new JFileChooser();
     File startDirectory = new File(Main.pref.get("mapillary.start-directory",
         System.getProperty("user.home")));
-    chooser.setCurrentDirectory(startDirectory);
-    chooser.setDialogTitle(tr("Select pictures"));
-    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
-    chooser.setAcceptAllFileFilterUsed(false);
-    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg",
-        "jpeg"));
-    chooser.setMultiSelectionEnabled(true);
-
-    if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
-      for (int i = 0; i < chooser.getSelectedFiles().length; i++) {
-        File file = chooser.getSelectedFiles()[i];
+    this.chooser.setCurrentDirectory(startDirectory);
+    this.chooser.setDialogTitle(tr("Select pictures"));
+    this.chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
+    this.chooser.setAcceptAllFileFilterUsed(false);
+    this.chooser.addChoosableFileFilter(new FileNameExtensionFilter("images",
+        "jpg", "jpeg"));
+    this.chooser.setMultiSelectionEnabled(true);
+
+    if (this.chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
+      for (int i = 0; i < this.chooser.getSelectedFiles().length; i++) {
+        File file = this.chooser.getSelectedFiles()[i];
         if (file == null)
           break;
@@ -117,10 +117,13 @@
 
   /**
-   * Reads a jpg pictures that contains the needed GPS information (position and
+   * Reads a JPG pictures that contains the needed GPS information (position and
    * direction) and creates a new icon in that position.
    *
    * @param file
+   *          The file where the image is located.
    * @throws ImageReadException
+   *           If the file doesn't contain an image.
    * @throws IOException
+   *           If the file doesn't contain valid metadata.
    */
   public void readJPG(File file) throws ImageReadException, IOException {
@@ -162,5 +165,5 @@
       image.getCapturedAt();
 
-      images.add(image);
+      this.images.add(image);
     }
   }
@@ -170,7 +173,7 @@
    */
   public void joinImages() {
-    Collections.sort(images, new MapillaryEpochComparator());
+    Collections.sort(this.images, new MapillaryEpochComparator());
     MapillarySequence seq = new MapillarySequence();
-    for (MapillaryImportedImage img : images) {
+    for (MapillaryImportedImage img : this.images) {
       seq.add(img);
       img.setSequence(seq);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java	(revision 31445)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java	(revision 31445)
@@ -0,0 +1,85 @@
+package org.openstreetmap.josm.plugins.mapillary.actions;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.Dimension;
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.io.UnsupportedEncodingException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.actions.JosmAction;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
+import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryUploadDialog;
+import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthUtils;
+import org.openstreetmap.josm.tools.Shortcut;
+
+/**
+ * @author nokutu
+ *
+ */
+public class MapillaryUploadAction extends JosmAction implements
+    MapillaryDataListener {
+
+  private static final long serialVersionUID = -1405641273676919943L;
+
+  /**
+   * Main constructor.
+   */
+  public MapillaryUploadAction() {
+    super(tr("Upload pictures"), MapillaryPlugin.getProvider("icon24.png"),
+        tr("Upload pictures"), Shortcut.registerShortcut("Upload Mapillary",
+            tr("Upload Mapillary pictures"), KeyEvent.CHAR_UNDEFINED,
+            Shortcut.NONE), false, "mapillaryUpload", false);
+    this.setEnabled(false);
+    MapillaryData.getInstance().addListener(this);
+  }
+
+  @Override
+  public void actionPerformed(ActionEvent arg0) {
+    MapillaryUploadDialog dialog = new MapillaryUploadDialog();
+    JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE,
+        JOptionPane.OK_CANCEL_OPTION);
+    JDialog dlg = pane.createDialog(Main.parent, tr("Upload pictures."));
+    dlg.setMinimumSize(new Dimension(400, 150));
+    dlg.setVisible(true);
+
+    if (pane.getValue() != null
+        && (int) pane.getValue() == JOptionPane.OK_OPTION) {
+      if (dialog.sequence.isSelected()) {
+        try {
+          OAuthUtils.uploadSequence(MapillaryData.getInstance().getSelectedImage().getSequence());
+        } catch (InvalidKeyException e) {
+          Main.error(e);
+        } catch (UnsupportedEncodingException e) {
+          Main.error(e);
+        } catch (NoSuchAlgorithmException e) {
+          Main.error(e);
+        }
+      }
+    }
+  }
+
+  @Override
+  public void imagesAdded() {
+    // Nothing
+  }
+
+  @Override
+  public void selectedImageChanged(MapillaryAbstractImage oldImage,
+      MapillaryAbstractImage newImage) {
+    if (oldImage == null && newImage != null)
+      MapillaryPlugin.setMenuEnabled(MapillaryPlugin.UPLOAD_MENU, true);
+    else if (oldImage != null && newImage == null)
+      MapillaryPlugin.setMenuEnabled(MapillaryPlugin.UPLOAD_MENU, false);
+  }
+
+}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java	(revision 31445)
@@ -38,8 +38,8 @@
    */
   public MapillaryWalkAction() {
-    super(tr("Walk mode"), MapillaryPlugin.getProvider("icon24.png"), tr("Walk mode"),
-        Shortcut.registerShortcut("Mapillary walk", tr("Start walk mode"),
-            KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryWalk",
-        false);
+    super(tr("Walk mode"), MapillaryPlugin.getProvider("icon24.png"),
+        tr("Walk mode"), Shortcut.registerShortcut("Mapillary walk",
+            tr("Start walk mode"), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE),
+        false, "mapillaryWalk", false);
     this.setEnabled(false);
   }
@@ -55,9 +55,9 @@
     if (pane.getValue() != null
         && (int) pane.getValue() == JOptionPane.OK_OPTION) {
-      thread = new WalkThread((int) dialog.spin.getValue(),
+      this.thread = new WalkThread((int) dialog.spin.getValue(),
           dialog.waitForPicture.isSelected(),
           dialog.followSelection.isSelected(), dialog.goForward.isSelected());
       fireWalkStarted();
-      thread.start();
+      this.thread.start();
       MapillaryMainDialog.getInstance().setMode(MapillaryMainDialog.Mode.WALK);
     }
@@ -73,7 +73,8 @@
    *
    * @param lis
+   *          The listener to be added.
    */
   public void addListener(WalkListener lis) {
-    listeners.add(lis);
+    this.listeners.add(lis);
   }
 
@@ -82,14 +83,15 @@
    *
    * @param lis
+   *          The listener to be added.
    */
   public void removeListener(WalkListener lis) {
-    listeners.remove(lis);
+    this.listeners.remove(lis);
   }
 
   private void fireWalkStarted() {
-    if (listeners.isEmpty())
+    if (this.listeners.isEmpty())
       return;
-    for (WalkListener lis : listeners)
-      lis.walkStarted(thread);
+    for (WalkListener lis : this.listeners)
+      lis.walkStarted(this.thread);
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkListener.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkListener.java	(revision 31445)
@@ -13,5 +13,5 @@
    * Called when a new walk thread is started.
    *
-   * @param thread
+   * @param thread The thread executing the walk.
    */
   public void walkStarted(WalkThread thread);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/WalkThread.java	(revision 31445)
@@ -36,7 +36,12 @@
    *
    * @param interval
+   *          How often the images switch.
    * @param waitForPicture
+   *          If it must wait for the full resolution picture or just the
+   *          thumbnail.
    * @param followSelected
+   *          Zoom to each image that is selected.
    * @param goForward
+   *          true to go forward; false to go backwards.
    */
   public WalkThread(int interval, boolean waitForPicture,
@@ -46,6 +51,6 @@
     this.followSelected = followSelected;
     this.goForward = goForward;
-    data = MapillaryLayer.getInstance().getMapillaryData();
-    data.addListener(this);
+    this.data = MapillaryLayer.getInstance().getMapillaryData();
+    this.data.addListener(this);
   }
 
@@ -53,6 +58,6 @@
   public void run() {
     try {
-      while (!end && data.getSelectedImage().next() != null) {
-        MapillaryAbstractImage image = data.getSelectedImage();
+      while (!this.end && this.data.getSelectedImage().next() != null) {
+        MapillaryAbstractImage image = this.data.getSelectedImage();
         if (image instanceof MapillaryImage) {
           // Predownload next 10 thumbnails.
@@ -64,19 +69,19 @@
                 Utils.PICTURE.THUMBNAIL);
           }
-        }
-        if (waitForFullQuality)
-          // Start downloading 3 next full images.
-          for (int i = 0; i < 3; i++) {
-            if (image.next() == null)
-              break;
-            image = image.next();
-            Utils.downloadPicture((MapillaryImage) image, Utils.PICTURE.FULL_IMAGE);
-          }
+          if (this.waitForFullQuality)
+            // Start downloading 3 next full images.
+            for (int i = 0; i < 3; i++) {
+              if (image.next() == null)
+                break;
+              image = image.next();
+              Utils.downloadPicture((MapillaryImage) image,
+                  Utils.PICTURE.FULL_IMAGE);
+            }
+        }
         try {
           synchronized (this) {
-            if (waitForFullQuality
-                && data.getSelectedImage() instanceof MapillaryImage) {
+            if (this.waitForFullQuality && image instanceof MapillaryImage) {
               while (MapillaryMainDialog.getInstance().mapillaryImageDisplay
-                  .getImage() == lastImage
+                  .getImage() == this.lastImage
                   || MapillaryMainDialog.getInstance().mapillaryImageDisplay
                       .getImage() == null
@@ -86,5 +91,5 @@
             } else {
               while (MapillaryMainDialog.getInstance().mapillaryImageDisplay
-                  .getImage() == lastImage
+                  .getImage() == this.lastImage
                   || MapillaryMainDialog.getInstance().mapillaryImageDisplay
                       .getImage() == null
@@ -93,22 +98,23 @@
                 wait(100);
             }
-            while (paused)
+            while (this.paused)
               wait(100);
-            wait(interval);
-            while (paused)
+            wait(this.interval);
+            while (this.paused)
               wait(100);
           }
-          lastImage = MapillaryMainDialog.getInstance().mapillaryImageDisplay
+          this.lastImage = MapillaryMainDialog.getInstance().mapillaryImageDisplay
               .getImage();
-          lock.lock();
-          if (goForward)
-            data.selectNext(followSelected);
-          else
-            data.selectPrevious(followSelected);
-          lock.unlock();
+          this.lock.lock();
+          try {
+            if (this.goForward)
+              this.data.selectNext(this.followSelected);
+            else
+              this.data.selectPrevious(this.followSelected);
+          } finally {
+            this.lock.unlock();
+          }
         } catch (InterruptedException e) {
           return;
-        } finally {
-          lock.unlock();
         }
       }
@@ -121,10 +127,10 @@
   @Override
   public void interrupt() {
-    lock.lock();
+    this.lock.lock();
     try {
       super.interrupt();
     } catch (Exception e) {
     } finally {
-      lock.unlock();
+      this.lock.unlock();
     }
 
@@ -148,5 +154,5 @@
    */
   public void play() {
-    paused = false;
+    this.paused = false;
   }
 
@@ -155,5 +161,5 @@
    */
   public void pause() {
-    paused = true;
+    this.paused = true;
   }
 
@@ -187,6 +193,6 @@
       });
     } else {
-      end = true;
-      data.removeListener(this);
+      this.end = true;
+      this.data.removeListener(this);
       MapillaryMainDialog.getInstance()
           .setMode(MapillaryMainDialog.Mode.NORMAL);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java	(revision 31445)
@@ -39,5 +39,8 @@
    *
    * @param key
+   *          The key of the image.
    * @param type
+   *          The type of image that must be downloaded (THUMNAIL or
+   *          FULL_IMAGE).
    */
   public MapillaryCache(String key, Type type) {
@@ -47,10 +50,10 @@
       switch (type) {
         case FULL_IMAGE:
-          url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
+          this.url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
               + "/thumb-2048.jpg");
           this.key += ".FULL_IMAGE";
           break;
         case THUMBNAIL:
-          url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
+          this.url = new URL("https://d1cuyjsrcm0gby.cloudfront.net/" + key
               + "/thumb-320.jpg");
           this.key += ".THUMBNAIL";
@@ -64,10 +67,10 @@
   @Override
   public String getCacheKey() {
-    return key;
+    return this.key;
   }
 
   @Override
   public URL getUrl() {
-    return url;
+    return this.url;
   }
 
@@ -79,13 +82,8 @@
   @Override
   protected boolean isObjectLoadable() {
-    if (cacheData == null)
+    if (this.cacheData == null)
       return false;
-    byte[] content = cacheData.getContent();
+    byte[] content = this.cacheData.getContent();
     return content != null && content.length > 0;
   }
-
-  // @Override
-  protected boolean handleNotFound() {
-    return false;
-  }
 }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/Utils.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/Utils.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/Utils.java	(revision 31445)
@@ -41,5 +41,5 @@
    * in cache.
    *
-   * @param img
+   * @param img The image to be downloaded.
    * @param pic
    *          The picture type to be downloaded (full quality, thumbnail or
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java	(revision 31445)
@@ -21,5 +21,5 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param images
    *          Set of images that are going to be moved.
@@ -38,6 +38,6 @@
   @Override
   public void undo() {
-    for (MapillaryAbstractImage image : images) {
-      image.move(-x, -y);
+    for (MapillaryAbstractImage image : this.images) {
+      image.move(-this.x, -this.y);
       image.stopMoving();
     }
@@ -48,6 +48,6 @@
   @Override
   public void redo() {
-    for (MapillaryAbstractImage image : images) {
-      image.move(x, y);
+    for (MapillaryAbstractImage image : this.images) {
+      image.move(this.x, this.y);
       image.stopMoving();
     }
@@ -58,6 +58,6 @@
   @Override
   public String toString() {
-    return trn("Moved {0} image", "Moved {0} images", images.size(),
-        images.size());
+    return trn("Moved {0} image", "Moved {0} images", this.images.size(),
+        this.images.size());
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java	(revision 31445)
@@ -20,5 +20,5 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param images
    *          Set of images that is turned.
@@ -33,6 +33,6 @@
   @Override
   public void undo() {
-    for (MapillaryAbstractImage image : images) {
-      image.turn(-ca);
+    for (MapillaryAbstractImage image : this.images) {
+      image.turn(-this.ca);
       image.stopMoving();
     }
@@ -43,6 +43,6 @@
   @Override
   public void redo() {
-    for (MapillaryAbstractImage image : images) {
-      image.turn(ca);
+    for (MapillaryAbstractImage image : this.images) {
+      image.turn(this.ca);
       image.stopMoving();
     }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryCommand.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryCommand.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryCommand.java	(revision 31445)
@@ -7,5 +7,5 @@
 /**
  * Abstract class for any Mapillary command.
- * 
+ *
  * @author nokutu
  *
@@ -27,6 +27,6 @@
    * If two equal commands are applied consecutively to the same set of images,
    * they are summed in order to reduce them to just one command.
-   * 
-   * @param command
+   *
+   * @param command The command to be summed to last command.
    */
   public abstract void sum(MapillaryCommand command);
@@ -36,5 +36,5 @@
    */
   public void checkModified() {
-    for (MapillaryAbstractImage image : images)
+    for (MapillaryAbstractImage image : this.images)
       image.isModified = (image.tempLatLon == image.latLon || image.tempCa == image.ca);
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecord.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecord.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/MapillaryRecord.java	(revision 31445)
@@ -7,5 +7,5 @@
 /**
  * History record system in order to let the user undo and redo commands
- * 
+ *
  * @author nokutu
  *
@@ -26,12 +26,12 @@
    */
   public MapillaryRecord() {
-    commandList = new ArrayList<>();
-    position = -1;
-    listeners = new ArrayList<>();
+    this.commandList = new ArrayList<>();
+    this.position = -1;
+    this.listeners = new ArrayList<>();
   }
 
   /**
    * Returns the unique instance of the class.
-   * 
+   *
    * @return The unique instance of the class.
    */
@@ -44,6 +44,7 @@
   /**
    * Adds a listener.
-   * 
+   *
    * @param lis
+   *          The listener to be added.
    */
   public void addListener(MapillaryRecordListener lis) {
@@ -53,6 +54,7 @@
   /**
    * Removes the given listener.
-   * 
+   *
    * @param lis
+   *          The listener to be removed.
    */
   public void removeListener(MapillaryRecordListener lis) {
@@ -62,17 +64,19 @@
   /**
    * Adds a new command to the list.
-   * 
+   *
    * @param command
+   *          The command to be added.
    */
   public void addCommand(MapillaryCommand command) {
     // Checks if it is a continuation of last command
-    if (position != -1) {
+    if (this.position != -1) {
       boolean equalSets = true;
-      for (MapillaryAbstractImage img : commandList.get(position).images)
+      for (MapillaryAbstractImage img : this.commandList.get(this.position).images)
         if (!command.images.contains(img))
           equalSets = false;
       if (equalSets
-          && commandList.get(position).getClass() == command.getClass()) {
-        commandList.get(position).sum(command);
+          && this.commandList.get(this.position).getClass() == command
+              .getClass()) {
+        this.commandList.get(this.position).sum(command);
         fireRecordChanged();
         return;
@@ -80,8 +84,8 @@
     }
     // Adds the command to the last position of the list.
-    commandList.add(position + 1, command);
-    position++;
-    while (commandList.size() > position + 1) {
-      commandList.remove(position + 1);
+    this.commandList.add(this.position + 1, command);
+    this.position++;
+    while (this.commandList.size() > this.position + 1) {
+      this.commandList.remove(this.position + 1);
     }
     fireRecordChanged();
@@ -92,8 +96,8 @@
    */
   public void undo() {
-    if (position == -1)
+    if (this.position == -1)
       return;
-    commandList.get(position).undo();
-    position--;
+    this.commandList.get(this.position).undo();
+    this.position--;
     fireRecordChanged();
   }
@@ -103,13 +107,13 @@
    */
   public void redo() {
-    if (position + 1 >= commandList.size())
+    if (this.position + 1 >= this.commandList.size())
       return;
-    position++;
-    commandList.get(position).redo();
+    this.position++;
+    this.commandList.get(this.position).redo();
     fireRecordChanged();
   }
 
   private void fireRecordChanged() {
-    for (MapillaryRecordListener lis : listeners)
+    for (MapillaryRecordListener lis : this.listeners)
       if (lis != null)
         lis.recordChanged();
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31445)
@@ -14,4 +14,5 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
@@ -121,4 +122,5 @@
    *
    * @param bounds
+   *          A {@link Bounds} object containing the area to be downloaded.
    */
   public static void getImages(Bounds bounds) {
@@ -156,4 +158,5 @@
   private static boolean isAreaTooBig() {
     double area = 0;
+    System.out.println(Main.map.mapView.getLayersOfType(OsmDataLayer.class));
     for (Bounds bounds : Main.map.mapView.getEditLayer().data
         .getDataSourceBounds()) {
@@ -172,11 +175,13 @@
   public static int getMode() {
     if (Main.pref.get("mapillary.download-mode").equals(MODES[0])
-        && !MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC)
+        && (MapillaryLayer.INSTANCE == null || !MapillaryLayer.INSTANCE.TEMP_SEMIAUTOMATIC))
       return 0;
     else if (Main.pref.get("mapillary.download-mode").equals(MODES[1])
-        || MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC)
+        || (MapillaryLayer.INSTANCE != null && MapillaryLayer.getInstance().TEMP_SEMIAUTOMATIC))
       return 1;
     else if (Main.pref.get("mapillary.download-mode").equals(MODES[2]))
       return 2;
+    else if (Main.pref.get("mapillary.download-mode").equals(""))
+      return 0;
     else
       throw new IllegalStateException();
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java	(revision 31445)
@@ -20,5 +20,5 @@
  * This is the thread that downloads one of the images that are going to be
  * exported and writes them in a {@link ArrayBlockingQueue}.
- * 
+ *
  * @author nokutu
  * @see MapillaryExportManager
@@ -37,5 +37,5 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param image
    *          Image to be downloaded.
@@ -50,5 +50,5 @@
       ArrayBlockingQueue<BufferedImage> queue,
       ArrayBlockingQueue<MapillaryAbstractImage> queueImages) {
-    url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey()
+    this.url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey()
         + "/thumb-2048.jpg";
     this.queue = queue;
@@ -59,5 +59,5 @@
   @Override
   public void run() {
-    new MapillaryCache(image.getKey(), MapillaryCache.Type.FULL_IMAGE).submit(
+    new MapillaryCache(this.image.getKey(), MapillaryCache.Type.FULL_IMAGE).submit(
         this, false);
   }
@@ -67,6 +67,6 @@
       LoadResult result) {
     try {
-      queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent())));
-      queueImages.put(image);
+      this.queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent())));
+      this.queueImages.put(this.image);
     } catch (InterruptedException e) {
       Main.error(e);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31445)
@@ -44,5 +44,5 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param images
    *          Set of {@link MapillaryAbstractImage} objects to be exported.
@@ -53,9 +53,9 @@
     super(tr("Downloading") + "...", new PleaseWaitProgressMonitor(
         "Exporting Mapillary Images"), true);
-    queue = new ArrayBlockingQueue<>(10);
-    queueImages = new ArrayBlockingQueue<>(10);
+    this.queue = new ArrayBlockingQueue<>(10);
+    this.queueImages = new ArrayBlockingQueue<>(10);
 
     this.images = images;
-    amount = images.size();
+    this.amount = images.size();
     this.path = path;
   }
@@ -65,5 +65,9 @@
    *
    * @param images
+   *          The set of {@link MapillaryImportedImage} object that is going to
+   *          be rewritten.
    * @throws IOException
+   *           If the file of one of the {@link MapillaryImportedImage} objects
+   *           doesn't contain a picture.
    */
   public MapillaryExportManager(List<MapillaryImportedImage> images)
@@ -71,17 +75,17 @@
     super(tr("Downloading") + "...", new PleaseWaitProgressMonitor(
         "Exporting Mapillary Images"), true);
-    queue = new ArrayBlockingQueue<>(10);
-    queueImages = new ArrayBlockingQueue<>(10);
+    this.queue = new ArrayBlockingQueue<>(10);
+    this.queueImages = new ArrayBlockingQueue<>(10);
     for (MapillaryImportedImage image : images) {
-      queue.add(image.getImage());
-      queueImages.add(image);
+      this.queue.add(image.getImage());
+      this.queueImages.add(image);
     }
-    amount = images.size();
+    this.amount = images.size();
   }
 
   @Override
   protected void cancel() {
-    writer.interrupt();
-    ex.shutdown();
+    this.writer.interrupt();
+    this.ex.shutdown();
   }
 
@@ -90,10 +94,10 @@
       OsmTransferException {
     // Starts a writer thread in order to write the pictures on the disk.
-    writer = new MapillaryExportWriterThread(path, queue, queueImages, amount,
-        this.getProgressMonitor());
-    writer.start();
-    if (path == null) {
+    this.writer = new MapillaryExportWriterThread(this.path, this.queue,
+        this.queueImages, this.amount, this.getProgressMonitor());
+    this.writer.start();
+    if (this.path == null) {
       try {
-        writer.join();
+        this.writer.join();
       } catch (InterruptedException e) {
         Main.error(e);
@@ -101,11 +105,11 @@
       return;
     }
-    ex = new ThreadPoolExecutor(20, 35, 25, TimeUnit.SECONDS,
+    this.ex = new ThreadPoolExecutor(20, 35, 25, TimeUnit.SECONDS,
         new ArrayBlockingQueue<Runnable>(10));
-    for (MapillaryAbstractImage image : images) {
+    for (MapillaryAbstractImage image : this.images) {
       if (image instanceof MapillaryImage) {
         try {
-          ex.execute(new MapillaryExportDownloadThread((MapillaryImage) image,
-              queue, queueImages));
+          this.ex.execute(new MapillaryExportDownloadThread(
+              (MapillaryImage) image, this.queue, this.queueImages));
         } catch (Exception e) {
           Main.error(e);
@@ -113,6 +117,6 @@
       } else if (image instanceof MapillaryImportedImage) {
         try {
-          queue.put(((MapillaryImportedImage) image).getImage());
-          queueImages.put(image);
+          this.queue.put(((MapillaryImportedImage) image).getImage());
+          this.queueImages.put(image);
         } catch (InterruptedException e) {
           Main.error(e);
@@ -122,5 +126,5 @@
         // If the queue is full, waits for it to have more space
         // available before executing anything else.
-        while (ex.getQueue().remainingCapacity() == 0)
+        while (this.ex.getQueue().remainingCapacity() == 0)
           Thread.sleep(100);
       } catch (Exception e) {
@@ -129,5 +133,5 @@
     }
     try {
-      writer.join();
+      this.writer.join();
     } catch (InterruptedException e) {
       Main.error(e);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java	(revision 31445)
@@ -3,5 +3,5 @@
 import java.awt.image.BufferedImage;
 import java.io.BufferedOutputStream;
-import java.io.File;
+import java.io.ByteArrayOutputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -32,5 +32,5 @@
 /**
  * Writes the images from the queue in the file system.
- * 
+ *
  * @author nokutu
  * @see MapillaryExportManager
@@ -46,5 +46,5 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param path
    *          Path to write the pictures.
@@ -71,28 +71,29 @@
   @Override
   public void run() {
-    monitor.setCustomText("Downloaded 0/" + amount);
-    File tempFile = null;
+    this.monitor.setCustomText("Downloaded 0/" + this.amount);
+    //File tempFile = null;
     BufferedImage img;
     MapillaryAbstractImage mimg = null;
     String finalPath = "";
-    for (int i = 0; i < amount; i++) {
+    for (int i = 0; i < this.amount; i++) {
       try {
-        img = queue.take();
-        mimg = queueImages.take();
+        img = this.queue.take();
+        mimg = this.queueImages.take();
         if (img == null || mimg == null)
           throw new IllegalStateException("Null image");
-        if (path == null && mimg instanceof MapillaryImportedImage) {
+        if (this.path == null && mimg instanceof MapillaryImportedImage) {
           String path = ((MapillaryImportedImage) mimg).getFile().getPath();
           finalPath = path.substring(0, path.lastIndexOf('.'));
         } else if (mimg instanceof MapillaryImage)
-          finalPath = path + "/" + ((MapillaryImage) mimg).getKey();
+          finalPath = this.path + "/" + ((MapillaryImage) mimg).getKey();
         else if (mimg instanceof MapillaryImportedImage)
-          finalPath = path + "/"
+          finalPath = this.path + "/"
               + ((MapillaryImportedImage) mimg).getFile().getName();
         ;
-        // Creates a temporal file that is going to be deleted after
-        // writing the EXIF tags.
-        tempFile = new File(finalPath + ".tmp");
-        ImageIO.write(img, "jpg", tempFile);
+
+        // Transforms the image into a byte array.
+        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+        ImageIO.write(img, "jpg", outputStream);
+        byte[] imageBytes = outputStream.toByteArray();
 
         // Write EXIF tags
@@ -136,6 +137,6 @@
         OutputStream os = new BufferedOutputStream(new FileOutputStream(
             finalPath + ".jpg"));
-        new ExifRewriter().updateExifMetadataLossless(tempFile, os, outputSet);
-        tempFile.delete();
+        new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
+
         os.close();
       } catch (InterruptedException e) {
@@ -151,6 +152,6 @@
 
       // Increases the progress bar.
-      monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / amount);
-      monitor.setCustomText("Downloaded " + (i + 1) + "/" + amount);
+      this.monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / this.amount);
+      this.monitor.setCustomText("Downloaded " + (i + 1) + "/" + this.amount);
     }
   }
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java	(revision 31445)
@@ -31,9 +31,11 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param ex
    *          {@link ExecutorService} object that is executing this thread.
    * @param queryString
+   *          A String containing the parameters for the download.
    * @param layer
+   *          The layer to store the data.
    */
   public MapillaryImageInfoDownloaderThread(ExecutorService ex,
@@ -48,8 +50,8 @@
     try {
       BufferedReader br = new BufferedReader(new InputStreamReader(new URL(URL
-          + queryString).openStream(), "UTF-8"));
+          + this.queryString).openStream(), "UTF-8"));
       JsonObject jsonobj = Json.createReader(br).readObject();
       if (!jsonobj.getBoolean("more"))
-        ex.shutdown();
+        this.ex.shutdown();
       JsonArray jsonarr = jsonobj.getJsonArray("ims");
       JsonObject data;
@@ -57,5 +59,5 @@
         data = jsonarr.getJsonObject(i);
         String key = data.getString("key");
-        for (MapillaryAbstractImage image : layer.getMapillaryData()
+        for (MapillaryAbstractImage image : this.layer.getMapillaryData()
             .getImages()) {
           if (image instanceof MapillaryImage) {
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31445)
@@ -18,4 +18,5 @@
 import org.openstreetmap.josm.Main;
 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.MapillaryLayer;
@@ -44,5 +45,7 @@
    *
    * @param ex
+   *          {@link ExecutorService} executing this thread.
    * @param queryString
+   *          String containing the parameters for the download.
    */
   public MapillarySequenceDownloadThread(ExecutorService ex, String queryString) {
@@ -57,9 +60,9 @@
       BufferedReader br;
       br = new BufferedReader(new InputStreamReader(
-          new URL(URL + queryString).openStream(), "UTF-8"));
+          new URL(URL + this.queryString).openStream(), "UTF-8"));
       JsonObject jsonall = Json.createReader(br).readObject();
 
-      if (!jsonall.getBoolean("more") && !ex.isShutdown())
-        ex.shutdown();
+      if (!jsonall.getBoolean("more") && !this.ex.isShutdown())
+        this.ex.shutdown();
       JsonArray jsonseq = jsonall.getJsonArray("ss");
       boolean isSequenceWrong = false;
@@ -77,5 +80,5 @@
                 .getJsonNumber(j).doubleValue()));
           } catch (IndexOutOfBoundsException e) {
-            Main.warn("Mapillary bug at " + URL + queryString);
+            Main.warn("Mapillary bug at " + URL + this.queryString);
             isSequenceWrong = true;
           }
@@ -95,15 +98,15 @@
 
         LOCK.lock();
-        MapillaryImage.LOCK.lock();
+        MapillaryAbstractImage.LOCK.lock();
         try {
           for (MapillaryImage img : finalImages) {
-            if (layer.getMapillaryData().getImages().contains(img)) {
+            if (this.layer.getMapillaryData().getImages().contains(img)) {
               // The image in finalImages is substituted by the one in the
               // database, as they represent the same picture.
-              img = (MapillaryImage) layer.getMapillaryData().getImages()
-                  .get(layer.getMapillaryData().getImages().indexOf(img));
+              img = (MapillaryImage) this.layer.getMapillaryData().getImages()
+                  .get(this.layer.getMapillaryData().getImages().indexOf(img));
               sequence.add(img);
-              ((MapillaryImage) layer.getMapillaryData().getImages()
-                  .get(layer.getMapillaryData().getImages().indexOf(img)))
+              ((MapillaryImage) this.layer.getMapillaryData().getImages()
+                  .get(this.layer.getMapillaryData().getImages().indexOf(img)))
                   .setSequence(sequence);
               finalImages.set(finalImages.indexOf(img), img);
@@ -114,21 +117,21 @@
           }
         } finally {
-          MapillaryImage.LOCK.unlock();
+          MapillaryAbstractImage.LOCK.unlock();
           LOCK.unlock();
         }
 
-        layer.getMapillaryData().add(
+        this.layer.getMapillaryData().add(
             new ArrayList<MapillaryAbstractImage>(finalImages), false);
       }
     } catch (IOException e) {
-      Main.error("Error reading the url " + URL + queryString
+      Main.error("Error reading the url " + URL + this.queryString
           + " might be a Mapillary problem.");
     }
-    layer.getMapillaryData().dataUpdated();
+    MapillaryData.dataUpdated();
   }
 
   private boolean isInside(MapillaryAbstractImage image) {
-    for (int i = 0; i < layer.bounds.size(); i++)
-      if (layer.bounds.get(i).contains(image.getLatLon()))
+    for (int i = 0; i < this.layer.bounds.size(); i++)
+      if (this.layer.bounds.get(i).contains(image.getLatLon()))
         return true;
     return false;
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31445)
@@ -12,4 +12,5 @@
 
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
@@ -36,5 +37,7 @@
    *
    * @param queryStringParts
+   *          The query data.
    * @param layer
+   *          The layer to store the images.
    *
    */
@@ -46,5 +49,5 @@
 
     // TODO: Move this line to the appropriate place, here's no GET-request
-    Main.info("GET " + sequenceQueryString + " (Mapillary plugin)");
+    Main.info("GET " + this.sequenceQueryString + " (Mapillary plugin)");
 
     this.layer = layer;
@@ -52,5 +55,5 @@
 
   // TODO: Maybe move into a separate utility class?
-  private String buildQueryString(ConcurrentHashMap<String, Double> hash) {
+  private static String buildQueryString(ConcurrentHashMap<String, Double> hash) {
     StringBuilder ret = new StringBuilder("?client_id="
         + MapillaryDownloader.CLIENT_ID);
@@ -81,6 +84,6 @@
       Main.error("Mapillary download interrupted (probably because of closing the layer).");
     }
-    layer.updateHelpText();
-    layer.getMapillaryData().dataUpdated();
+    this.layer.updateHelpText();
+    MapillaryData.dataUpdated();
     MapillaryFilterDialog.getInstance().refresh();
     MapillaryMainDialog.getInstance().updateImage();
@@ -92,6 +95,6 @@
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillarySequenceDownloadThread(ex, sequenceQueryString
-          + "&page=" + page + "&limit=10"));
+      ex.execute(new MapillarySequenceDownloadThread(ex,
+          this.sequenceQueryString + "&page=" + page + "&limit=10"));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(500);
@@ -99,5 +102,5 @@
     }
     ex.awaitTermination(15, TimeUnit.SECONDS);
-    layer.getMapillaryData().dataUpdated();
+    MapillaryData.dataUpdated();
   }
 
@@ -107,6 +110,6 @@
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillaryImageInfoDownloaderThread(ex, imageQueryString
-          + "&page=" + page + "&limit=20", layer));
+      ex.execute(new MapillaryImageInfoDownloaderThread(ex,
+          this.imageQueryString + "&page=" + page + "&limit=20", this.layer));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(100);
@@ -121,6 +124,6 @@
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillaryTrafficSignDownloaderThread(ex, signQueryString
-          + "&page=" + page + "&limit=20", layer));
+      ex.execute(new MapillaryTrafficSignDownloaderThread(ex,
+          this.signQueryString + "&page=" + page + "&limit=20", this.layer));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(100);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloaderThread.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloaderThread.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryTrafficSignDownloaderThread.java	(revision 31445)
@@ -36,5 +36,7 @@
    *          {@link ExecutorService} object that is executing this thread.
    * @param queryString
+   *          A String containing the parameter for the download.
    * @param layer
+   *          The layer to store the data.
    */
   public MapillaryTrafficSignDownloaderThread(ExecutorService ex,
@@ -50,8 +52,8 @@
     try {
       br = new BufferedReader(new InputStreamReader(
-          new URL(URL + queryString).openStream(), "UTF-8"));
+          new URL(URL + this.queryString).openStream(), "UTF-8"));
       JsonObject jsonobj = Json.createReader(br).readObject();
       if (!jsonobj.getBoolean("more")) {
-        ex.shutdown();
+        this.ex.shutdown();
       }
       JsonArray jsonarr = jsonobj.getJsonArray("ims");
@@ -66,5 +68,5 @@
             for (int k = 0; k < rects.size(); k++) {
               JsonObject data = rects.getJsonObject(k);
-              for (MapillaryAbstractImage image : layer.getMapillaryData()
+              for (MapillaryAbstractImage image : this.layer.getMapillaryData()
                   .getImages())
                 if (image instanceof MapillaryImage
@@ -79,5 +81,5 @@
           for (int j = 0; j < rects.size(); j++) {
             JsonObject data = rects.getJsonObject(j);
-            for (MapillaryAbstractImage image : layer.getMapillaryData()
+            for (MapillaryAbstractImage image : this.layer.getMapillaryData()
                 .getImages())
               if (image instanceof MapillaryImage
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31445)
@@ -3,4 +3,5 @@
 import static org.openstreetmap.josm.tools.I18n.tr;
 
+import java.awt.AWTEvent;
 import java.awt.Cursor;
 import java.awt.event.ActionEvent;
@@ -13,5 +14,5 @@
 
 import javax.swing.JLabel;
-import javax.swing.SwingUtilities;
+import javax.swing.SwingConstants;
 
 import org.openstreetmap.josm.Main;
@@ -35,9 +36,9 @@
    */
   public HyperlinkLabel() {
-    super(tr("View in website"), SwingUtilities.RIGHT);
+    super(tr("View in website"), SwingConstants.RIGHT);
     this.addActionListener(this);
     setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
 
-    enableEvents(MouseEvent.MOUSE_EVENT_MASK);
+    enableEvents(AWTEvent.MOUSE_EVENT_MASK);
   }
 
@@ -56,4 +57,5 @@
    *
    * @param key
+   *          The key of the image that the hyperlink will point to.
    */
   public void setURL(String key) {
@@ -75,5 +77,5 @@
    */
   public String getNormalText() {
-    return text;
+    return this.text;
   }
 
@@ -94,7 +96,8 @@
    *
    * @param listener
+   *          The listener to be added.
    */
   public void addActionListener(ActionListener listener) {
-    listenerList.add(ActionListener.class, listener);
+    this.listenerList.add(ActionListener.class, listener);
   }
 
@@ -104,7 +107,8 @@
    *
    * @param listener
+   *          The listener to be added.
    */
   public void removeActionListener(ActionListener listener) {
-    listenerList.remove(ActionListener.class, listener);
+    this.listenerList.remove(ActionListener.class, listener);
   }
 
@@ -115,5 +119,5 @@
    */
   protected void fireActionPerformed(ActionEvent evt) {
-    Object[] listeners = listenerList.getListenerList();
+    Object[] listeners = this.listenerList.getListenerList();
     for (int i = 0; i < listeners.length; i += 2) {
       if (listeners[i] == ActionListener.class) {
@@ -131,5 +135,5 @@
     if (desktop.isSupported(Desktop.Action.BROWSE)) {
       try {
-        desktop.browse(url.toURI());
+        desktop.browse(this.url.toURI());
       } catch (IOException | URISyntaxException e1) {
         Main.error(e1);
@@ -138,5 +142,5 @@
       Runtime runtime = Runtime.getRuntime();
       try {
-        runtime.exec("xdg-open " + url);
+        runtime.exec("xdg-open " + this.url);
       } catch (IOException exc) {
         exc.printStackTrace();
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryExportDialog.java	(revision 31445)
@@ -56,6 +56,7 @@
   /**
    * Main constructor.
-   * 
+   *
    * @param ok
+   *          The button for to OK option.
    */
   public MapillaryExportDialog(JButton ok) {
@@ -66,49 +67,49 @@
 
     RewriteButtonAction action = new RewriteButtonAction(this);
-    group = new ButtonGroup();
-    all = new JRadioButton(action);
-    all.setText(tr("Export all images"));
-    sequence = new JRadioButton(action);
-    sequence.setText(tr("Export selected sequence"));
-    selected = new JRadioButton(action);
-    selected.setText(tr("Export selected images"));
-    rewrite = new JRadioButton(action);
-    rewrite.setText(tr("Rewrite imported images"));
-    group.add(all);
-    group.add(sequence);
-    group.add(selected);
-    group.add(rewrite);
+    this.group = new ButtonGroup();
+    this.all = new JRadioButton(action);
+    this.all.setText(tr("Export all images"));
+    this.sequence = new JRadioButton(action);
+    this.sequence.setText(tr("Export selected sequence"));
+    this.selected = new JRadioButton(action);
+    this.selected.setText(tr("Export selected images"));
+    this.rewrite = new JRadioButton(action);
+    this.rewrite.setText(tr("Rewrite imported images"));
+    this.group.add(this.all);
+    this.group.add(this.sequence);
+    this.group.add(this.selected);
+    this.group.add(this.rewrite);
     // Some options are disabled depending on the circumstances
     if (MapillaryData.getInstance().getSelectedImage() == null
         || !(MapillaryData.getInstance().getSelectedImage() instanceof MapillaryImage && ((MapillaryImage) MapillaryData
             .getInstance().getSelectedImage()).getSequence() != null)) {
-      sequence.setEnabled(false);
+      this.sequence.setEnabled(false);
     }
     if (MapillaryData.getInstance().getMultiSelectedImages().isEmpty()) {
-      selected.setEnabled(false);
+      this.selected.setEnabled(false);
     }
-    rewrite.setEnabled(false);
+    this.rewrite.setEnabled(false);
     for (MapillaryAbstractImage img : MapillaryData.getInstance().getImages())
       if (img instanceof MapillaryImportedImage)
-        rewrite.setEnabled(true);
+        this.rewrite.setEnabled(true);
 
-    path = new JLabel(tr("Select a folder"));
-    choose = new JButton(tr("Explore"));
-    choose.addActionListener(this);
+    this.path = new JLabel(tr("Select a folder"));
+    this.choose = new JButton(tr("Explore"));
+    this.choose.addActionListener(this);
 
     // All options belong to the same jpanel so the are in line.
     JPanel jpanel = new JPanel();
     jpanel.setLayout(new BoxLayout(jpanel, BoxLayout.PAGE_AXIS));
-    jpanel.add(all);
-    jpanel.add(sequence);
-    jpanel.add(selected);
-    jpanel.add(rewrite);
+    jpanel.add(this.all);
+    jpanel.add(this.sequence);
+    jpanel.add(this.selected);
+    jpanel.add(this.rewrite);
     jpanel.setAlignmentX(Component.CENTER_ALIGNMENT);
-    path.setAlignmentX(Component.CENTER_ALIGNMENT);
-    choose.setAlignmentX(Component.CENTER_ALIGNMENT);
+    this.path.setAlignmentX(Component.CENTER_ALIGNMENT);
+    this.choose.setAlignmentX(Component.CENTER_ALIGNMENT);
 
     add(jpanel);
-    add(path);
-    add(choose);
+    add(this.path);
+    add(this.choose);
   }
 
@@ -118,15 +119,15 @@
   @Override
   public void actionPerformed(ActionEvent e) {
-    chooser = new JFileChooser();
-    chooser.setCurrentDirectory(new java.io.File(System
+    this.chooser = new JFileChooser();
+    this.chooser.setCurrentDirectory(new java.io.File(System
         .getProperty("user.home")));
-    chooser.setDialogTitle(tr("Select a directory"));
-    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
-    chooser.setAcceptAllFileFilterUsed(false);
+    this.chooser.setDialogTitle(tr("Select a directory"));
+    this.chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+    this.chooser.setAcceptAllFileFilterUsed(false);
 
-    if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
-      path.setText(chooser.getSelectedFile().toString());
+    if (this.chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
+      this.path.setText(this.chooser.getSelectedFile().toString());
       this.updateUI();
-      ok.setEnabled(true);
+      this.ok.setEnabled(true);
     }
   }
@@ -157,10 +158,10 @@
     @Override
     public void actionPerformed(ActionEvent arg0) {
-      choose.setEnabled(!rewrite.isSelected());
-      if (rewrite.isSelected()) {
-        lastPath = dlg.path.getText();
-        dlg.path.setText(" ");
-      } else if (lastPath != null) {
-        dlg.path.setText(lastPath);
+      MapillaryExportDialog.this.choose.setEnabled(!MapillaryExportDialog.this.rewrite.isSelected());
+      if (MapillaryExportDialog.this.rewrite.isSelected()) {
+        this.lastPath = this.dlg.path.getText();
+        this.dlg.path.setText(" ");
+      } else if (this.lastPath != null) {
+        this.dlg.path.setText(this.lastPath);
       }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterChooseSigns.java	(revision 31445)
@@ -49,16 +49,16 @@
 
   private MapillaryFilterChooseSigns() {
-    maxSpeed.setSelected(true);
-    stop.setSelected(true);
-    giveWay.setSelected(true);
-    roundabout.setSelected(true);
-    access.setSelected(true);
-    intersection.setSelected(true);
-    direction.setSelected(true);
-    uneven.setSelected(true);
-    noParking.setSelected(true);
-    noOvertaking.setSelected(true);
-    crossing.setSelected(true);
-    noTurn.setSelected(true);
+    this.maxSpeed.setSelected(true);
+    this.stop.setSelected(true);
+    this.giveWay.setSelected(true);
+    this.roundabout.setSelected(true);
+    this.access.setSelected(true);
+    this.intersection.setSelected(true);
+    this.direction.setSelected(true);
+    this.uneven.setSelected(true);
+    this.noParking.setSelected(true);
+    this.noOvertaking.setSelected(true);
+    this.crossing.setSelected(true);
+    this.noTurn.setSelected(true);
 
     // Max speed sign
@@ -67,5 +67,5 @@
     maxspeedLabel.setIcon(new ImageProvider("signs/speed.png").get());
     maxspeedPanel.add(maxspeedLabel);
-    maxspeedPanel.add(maxSpeed);
+    maxspeedPanel.add(this.maxSpeed);
     this.add(maxspeedPanel);
 
@@ -75,5 +75,5 @@
     stopLabel.setIcon(new ImageProvider("signs/stop.png").get());
     stopPanel.add(stopLabel);
-    stopPanel.add(stop);
+    stopPanel.add(this.stop);
     this.add(stopPanel);
 
@@ -83,5 +83,5 @@
     giveWayLabel.setIcon(new ImageProvider("signs/right_of_way.png").get());
     giveWayPanel.add(giveWayLabel);
-    giveWayPanel.add(giveWay);
+    giveWayPanel.add(this.giveWay);
     this.add(giveWayPanel);
 
@@ -92,5 +92,5 @@
         .get());
     roundaboutPanel.add(roundaboutLabel);
-    roundaboutPanel.add(roundabout);
+    roundaboutPanel.add(this.roundabout);
     this.add(roundaboutPanel);
 
@@ -100,5 +100,5 @@
     noEntryLabel.setIcon(new ImageProvider("signs/no_entry.png").get());
     noEntryPanel.add(noEntryLabel);
-    noEntryPanel.add(access);
+    noEntryPanel.add(this.access);
     this.add(noEntryPanel);
 
@@ -109,5 +109,5 @@
         .setIcon(new ImageProvider("signs/intersection_danger.png").get());
     intersectionPanel.add(intersectionLabel);
-    intersectionPanel.add(intersection);
+    intersectionPanel.add(this.intersection);
     this.add(intersectionPanel);
 
@@ -118,5 +118,5 @@
         .get());
     directionPanel.add(directionLabel);
-    directionPanel.add(direction);
+    directionPanel.add(this.direction);
     this.add(directionPanel);
 
@@ -126,5 +126,5 @@
     noTurnLabel.setIcon(new ImageProvider("signs/no_turn.png").get());
     noTurnPanel.add(noTurnLabel);
-    noTurnPanel.add(noTurn);
+    noTurnPanel.add(this.noTurn);
     this.add(noTurnPanel);
 
@@ -134,5 +134,5 @@
     unevenLabel.setIcon(new ImageProvider("signs/uneaven.png").get());
     unevenPanel.add(unevenLabel);
-    unevenPanel.add(uneven);
+    unevenPanel.add(this.uneven);
     this.add(unevenPanel);
 
@@ -142,5 +142,5 @@
     noParkingLabel.setIcon(new ImageProvider("signs/no_parking.png").get());
     noParkingPanel.add(noParkingLabel);
-    noParkingPanel.add(noParking);
+    noParkingPanel.add(this.noParking);
     this.add(noParkingPanel);
 
@@ -151,5 +151,5 @@
         .get());
     noOvertakingPanel.add(noOvertakingLabel);
-    noOvertakingPanel.add(noOvertaking);
+    noOvertakingPanel.add(this.noOvertaking);
     this.add(noOvertakingPanel);
 
@@ -159,5 +159,5 @@
     crossingLabel.setIcon(new ImageProvider("signs/crossing.png").get());
     crossingPanel.add(crossingLabel);
-    crossingPanel.add(crossing);
+    crossingPanel.add(this.crossing);
     this.add(crossingPanel);
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java	(revision 31445)
@@ -78,10 +78,10 @@
       "prohibitory_noturn" };
   /** The the {@link JCheckBox} where the respective tag should be searched */
-  private final JCheckBox[] SIGN_CHECKBOXES = { signFilter.maxSpeed,
-      signFilter.stop, signFilter.giveWay, signFilter.roundabout,
-      signFilter.access, signFilter.access, signFilter.intersection,
-      signFilter.direction, signFilter.direction, signFilter.intersection,
-      signFilter.uneven, signFilter.noParking, signFilter.noOvertaking,
-      signFilter.crossing, signFilter.noTurn, signFilter.noTurn };
+  private final JCheckBox[] SIGN_CHECKBOXES = { this.signFilter.maxSpeed,
+      this.signFilter.stop, this.signFilter.giveWay, this.signFilter.roundabout,
+      this.signFilter.access, this.signFilter.access, this.signFilter.intersection,
+      this.signFilter.direction, this.signFilter.direction, this.signFilter.intersection,
+      this.signFilter.uneven, this.signFilter.noParking, this.signFilter.noOvertaking,
+      this.signFilter.crossing, this.signFilter.noTurn, this.signFilter.noTurn };
 
   private MapillaryFilterDialog() {
@@ -91,42 +91,42 @@
             KeyEvent.VK_M, Shortcut.NONE), 200);
 
-    signChooser.setEnabled(false);
+    this.signChooser.setEnabled(false);
     JPanel signChooserPanel = new JPanel();
     signChooserPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
-    signChooserPanel.add(signChooser);
+    signChooserPanel.add(this.signChooser);
 
     JPanel fromPanel = new JPanel();
     fromPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
     fromPanel.add(new JLabel("Not older than: "));
-    spinner = new SpinnerNumberModel(1, 0, 10000, 1);
-    fromPanel.add(new JSpinner(spinner));
-    time = new JComboBox<>(TIME_LIST);
-    fromPanel.add(time);
+    this.spinner = new SpinnerNumberModel(1, 0, 10000, 1);
+    fromPanel.add(new JSpinner(this.spinner));
+    this.time = new JComboBox<>(TIME_LIST);
+    fromPanel.add(this.time);
 
     JPanel userSearchPanel = new JPanel();
     userSearchPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
-    user = new JTextField(10);
-    user.addActionListener(new UpdateAction());
+    this.user = new JTextField(10);
+    this.user.addActionListener(new UpdateAction());
     userSearchPanel.add(new JLabel("User"));
-    userSearchPanel.add(user);
-
-    imported.setSelected(true);
-    downloaded.setSelected(true);
+    userSearchPanel.add(this.user);
+
+    this.imported.setSelected(true);
+    this.downloaded.setSelected(true);
 
     JPanel col1 = new JPanel(new GridLayout(2, 1));
-    col1.add(downloaded);
+    col1.add(this.downloaded);
     col1.add(fromPanel);
-    panel.add(col1);
+    this.panel.add(col1);
     JPanel col2 = new JPanel(new GridLayout(2, 1));
-    col2.add(imported);
+    col2.add(this.imported);
     col2.add(userSearchPanel);
-    panel.add(col2);
+    this.panel.add(col2);
     JPanel col3 = new JPanel(new GridLayout(2, 1));
-    col3.add(onlySigns);
+    col3.add(this.onlySigns);
     col3.add(signChooserPanel);
-    panel.add(col3);
-
-    createLayout(panel, true,
-        Arrays.asList(new SideButton[] { updateButton, resetButton }));
+    this.panel.add(col3);
+
+    createLayout(this.panel, true,
+        Arrays.asList(new SideButton[] { this.updateButton, this.resetButton }));
   }
 
@@ -156,11 +156,11 @@
    */
   public void reset() {
-    imported.setSelected(true);
-    downloaded.setSelected(true);
-    onlySigns.setEnabled(true);
-    onlySigns.setSelected(false);
-    user.setText("");
-    time.setSelectedItem(TIME_LIST[0]);
-    spinner.setValue(1);
+    this.imported.setSelected(true);
+    this.downloaded.setSelected(true);
+    this.onlySigns.setEnabled(true);
+    this.onlySigns.setSelected(false);
+    this.user.setText("");
+    this.time.setSelectedItem(TIME_LIST[0]);
+    this.spinner.setValue(1);
     refresh();
   }
@@ -195,6 +195,6 @@
           }
         }
-        if (!user.getText().equals("")
-            && !user.getText().equals(((MapillaryImage) img).getUser())) {
+        if (!this.user.getText().equals("")
+            && !this.user.getText().equals(((MapillaryImage) img).getUser())) {
           img.setVisible(false);
           continue;
@@ -203,7 +203,7 @@
       // Calculates the amount of days since the image was taken
       Long currentTime = currentTime();
-      if (time.getSelectedItem().equals(TIME_LIST[1])) {
+      if (this.time.getSelectedItem().equals(TIME_LIST[1])) {
         if (img.getCapturedAt() < currentTime
-            - ((Integer) spinner.getValue()).longValue() * 365 * 24 * 60 * 60
+            - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60 * 60
             * 1000) {
           img.setVisible(false);
@@ -211,7 +211,7 @@
         }
       }
-      if (time.getSelectedItem().equals(TIME_LIST[2])) {
+      if (this.time.getSelectedItem().equals(TIME_LIST[2])) {
         if (img.getCapturedAt() < currentTime
-            - ((Integer) spinner.getValue()).longValue() * 30 * 24 * 60 * 60
+            - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60 * 60
             * 1000) {
           img.setVisible(false);
@@ -219,7 +219,7 @@
         }
       }
-      if (time.getSelectedItem().equals(TIME_LIST[3])) {
+      if (this.time.getSelectedItem().equals(TIME_LIST[3])) {
         if (img.getCapturedAt() < currentTime
-            - ((Integer) spinner.getValue()).longValue() * 60 * 60 * 1000) {
+            - ((Integer) this.spinner.getValue()).longValue() * 60 * 60 * 1000) {
           img.setVisible(false);
           continue;
@@ -240,6 +240,6 @@
    */
   private boolean checkSigns(MapillaryImage img) {
-    for (int i = 0; i < SIGN_TAGS.length; i++) {
-      if (checkSign(img, SIGN_CHECKBOXES[i], SIGN_TAGS[i]))
+    for (int i = 0; i < this.SIGN_TAGS.length; i++) {
+      if (checkSign(img, this.SIGN_CHECKBOXES[i], this.SIGN_TAGS[i]))
         return true;
     }
@@ -247,5 +247,5 @@
   }
 
-  private boolean checkSign(MapillaryImage img, JCheckBox signCheckBox,
+  private static boolean checkSign(MapillaryImage img, JCheckBox signCheckBox,
       String singString) {
     boolean contains = false;
@@ -259,5 +259,5 @@
   }
 
-  private long currentTime() {
+  private static long currentTime() {
     Calendar cal = Calendar.getInstance();
     return cal.getTimeInMillis();
@@ -274,5 +274,5 @@
     @Override
     public void actionPerformed(ActionEvent arg0) {
-      onlySigns.setEnabled(downloaded.isSelected());
+      MapillaryFilterDialog.this.onlySigns.setEnabled(MapillaryFilterDialog.this.downloaded.isSelected());
     }
   }
@@ -318,5 +318,5 @@
     @Override
     public void actionPerformed(ActionEvent arg0) {
-      signChooser.setEnabled(onlySigns.isSelected());
+      MapillaryFilterDialog.this.signChooser.setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected());
     }
   }
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryHistoryDialog.java	(revision 31445)
@@ -5,4 +5,5 @@
 import java.awt.Component;
 import java.awt.Dimension;
+import java.awt.GridBagConstraints;
 import java.awt.GridBagLayout;
 import java.awt.event.ActionEvent;
@@ -50,6 +51,6 @@
   private final DefaultTreeModel redoTreeModel = new DefaultTreeModel(
       new DefaultMutableTreeNode());
-  private final JTree undoTree = new JTree(undoTreeModel);
-  private final JTree redoTree = new JTree(redoTreeModel);
+  private final JTree undoTree = new JTree(this.undoTreeModel);
+  private final JTree redoTree = new JTree(this.redoTreeModel);
 
   private JSeparator separator = new JSeparator();
@@ -67,29 +68,29 @@
     MapillaryRecord.getInstance().addListener(this);
 
-    undoTree.expandRow(0);
-    undoTree.setShowsRootHandles(true);
-    undoTree.setRootVisible(false);
-    undoTree.setCellRenderer(new MapillaryCellRenderer());
-    redoTree.expandRow(0);
-    redoTree.setCellRenderer(new MapillaryCellRenderer());
-    redoTree.setShowsRootHandles(true);
-    redoTree.setRootVisible(false);
+    this.undoTree.expandRow(0);
+    this.undoTree.setShowsRootHandles(true);
+    this.undoTree.setRootVisible(false);
+    this.undoTree.setCellRenderer(new MapillaryCellRenderer());
+    this.redoTree.expandRow(0);
+    this.redoTree.setCellRenderer(new MapillaryCellRenderer());
+    this.redoTree.setShowsRootHandles(true);
+    this.redoTree.setRootVisible(false);
 
     JPanel treesPanel = new JPanel(new GridBagLayout());
-    treesPanel.add(spacer, GBC.eol());
-    spacer.setVisible(false);
-    treesPanel.add(undoTree, GBC.eol().fill(GBC.HORIZONTAL));
-    separator.setVisible(false);
-    treesPanel.add(separator, GBC.eol().fill(GBC.HORIZONTAL));
-    treesPanel.add(redoTree, GBC.eol().fill(GBC.HORIZONTAL));
+    treesPanel.add(this.spacer, GBC.eol());
+    this.spacer.setVisible(false);
+    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(Box.createRigidArea(new Dimension(0, 0)),
         GBC.std().weight(0, 1));
-    treesPanel.setBackground(redoTree.getBackground());
-
-    undoButton = new SideButton(new UndoAction());
-    redoButton = new SideButton(new RedoAction());
+    treesPanel.setBackground(this.redoTree.getBackground());
+
+    this.undoButton = new SideButton(new UndoAction());
+    this.redoButton = new SideButton(new RedoAction());
 
     createLayout(treesPanel, true,
-        Arrays.asList(new SideButton[] { undoButton, redoButton }));
+        Arrays.asList(new SideButton[] { this.undoButton, this.redoButton }));
   }
 
@@ -106,6 +107,6 @@
 
   private void buildTree() {
-    redoButton.setEnabled(true);
-    undoButton.setEnabled(true);
+    this.redoButton.setEnabled(true);
+    this.undoButton.setEnabled(true);
     ArrayList<MapillaryCommand> commands = MapillaryRecord.getInstance().commandList;
     int position = MapillaryRecord.getInstance().position;
@@ -114,5 +115,5 @@
       undoCommands = new ArrayList<>(commands.subList(0, position + 1));
     else
-      undoButton.setEnabled(false);
+      this.undoButton.setEnabled(false);
     ArrayList<MapillaryCommand> redoCommands = new ArrayList<>();
     if (commands.size() > 0 && position + 1 < commands.size())
@@ -120,5 +121,5 @@
           commands.size()));
     else
-      redoButton.setEnabled(false);
+      this.redoButton.setEnabled(false);
 
     DefaultMutableTreeNode redoRoot = new DefaultMutableTreeNode();
@@ -134,9 +135,9 @@
     }
 
-    separator.setVisible(!undoCommands.isEmpty() || !redoCommands.isEmpty());
-    spacer.setVisible(undoCommands.isEmpty() && !redoCommands.isEmpty());
-
-    undoTreeModel.setRoot(undoRoot);
-    redoTreeModel.setRoot(redoRoot);
+    this.separator.setVisible(!undoCommands.isEmpty() || !redoCommands.isEmpty());
+    this.spacer.setVisible(undoCommands.isEmpty() && !redoCommands.isEmpty());
+
+    this.undoTreeModel.setRoot(undoRoot);
+    this.redoTreeModel.setRoot(redoRoot);
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31445)
@@ -77,6 +77,6 @@
         visibleRect = MapillaryImageDisplay.this.visibleRect;
       }
-      mouseIsDragging = false;
-      selectedRect = null;
+      this.mouseIsDragging = false;
+      MapillaryImageDisplay.this.selectedRect = null;
       if (image == null)
         return;
@@ -87,7 +87,7 @@
       // borders, this point is not calculated
       // again if there was less than 1.5seconds since the last event.
-      if (e.getWhen() - lastTimeForMousePoint > 1500 || mousePointInImg == null) {
-        lastTimeForMousePoint = e.getWhen();
-        mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
+      if (e.getWhen() - this.lastTimeForMousePoint > 1500 || this.mousePointInImg == null) {
+        this.lastTimeForMousePoint = e.getWhen();
+        this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
       }
       // Applicate the zoom to the visible rectangle in image coordinates
@@ -119,7 +119,7 @@
       // cursor doesn't move on the image.
       Rectangle drawRect = calculateDrawImageRectangle(visibleRect);
-      visibleRect.x = mousePointInImg.x
+      visibleRect.x = this.mousePointInImg.x
           + ((drawRect.x - e.getX()) * visibleRect.width) / drawRect.width;
-      visibleRect.y = mousePointInImg.y
+      visibleRect.y = this.mousePointInImg.y
           + ((drawRect.y - e.getY()) * visibleRect.height) / drawRect.height;
       // The position is also limited by the image size
@@ -178,7 +178,7 @@
     @Override
     public void mousePressed(MouseEvent e) {
-      if (image == null) {
-        mouseIsDragging = false;
-        selectedRect = null;
+      if (MapillaryImageDisplay.this.image == null) {
+        this.mouseIsDragging = false;
+        MapillaryImageDisplay.this.selectedRect = null;
         return;
       }
@@ -192,16 +192,16 @@
         return;
       if (e.getButton() == DRAG_BUTTON) {
-        mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
-        mouseIsDragging = true;
-        selectedRect = null;
+        this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
+        this.mouseIsDragging = true;
+        MapillaryImageDisplay.this.selectedRect = null;
       } else if (e.getButton() == ZOOM_BUTTON) {
-        mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
-        checkPointInVisibleRect(mousePointInImg, visibleRect);
-        mouseIsDragging = false;
-        selectedRect = new Rectangle(mousePointInImg.x, mousePointInImg.y, 0, 0);
+        this.mousePointInImg = comp2imgCoord(visibleRect, e.getX(), e.getY());
+        checkPointInVisibleRect(this.mousePointInImg, visibleRect);
+        this.mouseIsDragging = false;
+        MapillaryImageDisplay.this.selectedRect = new Rectangle(this.mousePointInImg.x, this.mousePointInImg.y, 0, 0);
         MapillaryImageDisplay.this.repaint();
       } else {
-        mouseIsDragging = false;
-        selectedRect = null;
+        this.mouseIsDragging = false;
+        MapillaryImageDisplay.this.selectedRect = null;
       }
     }
@@ -209,5 +209,5 @@
     @Override
     public void mouseDragged(MouseEvent e) {
-      if (!mouseIsDragging && selectedRect == null)
+      if (!this.mouseIsDragging && MapillaryImageDisplay.this.selectedRect == null)
         return;
       Image image;
@@ -218,12 +218,12 @@
       }
       if (image == null) {
-        mouseIsDragging = false;
-        selectedRect = null;
-        return;
-      }
-      if (mouseIsDragging) {
+        this.mouseIsDragging = false;
+        MapillaryImageDisplay.this.selectedRect = null;
+        return;
+      }
+      if (this.mouseIsDragging) {
         Point p = comp2imgCoord(visibleRect, e.getX(), e.getY());
-        visibleRect.x += mousePointInImg.x - p.x;
-        visibleRect.y += mousePointInImg.y - p.y;
+        visibleRect.x += this.mousePointInImg.x - p.x;
+        visibleRect.y += this.mousePointInImg.y - p.y;
         checkVisibleRectPos(image, visibleRect);
         synchronized (MapillaryImageDisplay.this) {
@@ -231,13 +231,13 @@
         }
         MapillaryImageDisplay.this.repaint();
-      } else if (selectedRect != null) {
+      } else if (MapillaryImageDisplay.this.selectedRect != null) {
         Point p = comp2imgCoord(visibleRect, e.getX(), e.getY());
         checkPointInVisibleRect(p, visibleRect);
-        Rectangle rect = new Rectangle(p.x < mousePointInImg.x ? p.x
-            : mousePointInImg.x, p.y < mousePointInImg.y ? p.y
-            : mousePointInImg.y, p.x < mousePointInImg.x ? mousePointInImg.x
-            - p.x : p.x - mousePointInImg.x,
-            p.y < mousePointInImg.y ? mousePointInImg.y - p.y : p.y
-                - mousePointInImg.y);
+        Rectangle rect = new Rectangle(p.x < this.mousePointInImg.x ? p.x
+            : this.mousePointInImg.x, p.y < this.mousePointInImg.y ? p.y
+            : this.mousePointInImg.y, p.x < this.mousePointInImg.x ? this.mousePointInImg.x
+            - p.x : p.x - this.mousePointInImg.x,
+            p.y < this.mousePointInImg.y ? this.mousePointInImg.y - p.y : p.y
+                - this.mousePointInImg.y);
         checkVisibleRectSize(image, rect);
         checkVisibleRectPos(image, rect);
@@ -249,5 +249,5 @@
     @Override
     public void mouseReleased(MouseEvent e) {
-      if (!mouseIsDragging && selectedRect == null)
+      if (!this.mouseIsDragging && MapillaryImageDisplay.this.selectedRect == null)
         return;
       Image image;
@@ -256,42 +256,42 @@
       }
       if (image == null) {
-        mouseIsDragging = false;
-        selectedRect = null;
-        return;
-      }
-      if (mouseIsDragging) {
-        mouseIsDragging = false;
-      } else if (selectedRect != null) {
-        int oldWidth = selectedRect.width;
-        int oldHeight = selectedRect.height;
+        this.mouseIsDragging = false;
+        MapillaryImageDisplay.this.selectedRect = null;
+        return;
+      }
+      if (this.mouseIsDragging) {
+        this.mouseIsDragging = false;
+      } else if (MapillaryImageDisplay.this.selectedRect != null) {
+        int oldWidth = MapillaryImageDisplay.this.selectedRect.width;
+        int oldHeight = MapillaryImageDisplay.this.selectedRect.height;
         // Check that the zoom doesn't exceed 2:1
-        if (selectedRect.width < getSize().width / 2) {
-          selectedRect.width = getSize().width / 2;
-        }
-        if (selectedRect.height < getSize().height / 2) {
-          selectedRect.height = getSize().height / 2;
+        if (MapillaryImageDisplay.this.selectedRect.width < getSize().width / 2) {
+          MapillaryImageDisplay.this.selectedRect.width = getSize().width / 2;
+        }
+        if (MapillaryImageDisplay.this.selectedRect.height < getSize().height / 2) {
+          MapillaryImageDisplay.this.selectedRect.height = getSize().height / 2;
         }
         // Set the same ratio for the visible rectangle and the display
         // area
-        int hFact = selectedRect.height * getSize().width;
-        int wFact = selectedRect.width * getSize().height;
+        int hFact = MapillaryImageDisplay.this.selectedRect.height * getSize().width;
+        int wFact = MapillaryImageDisplay.this.selectedRect.width * getSize().height;
         if (hFact > wFact) {
-          selectedRect.width = hFact / getSize().height;
+          MapillaryImageDisplay.this.selectedRect.width = hFact / getSize().height;
         } else {
-          selectedRect.height = wFact / getSize().width;
+          MapillaryImageDisplay.this.selectedRect.height = wFact / getSize().width;
         }
         // Keep the center of the selection
-        if (selectedRect.width != oldWidth) {
-          selectedRect.x -= (selectedRect.width - oldWidth) / 2;
-        }
-        if (selectedRect.height != oldHeight) {
-          selectedRect.y -= (selectedRect.height - oldHeight) / 2;
-        }
-        checkVisibleRectSize(image, selectedRect);
-        checkVisibleRectPos(image, selectedRect);
+        if (MapillaryImageDisplay.this.selectedRect.width != oldWidth) {
+          MapillaryImageDisplay.this.selectedRect.x -= (MapillaryImageDisplay.this.selectedRect.width - oldWidth) / 2;
+        }
+        if (MapillaryImageDisplay.this.selectedRect.height != oldHeight) {
+          MapillaryImageDisplay.this.selectedRect.y -= (MapillaryImageDisplay.this.selectedRect.height - oldHeight) / 2;
+        }
+        checkVisibleRectSize(image, MapillaryImageDisplay.this.selectedRect);
+        checkVisibleRectPos(image, MapillaryImageDisplay.this.selectedRect);
         synchronized (MapillaryImageDisplay.this) {
-          MapillaryImageDisplay.this.visibleRect = selectedRect;
-        }
-        selectedRect = null;
+          MapillaryImageDisplay.this.visibleRect = MapillaryImageDisplay.this.selectedRect;
+        }
+        MapillaryImageDisplay.this.selectedRect = null;
         MapillaryImageDisplay.this.repaint();
       }
@@ -337,6 +337,6 @@
     JPanel southPanel = new JPanel();
     southPanel.setLayout(new BorderLayout());
-    hyperlink = new HyperlinkLabel();
-    southPanel.add(hyperlink, BorderLayout.EAST);
+    this.hyperlink = new HyperlinkLabel();
+    southPanel.add(this.hyperlink, BorderLayout.EAST);
     southPanel.setOpaque(false);
 
@@ -347,10 +347,10 @@
    * Sets a new picture to be displayed.
    *
-   * @param image
+   * @param image The picture to be displayed.
    */
   public void setImage(BufferedImage image) {
     synchronized (this) {
       this.image = image;
-      selectedRect = null;
+      this.selectedRect = null;
       if (image != null)
         this.visibleRect = new Rectangle(0, 0, image.getWidth(null),
@@ -394,9 +394,9 @@
           + target.height, visibleRect.x, visibleRect.y, visibleRect.x
           + visibleRect.width, visibleRect.y + visibleRect.height, null);
-      if (selectedRect != null) {
-        Point topLeft = img2compCoord(visibleRect, selectedRect.x,
-            selectedRect.y);
-        Point bottomRight = img2compCoord(visibleRect, selectedRect.x
-            + selectedRect.width, selectedRect.y + selectedRect.height);
+      if (this.selectedRect != null) {
+        Point topLeft = img2compCoord(visibleRect, this.selectedRect.x,
+            this.selectedRect.y);
+        Point bottomRight = img2compCoord(visibleRect, this.selectedRect.x
+            + this.selectedRect.width, this.selectedRect.y + this.selectedRect.height);
         g.setColor(new Color(128, 128, 128, 180));
         g.fillRect(target.x, target.y, target.width, topLeft.y - target.y);
@@ -427,5 +427,5 @@
   }
 
-  private final Point getCenterImgCoord(Rectangle visibleRect) {
+  private final static Point getCenterImgCoord(Rectangle visibleRect) {
     return new Point(visibleRect.x + visibleRect.width / 2, visibleRect.y
         + visibleRect.height / 2);
@@ -498,5 +498,5 @@
   }
 
-  private final void checkVisibleRectPos(Image image, Rectangle visibleRect) {
+  private final static void checkVisibleRectPos(Image image, Rectangle visibleRect) {
     if (visibleRect.x < 0) {
       visibleRect.x = 0;
@@ -513,5 +513,5 @@
   }
 
-  private void checkVisibleRectSize(Image image, Rectangle visibleRect) {
+  private static void checkVisibleRectSize(Image image, Rectangle visibleRect) {
     if (visibleRect.width > image.getWidth(null)) {
       visibleRect.width = image.getWidth(null);
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java	(revision 31445)
@@ -99,13 +99,13 @@
     MapillaryData.getInstance().addListener(this);
     addShortcuts();
-    mapillaryImageDisplay = new MapillaryImageDisplay();
-
-    blueButton.setForeground(Color.BLUE);
-    redButton.setForeground(Color.RED);
+    this.mapillaryImageDisplay = new MapillaryImageDisplay();
+
+    this.blueButton.setForeground(Color.BLUE);
+    this.redButton.setForeground(Color.RED);
 
     createLayout(
-        mapillaryImageDisplay,
-        Arrays.asList(new SideButton[] { blueButton, previousButton,
-            nextButton, redButton }),
+        this.mapillaryImageDisplay,
+        Arrays.asList(new SideButton[] { this.blueButton, this.previousButton,
+            this.nextButton, this.redButton }),
         Main.pref.getBoolean("mapillary.reverse-buttons"));
     disableAllButtons();
@@ -117,16 +117,17 @@
    */
   private void addShortcuts() {
-    nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+    this.nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
         KeyStroke.getKeyStroke("PAGE_DOWN"), "next");
-    nextButton.getActionMap().put("next", new nextPictureAction());
-    previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+    this.nextButton.getActionMap().put("next", new nextPictureAction());
+    this.previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
         KeyStroke.getKeyStroke("PAGE_UP"), "previous");
-    previousButton.getActionMap().put("previous", new previousPictureAction());
-    blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+    this.previousButton.getActionMap().put("previous",
+        new previousPictureAction());
+    this.blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
         KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
-    blueButton.getActionMap().put("blue", new blueAction());
-    redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+    this.blueButton.getActionMap().put("blue", new blueAction());
+    this.redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
         KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
-    redButton.getActionMap().put("red", new redAction());
+    this.redButton.getActionMap().put("red", new redAction());
   }
 
@@ -143,5 +144,8 @@
 
   /**
+   * Sets a new mode for the dialog.
+   *
    * @param mode
+   *          The mode to be set.
    */
   public void setMode(Mode mode) {
@@ -149,14 +153,14 @@
       case NORMAL:
         createLayout(
-            mapillaryImageDisplay,
-            Arrays.asList(new SideButton[] { blueButton, previousButton,
-                nextButton, redButton }),
+            this.mapillaryImageDisplay,
+            Arrays.asList(new SideButton[] { this.blueButton,
+                this.previousButton, this.nextButton, this.redButton }),
             Main.pref.getBoolean("mapillary.reverse-buttons"));
         break;
       case WALK:
         createLayout(
-            mapillaryImageDisplay,
-            Arrays.asList(new SideButton[] { playButton, pauseButton,
-                stopButton }),
+            this.mapillaryImageDisplay,
+            Arrays.asList(new SideButton[] { this.playButton, this.pauseButton,
+                this.stopButton }),
             Main.pref.getBoolean("mapillary.reverse-buttons"));
         break;
@@ -202,5 +206,5 @@
       }
       if (this.image == null) {
-        mapillaryImageDisplay.setImage(null);
+        this.mapillaryImageDisplay.setImage(null);
         setTitle(tr(BASE_TITLE));
         disableAllButtons();
@@ -210,6 +214,6 @@
       this.nextButton.setEnabled(false);
       this.previousButton.setEnabled(false);
-      if (image.getSequence() != null) {
-        MapillaryAbstractImage tempImage = image;
+      if (this.image.getSequence() != null) {
+        MapillaryAbstractImage tempImage = this.image;
         while (tempImage.next() != null) {
           tempImage = tempImage.next();
@@ -220,6 +224,6 @@
         }
       }
-      if (image.getSequence() != null) {
-        MapillaryAbstractImage tempImage = image;
+      if (this.image.getSequence() != null) {
+        MapillaryAbstractImage tempImage = this.image;
         while (tempImage.previous() != null) {
           tempImage = tempImage.previous();
@@ -230,30 +234,30 @@
         }
       }
-      if (image instanceof MapillaryImage) {
-        mapillaryImageDisplay.hyperlink.setVisible(true);
+      if (this.image instanceof MapillaryImage) {
+        this.mapillaryImageDisplay.hyperlink.setVisible(true);
         MapillaryImage mapillaryImage = (MapillaryImage) this.image;
-        mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey());
+        this.mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey());
         // Downloads the thumbnail.
         this.mapillaryImageDisplay.setImage(null);
-        if (thumbnailCache != null)
-          thumbnailCache.cancelOutstandingTasks();
-        thumbnailCache = new MapillaryCache(mapillaryImage.getKey(),
+        if (this.thumbnailCache != null)
+          this.thumbnailCache.cancelOutstandingTasks();
+        this.thumbnailCache = new MapillaryCache(mapillaryImage.getKey(),
             MapillaryCache.Type.THUMBNAIL);
-        thumbnailCache.submit(this, false);
+        this.thumbnailCache.submit(this, false);
 
         // Downloads the full resolution image.
         if (fullQuality) {
-          if (imageCache != null)
-            imageCache.cancelOutstandingTasks();
-          imageCache = new MapillaryCache(mapillaryImage.getKey(),
+          if (this.imageCache != null)
+            this.imageCache.cancelOutstandingTasks();
+          this.imageCache = new MapillaryCache(mapillaryImage.getKey(),
               MapillaryCache.Type.FULL_IMAGE);
-          imageCache.submit(this, false);
-        }
-      } else if (image instanceof MapillaryImportedImage) {
-        mapillaryImageDisplay.hyperlink.setVisible(false);
-        mapillaryImageDisplay.hyperlink.setURL(null);
+          this.imageCache.submit(this, false);
+        }
+      } else if (this.image instanceof MapillaryImportedImage) {
+        this.mapillaryImageDisplay.hyperlink.setVisible(false);
+        this.mapillaryImageDisplay.hyperlink.setURL(null);
         MapillaryImportedImage mapillaryImage = (MapillaryImportedImage) this.image;
         try {
-          mapillaryImageDisplay.setImage(mapillaryImage.getImage());
+          this.mapillaryImageDisplay.setImage(mapillaryImage.getImage());
         } catch (IOException e) {
           Main.error(e);
@@ -266,9 +270,9 @@
 
   private void disableAllButtons() {
-    nextButton.setEnabled(false);
-    previousButton.setEnabled(false);
-    blueButton.setEnabled(false);
-    redButton.setEnabled(false);
-    mapillaryImageDisplay.hyperlink.setVisible(false);
+    this.nextButton.setEnabled(false);
+    this.previousButton.setEnabled(false);
+    this.blueButton.setEnabled(false);
+    this.redButton.setEnabled(false);
+    this.mapillaryImageDisplay.hyperlink.setVisible(false);
   }
 
@@ -277,4 +281,5 @@
    *
    * @param image
+   *          The image to be shown.
    */
   public synchronized void setImage(MapillaryAbstractImage image) {
@@ -429,6 +434,6 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-      if (thread != null)
-        thread.stopWalk();
+      if (this.thread != null)
+        this.thread.stopWalk();
     }
 
@@ -453,6 +458,6 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-      if (thread != null)
-        thread.play();
+      if (this.thread != null)
+        this.thread.play();
     }
 
@@ -479,5 +484,5 @@
     @Override
     public void actionPerformed(ActionEvent e) {
-      thread.pause();
+      this.thread.pause();
     }
 
@@ -510,8 +515,8 @@
           return;
         if (this.mapillaryImageDisplay.getImage() == null)
-          mapillaryImageDisplay.setImage(img);
+          this.mapillaryImageDisplay.setImage(img);
         else if (img.getHeight() > this.mapillaryImageDisplay.getImage()
             .getHeight()) {
-          mapillaryImageDisplay.setImage(img);
+          this.mapillaryImageDisplay.setImage(img);
         }
       } catch (IOException e) {
@@ -539,18 +544,18 @@
     panel.add(data, BorderLayout.CENTER);
     if (reverse) {
-      buttonsPanel = new JPanel(new GridLayout(1, 1));
+      this.buttonsPanel = new JPanel(new GridLayout(1, 1));
       if (!buttons.isEmpty() && buttons.get(0) != null) {
         final JPanel buttonRowPanel = new JPanel(Main.pref.getBoolean(
             "dialog.align.left", false) ? new FlowLayout(FlowLayout.LEFT)
             : new GridLayout(1, buttons.size()));
-        buttonsPanel.add(buttonRowPanel);
+        this.buttonsPanel.add(buttonRowPanel);
         for (SideButton button : buttons)
           buttonRowPanel.add(button);
       }
-      panel.add(buttonsPanel, BorderLayout.NORTH);
+      panel.add(this.buttonsPanel, BorderLayout.NORTH);
       createLayout(panel, true, null);
     } else
       createLayout(panel, true, buttons);
-    this.add(titleBar, BorderLayout.NORTH);
+    this.add(this.titleBar, BorderLayout.NORTH);
   }
 
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java	(revision 31445)
@@ -7,4 +7,5 @@
 import java.awt.event.ActionEvent;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -23,4 +24,5 @@
 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin;
 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
+import org.openstreetmap.josm.plugins.mapillary.oauth.MapillaryUser;
 import org.openstreetmap.josm.plugins.mapillary.oauth.OAuthPortListener;
 
@@ -52,37 +54,45 @@
     JPanel panel = new JPanel();
 
-    reverseButtons.setSelected(Main.pref
+    this.reverseButtons.setSelected(Main.pref
         .getBoolean("mapillary.reverse-buttons"));
-    displayHour.setSelected(Main.pref
+    this.displayHour.setSelected(Main.pref
         .getBoolean("mapillary.display-hour", true));
-    format24.setSelected(Main.pref.getBoolean("mapillary.format-24"));
-    moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture", true));
+    this.format24.setSelected(Main.pref.getBoolean("mapillary.format-24"));
+    this.moveTo.setSelected(Main.pref.getBoolean("mapillary.move-to-picture", true));
 
     panel.setLayout(new FlowLayout(FlowLayout.LEFT));
-    panel.add(reverseButtons);
+    panel.add(this.reverseButtons);
 
     // Sets the value of the ComboBox.
     if (Main.pref.get("mapillary.download-mode").equals(
         MapillaryDownloader.MODES[0]))
-      downloadMode.setSelectedItem(MapillaryDownloader.MODES[0]);
+      this.downloadMode.setSelectedItem(MapillaryDownloader.MODES[0]);
     if (Main.pref.get("mapillary.download-mode").equals(
         MapillaryDownloader.MODES[1]))
-      downloadMode.setSelectedItem(MapillaryDownloader.MODES[1]);
+      this.downloadMode.setSelectedItem(MapillaryDownloader.MODES[1]);
     if (Main.pref.get("mapillary.download-mode").equals(
         MapillaryDownloader.MODES[2]))
-      downloadMode.setSelectedItem(MapillaryDownloader.MODES[2]);
+      this.downloadMode.setSelectedItem(MapillaryDownloader.MODES[2]);
     JPanel downloadModePanel = new JPanel();
     downloadModePanel.add(new JLabel(tr("Download mode: ")));
-    downloadModePanel.add(downloadMode);
+    downloadModePanel.add(this.downloadMode);
     panel.add(downloadModePanel);
 
-    panel.add(displayHour);
-    panel.add(format24);
-    panel.add(moveTo);
+    panel.add(this.displayHour);
+    panel.add(this.format24);
+    panel.add(this.moveTo);
     JButton oauth = new JButton(new OAuthAction());
     if (Main.pref.get("mapillary.access-token") == null)
       oauth.setText("Login");
     else
-      oauth.setText("Logged as: " + Main.pref.get("mapillary.username") + ". Click to relogin.");
+      try {
+        oauth.setText("Logged as: " + MapillaryUser.getUsername() + ". Click to relogin.");
+      } catch (MalformedURLException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      } catch (IOException e) {
+        // TODO Auto-generated catch block
+        e.printStackTrace();
+      }
     panel.add(oauth);
     gui.getDisplayPreference().addSubTab(this, "Mapillary", panel);
@@ -92,19 +102,19 @@
   public boolean ok() {
     boolean mod = false;
-    Main.pref.put("mapillary.reverse-buttons", reverseButtons.isSelected());
+    Main.pref.put("mapillary.reverse-buttons", this.reverseButtons.isSelected());
 
     MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, false);
-    if (downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[0]))
+    if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[0]))
       Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES[0]);
-    if (downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[1]))
+    if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[1]))
       Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES[1]);
-    if (downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[2])) {
+    if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES[2])) {
       Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES[2]);
       MapillaryPlugin.setMenuEnabled(MapillaryPlugin.DOWNLOAD_VIEW_MENU, true);
     }
 
-    Main.pref.put("mapillary.display-hour", displayHour.isSelected());
-    Main.pref.put("mapillary.format-24", format24.isSelected());
-    Main.pref.put("mapillary.move-to-picture", moveTo.isSelected());
+    Main.pref.put("mapillary.display-hour", this.displayHour.isSelected());
+    Main.pref.put("mapillary.format-24", this.format24.isSelected());
+    Main.pref.put("mapillary.move-to-picture", this.moveTo.isSelected());
     return mod;
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java	(revision 31445)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryUploadDialog.java	(revision 31445)
@@ -0,0 +1,39 @@
+package org.openstreetmap.josm.plugins.mapillary.gui;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
+
+/**
+ * @author nokutu
+ *
+ */
+public class MapillaryUploadDialog extends JPanel {
+
+  private static final long serialVersionUID = 2517368588113991767L;
+
+  /** Button group for upload options. */
+  public ButtonGroup group;
+  /** Upload the whole sequence. */
+  public JRadioButton sequence;
+
+  /**
+   * Main constructor.
+   */
+  public MapillaryUploadDialog() {
+    this.group = new ButtonGroup();
+
+    this.sequence = new JRadioButton("Upload selected sequence.");
+    if (MapillaryData.getInstance().getSelectedImage() == null
+        || !(MapillaryData.getInstance().getSelectedImage() instanceof MapillaryImportedImage))
+      this.sequence.setEnabled(false);
+    this.group.add(this.sequence);
+    add(this.sequence);
+
+    this.group.setSelected(this.sequence.getModel(), true);
+
+  }
+}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryWalkDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryWalkDialog.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryWalkDialog.java	(revision 31445)
@@ -32,20 +32,20 @@
   public MapillaryWalkDialog() {
     JPanel interval = new JPanel();
-    spin = new SpinnerNumberModel(2000, 500, 10000, 500);
+    this.spin = new SpinnerNumberModel(2000, 500, 10000, 500);
     interval.add(new JLabel("Interval (miliseconds): "));
-    interval.add(new JSpinner(spin));
+    interval.add(new JSpinner(this.spin));
     add(interval);
 
-    waitForPicture = new JCheckBox("Wait for full quality pictures");
-    waitForPicture.setSelected(true);
-    add(waitForPicture);
+    this.waitForPicture = new JCheckBox("Wait for full quality pictures");
+    this.waitForPicture.setSelected(true);
+    add(this.waitForPicture);
 
-    followSelection = new JCheckBox("Follow selected image");
-    followSelection.setSelected(true);
-    add(followSelection);
+    this.followSelection = new JCheckBox("Follow selected image");
+    this.followSelection.setSelected(true);
+    add(this.followSelection);
 
-    goForward = new JCheckBox("Go forward");
-    goForward.setSelected(true);
-    add(goForward);
+    this.goForward = new JCheckBox("Go forward");
+    this.goForward.setSelected(true);
+    add(this.goForward);
   }
 }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/AbstractMode.java	(revision 31445)
@@ -40,5 +40,5 @@
     double minDistance = Double.MAX_VALUE;
     MapillaryAbstractImage closest = null;
-    for (MapillaryAbstractImage image : data.getImages()) {
+    for (MapillaryAbstractImage image : this.data.getImages()) {
       Point imagePoint = Main.map.mapView.getPoint(image.getLatLon());
       imagePoint.setLocation(imagePoint.getX(), imagePoint.getY());
@@ -54,8 +54,7 @@
 
   /**
-   * Paints whatever the mode needs.
-   *
+   * Paint the dataset using the engine set.
    * @param g
-   * @param mv
+   * @param mv The object that can translate GeoPoints to screen coordinates.
    * @param box
    */
@@ -89,10 +88,10 @@
     public void run() {
       while (true) {
-        if (moved
-            && Calendar.getInstance().getTimeInMillis() - lastDownload >= DOWNLOAD_COOLDOWN) {
-          lastDownload = Calendar.getInstance().getTimeInMillis();
+        if (this.moved
+            && Calendar.getInstance().getTimeInMillis() - this.lastDownload >= DOWNLOAD_COOLDOWN) {
+          this.lastDownload = Calendar.getInstance().getTimeInMillis();
           MapillaryDownloader.completeView();
-          moved = false;
-          MapillaryData.getInstance().dataUpdated();
+          this.moved = false;
+          MapillaryData.dataUpdated();
         }
         synchronized (this) {
@@ -106,5 +105,5 @@
 
     public void moved() {
-      moved = true;
+      this.moved = true;
     }
   }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/JoinMode.java	(revision 31445)
@@ -12,4 +12,5 @@
 import org.openstreetmap.josm.gui.MapView;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
@@ -31,87 +32,91 @@
    */
   public JoinMode() {
-    cursor = Cursor.CROSSHAIR_CURSOR;
+    this.cursor = Cursor.CROSSHAIR_CURSOR;
   }
 
   @Override
   public void mousePressed(MouseEvent e) {
-    if (data.getHighlighted() == null)
+    if (this.data.getHighlighted() == null)
       return;
-    if (lastClick == null
-        && data.getHighlighted() instanceof MapillaryImportedImage) {
-      lastClick = (MapillaryImportedImage) data.getHighlighted();
-    } else if (lastClick != null
-        && data.getHighlighted() instanceof MapillaryImportedImage) {
-      if (((data.getHighlighted().previous() == null && lastClick.next() == null) || (data
-          .getHighlighted().next() == null && lastClick.previous() == null))
-          && (data.getHighlighted().getSequence() != lastClick.getSequence() || lastClick
+    if (this.lastClick == null
+        && this.data.getHighlighted() instanceof MapillaryImportedImage) {
+      this.lastClick = (MapillaryImportedImage) this.data.getHighlighted();
+    } else if (this.lastClick != null
+        && this.data.getHighlighted() instanceof MapillaryImportedImage) {
+      if (((this.data.getHighlighted().previous() == null && this.lastClick.next() == null) || (this.data
+          .getHighlighted().next() == null && this.lastClick.previous() == null))
+          && (this.data.getHighlighted().getSequence() != this.lastClick.getSequence() || this.lastClick
               .getSequence() == null)) {
-        join(lastClick, (MapillaryImportedImage) data.getHighlighted());
-      } else if (lastClick.next() == data.getHighlighted()
-          || lastClick.previous() == data.getHighlighted())
-        unjoin(lastClick, (MapillaryImportedImage) data.getHighlighted());
-      lastClick = null;
+        join(this.lastClick, (MapillaryImportedImage) this.data.getHighlighted());
+      } else if (this.lastClick.next() == this.data.getHighlighted()
+          || this.lastClick.previous() == this.data.getHighlighted())
+        unjoin(this.lastClick, (MapillaryImportedImage) this.data.getHighlighted());
+      this.lastClick = null;
     }
-    data.dataUpdated();
+    MapillaryData.dataUpdated();
   }
 
   @Override
   public void mouseMoved(MouseEvent e) {
-    lastPos = e;
+    this.lastPos = e;
     if (!(Main.map.mapView.getActiveLayer() instanceof MapillaryLayer))
       return;
     MapillaryAbstractImage closestTemp = getClosest(e.getPoint());
-    data.setHighlightedImage(closestTemp);
-    data.dataUpdated();
+    this.data.setHighlightedImage(closestTemp);
+    MapillaryData.dataUpdated();
   }
 
   @Override
   public void paint(Graphics2D g, MapView mv, Bounds box) {
-    if (lastClick != null) {
+    if (this.lastClick != null) {
       g.setColor(Color.WHITE);
-      Point p0 = mv.getPoint(lastClick.getLatLon());
-      Point p1 = lastPos.getPoint();
+      Point p0 = mv.getPoint(this.lastClick.getLatLon());
+      Point p1 = this.lastPos.getPoint();
       g.drawLine(p0.x, p0.y, p1.x, p1.y);
     }
   }
 
-  private void join(MapillaryImportedImage img1, MapillaryImportedImage img2) {
+  private static void join(MapillaryImportedImage img1, MapillaryImportedImage img2) {
+    MapillaryImportedImage firstImage = img1;
+    MapillaryImportedImage secondImage = img2;
+
     if (img1.next() != null) {
-      MapillaryImportedImage temp = img1;
-      img1 = img2;
-      img2 = temp;
+      firstImage = img2;
+      secondImage = img1;
     }
-    if (img1.getSequence() == null) {
+    if (firstImage.getSequence() == null) {
       MapillarySequence seq = new MapillarySequence();
-      seq.add(img1);
-      img1.setSequence(seq);
+      seq.add(firstImage);
+      firstImage.setSequence(seq);
     }
-    if (img2.getSequence() == null) {
+    if (secondImage.getSequence() == null) {
       MapillarySequence seq = new MapillarySequence();
-      seq.add(img2);
+      seq.add(secondImage);
       img2.setSequence(seq);
     }
 
-    for (MapillaryAbstractImage img : img2.getSequence().getImages()) {
-      img1.getSequence().add(img);
-      img.setSequence(img1.getSequence());
+    for (MapillaryAbstractImage img : secondImage.getSequence().getImages()) {
+      firstImage.getSequence().add(img);
+      img.setSequence(firstImage.getSequence());
     }
   }
 
-  private void unjoin(MapillaryImportedImage img1, MapillaryImportedImage img2) {
+  private static void unjoin(MapillaryImportedImage img1, MapillaryImportedImage img2) {
+    MapillaryImportedImage firstImage = img1;
+    MapillaryImportedImage secondImage = img2;
+
     if (img1.next() != img2) {
-      MapillaryImportedImage temp = img1;
-      img1 = img2;
-      img2 = temp;
+      firstImage = img2;
+      secondImage = img1;
     }
 
-    ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(img1
+    ArrayList<MapillaryAbstractImage> firstHalf = new ArrayList<>(firstImage
         .getSequence().getImages()
-        .subList(0, img1.getSequence().getImages().indexOf(img2)));
-    ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(img1
+        .subList(0, firstImage.getSequence().getImages().indexOf(secondImage)));
+    ArrayList<MapillaryAbstractImage> secondHalf = new ArrayList<>(firstImage
         .getSequence()
         .getImages()
-        .subList(img1.getSequence().getImages().indexOf(img2),
-            img1.getSequence().getImages().size()));
+        .subList(firstImage.getSequence().getImages().indexOf(secondImage),
+            firstImage.getSequence().getImages().size()));
 
     MapillarySequence seq1 = new MapillarySequence();
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 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/mode/SelectMode.java	(revision 31445)
@@ -3,4 +3,5 @@
 import java.awt.Graphics2D;
 import java.awt.Point;
+import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
@@ -13,4 +14,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.MapillaryLayer;
@@ -40,10 +42,10 @@
    */
   public SelectMode() {
-    record = MapillaryRecord.getInstance();
+    this.record = MapillaryRecord.getInstance();
   }
 
   @Override
   public void mousePressed(MouseEvent e) {
-    lastButton = e.getButton();
+    this.lastButton = e.getButton();
     if (e.getButton() != MouseEvent.BUTTON1)
       return;
@@ -52,5 +54,5 @@
         && closest != null && Main.map.mapMode == Main.map.mapModeSelect) {
       this.lastClicked = this.closest;
-      data.setSelectedImage(closest);
+      this.data.setSelectedImage(closest);
       return;
     } else if (Main.map.mapView.getActiveLayer() != MapillaryLayer
@@ -58,8 +60,8 @@
       return;
     // Double click
-    if (e.getClickCount() == 2 && data.getSelectedImage() != null
+    if (e.getClickCount() == 2 && this.data.getSelectedImage() != null
         && closest != null) {
       for (MapillaryAbstractImage img : closest.getSequence().getImages()) {
-        data.addMultiSelectedImage(img);
+        this.data.addMultiSelectedImage(img);
       }
     }
@@ -67,12 +69,12 @@
     this.lastClicked = this.closest;
     this.closest = closest;
-    if (data.getMultiSelectedImages().contains(closest))
+    if (this.data.getMultiSelectedImages().contains(closest))
       return;
     // ctrl+click
-    if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK)
+    if (e.getModifiers() == (InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK)
         && closest != null)
-      data.addMultiSelectedImage(closest);
+      this.data.addMultiSelectedImage(closest);
     // shift + click
-    else if (e.getModifiers() == (MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK)
+    else if (e.getModifiers() == (InputEvent.BUTTON1_MASK | InputEvent.SHIFT_MASK)
         && this.lastClicked instanceof MapillaryImage) {
       if (this.closest != null && this.lastClicked != null
@@ -82,13 +84,13 @@
             .indexOf(this.lastClicked);
         if (i < j)
-          data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
+          this.data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
               .getImages().subList(i, j + 1)));
         else
-          data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
+          this.data.addMultiSelectedImage(new ArrayList<>(this.closest.getSequence()
               .getImages().subList(j, i + 1)));
       }
       // click
     } else
-      data.setSelectedImage(closest);
+      this.data.setSelectedImage(closest);
   }
 
@@ -99,24 +101,24 @@
 
     if (!Main.pref.getBoolean("mapillary.developer"))
-      for (MapillaryAbstractImage img : data.getMultiSelectedImages()) {
+      for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) {
         if (img instanceof MapillaryImage)
           return;
       }
-    if (data.getSelectedImage() != null) {
-      if (lastButton == MouseEvent.BUTTON1 && !e.isShiftDown()) {
+    if (this.data.getSelectedImage() != null) {
+      if (this.lastButton == MouseEvent.BUTTON1 && !e.isShiftDown()) {
         LatLon to = Main.map.mapView.getLatLon(e.getX(), e.getY());
-        LatLon from = Main.map.mapView.getLatLon(start.getX(), start.getY());
-        for (MapillaryAbstractImage img : data.getMultiSelectedImages()) {
+        LatLon from = Main.map.mapView.getLatLon(this.start.getX(), this.start.getY());
+        for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) {
 
           img.move(to.getX() - from.getX(), to.getY() - from.getY());
         }
         Main.map.repaint();
-      } else if (lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) {
-        this.closest.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
-            -(e.getY() - start.y)))
-            - closest.getTempCa());
-        for (MapillaryAbstractImage img : data.getMultiSelectedImages()) {
-          img.turn(Math.toDegrees(Math.atan2((e.getX() - start.x),
-              -(e.getY() - start.y))) - closest.getTempCa());
+      } else if (this.lastButton == MouseEvent.BUTTON1 && e.isShiftDown()) {
+        this.closest.turn(Math.toDegrees(Math.atan2((e.getX() - this.start.x),
+            -(e.getY() - this.start.y)))
+            - this.closest.getTempCa());
+        for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) {
+          img.turn(Math.toDegrees(Math.atan2((e.getX() - this.start.x),
+              -(e.getY() - this.start.y))) - this.closest.getTempCa());
         }
         Main.map.repaint();
@@ -127,19 +129,19 @@
   @Override
   public void mouseReleased(MouseEvent e) {
-    if (data.getSelectedImage() == null)
-      return;
-    if (data.getSelectedImage().getTempCa() != data.getSelectedImage().getCa()) {
-      double from = data.getSelectedImage().getTempCa();
-      double to = data.getSelectedImage().getCa();
-      record.addCommand(new CommandTurnImage(data.getMultiSelectedImages(), to
+    if (this.data.getSelectedImage() == null)
+      return;
+    if (this.data.getSelectedImage().getTempCa() != this.data.getSelectedImage().getCa()) {
+      double from = this.data.getSelectedImage().getTempCa();
+      double to = this.data.getSelectedImage().getCa();
+      this.record.addCommand(new CommandTurnImage(this.data.getMultiSelectedImages(), to
           - from));
-    } else if (data.getSelectedImage().getTempLatLon() != data
+    } else if (this.data.getSelectedImage().getTempLatLon() != this.data
         .getSelectedImage().getLatLon()) {
-      LatLon from = data.getSelectedImage().getTempLatLon();
-      LatLon to = data.getSelectedImage().getLatLon();
-      record.addCommand(new CommandMoveImage(data.getMultiSelectedImages(), to
+      LatLon from = this.data.getSelectedImage().getTempLatLon();
+      LatLon to = this.data.getSelectedImage().getLatLon();
+      this.record.addCommand(new CommandMoveImage(this.data.getMultiSelectedImages(), to
           .getX() - from.getX(), to.getY() - from.getY()));
     }
-    for (MapillaryAbstractImage img : data.getMultiSelectedImages()) {
+    for (MapillaryAbstractImage img : this.data.getMultiSelectedImages()) {
       if (img != null)
         img.stopMoving();
@@ -158,15 +160,15 @@
     if (closestTemp != null
         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
-        && !imageHighlighted) {
+        && !this.imageHighlighted) {
       Main.map.mapMode.putValue("active", Boolean.FALSE);
-      imageHighlighted = true;
+      this.imageHighlighted = true;
 
     } else if (closestTemp == null
         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer
-        && imageHighlighted && nothingHighlighted) {
-      nothingHighlighted = false;
+        && this.imageHighlighted && this.nothingHighlighted) {
+      this.nothingHighlighted = false;
       Main.map.mapMode.putValue("active", Boolean.TRUE);
 
-    } else if (imageHighlighted && !nothingHighlighted
+    } else if (this.imageHighlighted && !this.nothingHighlighted
         && Main.map.mapView.getEditLayer().data != null
         && Main.map.mapView.getActiveLayer() instanceof OsmDataLayer) {
@@ -176,18 +178,18 @@
         primivitive.setHighlighted(false);
       }
-      imageHighlighted = false;
-      nothingHighlighted = true;
-    }
-
-    if (data.getHighlighted() != closestTemp && closestTemp != null) {
-      data.setHighlightedImage(closestTemp);
+      this.imageHighlighted = false;
+      this.nothingHighlighted = true;
+    }
+
+    if (this.data.getHighlighted() != closestTemp && closestTemp != null) {
+      this.data.setHighlightedImage(closestTemp);
       MapillaryMainDialog.getInstance().setImage(closestTemp);
       MapillaryMainDialog.getInstance().updateImage(false);
-    } else if (data.getHighlighted() != closestTemp && closestTemp == null) {
-      data.setHighlightedImage(null);
-      MapillaryMainDialog.getInstance().setImage(data.getSelectedImage());
+    } else if (this.data.getHighlighted() != closestTemp && closestTemp == null) {
+      this.data.setHighlightedImage(null);
+      MapillaryMainDialog.getInstance().setImage(this.data.getSelectedImage());
       MapillaryMainDialog.getInstance().updateImage();
     }
-    data.dataUpdated();
+    MapillaryData.dataUpdated();
   }
 
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java	(revision 31445)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java	(revision 31445)
@@ -0,0 +1,71 @@
+package org.openstreetmap.josm.plugins.mapillary.oauth;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+
+/**
+ * @author nokutu
+ *
+ */
+public class MapillaryUser {
+
+  private static String username;
+  private static String images_policy;
+  private static String images_hash;
+
+  /**
+   * Returns the username of the logged user.
+   *
+   * @return The username of the logged in user.
+   * @throws MalformedURLException
+   * @throws IOException
+   */
+  public static String getUsername() throws MalformedURLException, IOException {
+    if (username == null)
+      username = OAuthUtils
+          .getWithHeader(
+              new URL(
+                  "https://a.mapillary.com/v2/me?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+          .getString("username");
+
+    return username;
+  }
+
+  /**
+   * @return A HashMap object containing the images_policy and images_hash
+   *         strings.
+   * @throws MalformedURLException
+   * @throws IOException
+   */
+  public static HashMap<String, String> getSecrets()
+      throws MalformedURLException, IOException {
+    HashMap<String, String> hash = new HashMap<>();
+    if (images_hash == null)
+      images_hash = OAuthUtils
+          .getWithHeader(
+              new URL(
+                  "https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+          .getString("images_hash");
+    hash.put("images_hash", images_hash);
+    if (images_policy == null)
+      images_policy = OAuthUtils
+          .getWithHeader(
+              new URL(
+                  "https://a.mapillary.com/v2/me/uploads/secrets?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
+          .getString("images_policy");
+    hash.put("images_policy", images_policy);
+    return hash;
+  }
+
+  /**
+   * Resets the MapillaryUser to null values.
+   */
+  public static void reset() {
+    username = null;
+    images_policy = null;
+    images_hash = null;
+  }
+
+}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthPortListener.java	(revision 31445)
@@ -8,5 +8,4 @@
 import java.net.ServerSocket;
 import java.net.Socket;
-import java.net.URL;
 import java.util.Scanner;
 
@@ -54,19 +53,12 @@
       serverSocket.close();
 
+      MapillaryUser.reset();
+
       Main.info("Successful login with Mapillary, the access token is: "
           + accessToken);
       // Saves the access token in preferences.
       Main.pref.put("mapillary.access-token", accessToken);
-      // Sets the logged username in preferences.
-      Main.pref
-          .put(
-              "mapillary.username",
-              OAuthUtils
-                  .getWithHeader(
-                      new URL(
-                          "https://a.mapillary.com/v2/me?client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))
-                  .getString("username"));
 
-      Main.info("The username is: " + Main.pref.get("mapillary.username"));
+      Main.info("The username is: " + MapillaryUser.getUsername());
 
     } catch (BindException e) {
@@ -77,5 +69,5 @@
   }
 
-  private void writeContent(PrintWriter out) {
+  private static void writeContent(PrintWriter out) {
     String response = "<html><head><title>Mapillary login</title></head><body>Login successful, return to JOSM.</body></html>";
     out.println("HTTP/1.1 200 OK");
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java	(revision 31425)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/OAuthUtils.java	(revision 31445)
@@ -1,14 +1,49 @@
 package org.openstreetmap.josm.plugins.mapillary.oauth;
 
+import java.io.BufferedOutputStream;
 import java.io.BufferedReader;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
 import java.net.HttpURLConnection;
 import java.net.URL;
-
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.HashMap;
+import java.util.UUID;
+
+import javax.imageio.ImageIO;
 import javax.json.Json;
 import javax.json.JsonObject;
 
+import org.apache.commons.imaging.ImageReadException;
+import org.apache.commons.imaging.ImageWriteException;
+import org.apache.commons.imaging.Imaging;
+import org.apache.commons.imaging.common.ImageMetadata;
+import org.apache.commons.imaging.common.RationalNumber;
+import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata;
+import org.apache.commons.imaging.formats.jpeg.exif.ExifRewriter;
+import org.apache.commons.imaging.formats.tiff.TiffImageMetadata;
+import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants;
+import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputDirectory;
+import org.apache.commons.imaging.formats.tiff.write.TiffOutputSet;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ContentType;
+import org.apache.http.entity.mime.MultipartEntityBuilder;
+import org.apache.http.entity.mime.content.FileBody;
+import org.apache.http.entity.mime.content.StringBody;
+import org.apache.http.impl.client.HttpClientBuilder;
 import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillarySequence;
 
 /**
@@ -20,6 +55,10 @@
 public class OAuthUtils {
 
-  /** URL where to upload the images. */
-  public static final String MAPILLARY_UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";
+  private static final String[] keys = { "key", "AWSAccessKeyId", "acl",
+      "policy", "signature", "Content-Type" };
+  private static final String UPLOAD_URL = "https://s3-eu-west-1.amazonaws.com/mapillary.uploads.manual.images";
+
+  // Count to name temporal files.
+  private static int c = 0;
 
   /**
@@ -28,6 +67,8 @@
    *
    * @param url
+   *          The {@link URL} where the request must be made.
    * @return A JsonObject containing the result of the GET request.
    * @throws IOException
+   *           Errors relating to the connection.
    */
   public static JsonObject getWithHeader(URL url) throws IOException {
@@ -41,3 +82,158 @@
     return Json.createReader(in).readObject();
   }
+
+  /**
+   * Uploads the given MapillaryImportedImage object.
+   *
+   * @param image
+   *
+   * @throws NoSuchAlgorithmException
+   * @throws UnsupportedEncodingException
+   * @throws InvalidKeyException
+   *
+   */
+  public static void upload(MapillaryImportedImage image)
+      throws InvalidKeyException, UnsupportedEncodingException,
+      NoSuchAlgorithmException {
+    try {
+      upload(image, UUID.randomUUID());
+    } catch (IOException e) {
+      Main.error(e);
+    }
+  }
+
+  /**
+   * @param image
+   * @param uuid
+   *          The UUID used to create the sequence.
+   * @param username
+   *          The username who is going to upload the picture.
+   * @throws NoSuchAlgorithmException
+   * @throws InvalidKeyException
+   * @throws IOException
+   */
+  public static void upload(MapillaryImportedImage image, UUID uuid)
+      throws NoSuchAlgorithmException, InvalidKeyException, IOException {
+    String key = MapillaryUser.getUsername() + "/" + uuid.toString() + "/"
+        + image.getLatLon().lat() + "_" + image.getLatLon().lon() + "_"
+        + image.getCa() + "_" + image.datetimeOriginal + ".jpg";
+
+    String policy = null;
+    String signature = null;
+    policy = MapillaryUser.getSecrets().get("images_policy");
+    signature = MapillaryUser.getSecrets().get("images_hash");
+
+    HashMap<String, String> hash = new HashMap<>();
+    hash.put("key", key);
+    hash.put("AWSAccessKeyId", "AKIAI2X3BJAT2W75HILA");
+    hash.put("acl", "private");
+    hash.put("policy", policy);
+    hash.put("signature", signature);
+    hash.put("Content-Type", "image/jpeg");
+
+    try {
+      uploadFile(updateFile(image), hash);
+    } catch (ImageReadException | ImageWriteException e) {
+      Main.error(e);
+    }
+
+  }
+
+  /**
+   * @param file
+   * @param hash
+   * @throws IOException
+   */
+  public static void uploadFile(File file, HashMap<String, String> hash)
+      throws IOException {
+    HttpClientBuilder builder = HttpClientBuilder.create();
+    HttpClient httpClient = builder.build();
+    HttpPost httpPost = new HttpPost(UPLOAD_URL);
+
+    MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
+    for (String key : keys) {
+      entityBuilder.addPart(key, new StringBody(hash.get(key),
+          ContentType.TEXT_PLAIN));
+      System.out.println(key + " => " + hash.get(key));
+    }
+    entityBuilder.addPart("file", new FileBody(file));
+
+    HttpEntity entity = entityBuilder.build();
+    httpPost.setEntity(entity);
+
+    System.out.println(httpPost);
+    HttpResponse response = httpClient.execute(httpPost);
+    System.out.println(response.toString());
+  }
+
+  /**
+   * Uploads the given {@link MapillarySequence}.
+   *
+   * @param sequence
+   *          The sequence to upload. It must contain only
+   *          {@link MapillaryImportedImage} objects.
+   * @throws NoSuchAlgorithmException
+   * @throws UnsupportedEncodingException
+   * @throws InvalidKeyException
+   */
+  public static void uploadSequence(MapillarySequence sequence)
+      throws InvalidKeyException, UnsupportedEncodingException,
+      NoSuchAlgorithmException {
+    UUID uuid = UUID.randomUUID();
+
+    for (MapillaryAbstractImage img : sequence.getImages()) {
+      if (!(img instanceof MapillaryImportedImage))
+        throw new IllegalArgumentException(
+            "The sequence contains downloaded images.");
+      try {
+        upload((MapillaryImportedImage) img, uuid);
+      } catch (IOException e) {
+        Main.error(e);
+      }
+    }
+  }
+
+  private static File updateFile(MapillaryImportedImage image)
+      throws ImageReadException, IOException, ImageWriteException {
+    TiffOutputSet outputSet = null;
+    TiffOutputDirectory exifDirectory = null;
+    // If the image is imported, loads the rest of the EXIF data.
+    ImageMetadata metadata = Imaging.getMetadata(image.getFile());
+    final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
+    if (null != jpegMetadata) {
+      final TiffImageMetadata exif = jpegMetadata.getExif();
+      if (null != exif) {
+        outputSet = exif.getOutputSet();
+      }
+    }
+    if (null == outputSet) {
+      outputSet = new TiffOutputSet();
+    }
+    exifDirectory = outputSet.getOrCreateExifDirectory();
+
+    exifDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF);
+    exifDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF,
+        GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF_VALUE_TRUE_NORTH);
+
+    exifDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
+    exifDirectory.add(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION,
+        RationalNumber.valueOf(image.getCa()));
+
+    exifDirectory.removeField(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
+    exifDirectory.add(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL,
+        ((MapillaryImportedImage) image).getDate("yyyy/MM/dd hh:mm:ss"));
+
+    outputSet.setGPSInDegrees(image.getLatLon().lon(), image.getLatLon().lat());
+    File tempFile = new File(c + ".tmp");
+    OutputStream os = new BufferedOutputStream(new FileOutputStream(tempFile));
+
+    // Transforms the image into a byte array.
+    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+    ImageIO.write(image.getImage(), "jpg", outputStream);
+    byte[] imageBytes = outputStream.toByteArray();
+
+    new ExifRewriter().updateExifMetadataLossless(imageBytes, os, outputSet);
+
+    return tempFile;
+  }
 }
