Index: /applications/editors/josm/plugins/mapillary/.classpath
===================================================================
--- /applications/editors/josm/plugins/mapillary/.classpath	(revision 31175)
+++ /applications/editors/josm/plugins/mapillary/.classpath	(revision 31176)
@@ -3,5 +3,5 @@
 	<classpathentry kind="src" path="src"/>
 	<classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="lib" path="/home/nokutu/Dropbox/programacion/GSoC/josm/plugins/mapillary/lib/sanselan-0.97-incubator.jar"/>
 	<classpathentry kind="output" path="bin"/>
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31176)
@@ -28,10 +28,11 @@
 
 	private final List<MapillaryImage> images;
-	private MapillaryImage selectedImage = null;
-	private List<MapillaryImage> multiSelectedImages;
+	private MapillaryImage selectedImage;
+	private final List<MapillaryImage> multiSelectedImages;
 
 	public MapillaryData() {
 		images = new CopyOnWriteArrayList<>();
 		multiSelectedImages = new ArrayList<>();
+		selectedImage = null;
 	}
 
@@ -41,12 +42,4 @@
 		}
 		return INSTANCE;
-	}
-
-	public static void deleteInstance() {
-		INSTANCE = null;
-	}
-
-	public MapillaryData(List<MapillaryImage> images) {
-		this.images = images;
 	}
 
@@ -154,15 +147,9 @@
 	/**
 	 * Selects a new image and then starts a new MapillaryImageDownloadThread
-	 * thread in order to download its surrounding thumbnails and images. If the
+	 * thread in order to download its surrounding thumbnails. If the
 	 * user does ctrl+click, this isn't triggered.
 	 * 
 	 * @param image
 	 *            The MapillaryImage which is going to be selected
-	 * @param clearThumbnail
-	 *            Whether if the old selected MapillaryImage's thumbnail should
-	 *            be deleted or not.
-	 * @param clearImageWhether
-	 *            if the old selected MapillaryImage's full resolution image
-	 *            should be deleted or not.
 	 */
 	public void setSelectedImage(MapillaryImage image) {
@@ -236,5 +223,4 @@
 			CacheEntryAttributes attributes, LoadResult result) {
 		// DO NOTHING
-
 	}
 }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java	(revision 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java	(revision 31176)
@@ -39,4 +39,5 @@
 		dlg.setVisible(true);
 
+		// Checks if the inputs are correct and starts the export process.
 		if (pane.getValue() != null
 				&& (int) pane.getValue() == JOptionPane.OK_OPTION
@@ -51,13 +52,12 @@
 			}
 		}
-
 		dlg.dispose();
 	}
 
 	/**
-	 * Exports the given images from the database
+	 * Exports the given images from the database.
 	 */
 	public void export(List<MapillaryImage> images) {
-		new Thread(new MapillaryExportManager(tr("Downloading..."), images,
+		new Thread(new MapillaryExportManager(images,
 				dialog.chooser.getSelectedFile().toString())).start();
 	}
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportDialog.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportDialog.java	(revision 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportDialog.java	(revision 31176)
@@ -49,4 +49,5 @@
 		group.add(sequence);
 		group.add(selected);
+		// Some options are disabled depending on the circumstances
 		if (MapillaryData.getInstance().getSelectedImage() == null
 				|| MapillaryData.getInstance().getSelectedImage().getSequence() == null) {
@@ -60,4 +61,5 @@
 		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));
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31176)
@@ -15,5 +15,5 @@
 	private Double ca;
 	private boolean isModified = false;
-	public MapillarySequence sequence;
+	private MapillarySequence sequence;
 
 	/**
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImageDisplay.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImageDisplay.java	(revision 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImageDisplay.java	(revision 31176)
@@ -24,5 +24,6 @@
  * 
  * @author Jorge
- *
+ * @see ImageDisplay
+ * @see MapillaryToggleDialog
  */
 public class MapillaryImageDisplay extends JComponent {
@@ -310,4 +311,9 @@
 	}
 
+	/**
+	 * Sets a new picture to be displayed.
+	 * 
+	 * @param image
+	 */
 	public void setImage(BufferedImage image) {
 		synchronized (this) {
@@ -320,9 +326,17 @@
 		repaint();
 	}
-	
+
+	/**
+	 * Returns the picture that is being displayerd
+	 * 
+	 * @return
+	 */
 	public BufferedImage getImage() {
 		return this.image;
 	}
 
+	/**
+	 * Paints the visible part of the picture.
+	 */
 	public void paintComponent(Graphics g) {
 		Image image;
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31176)
@@ -75,6 +75,5 @@
 			CACHE = JCSCacheManager.getCache("Mapillary");
 		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			Main.error(e);
 		}
 		if (Main.map != null && Main.map.mapView != null) {
@@ -95,5 +94,5 @@
 	}
 
-	public static MapillaryLayer getInstance() {
+	public synchronized static MapillaryLayer getInstance() {
 		if (MapillaryLayer.INSTANCE == null)
 			MapillaryLayer.INSTANCE = new MapillaryLayer();
@@ -109,12 +108,13 @@
 			if (!this.bounds.contains(bounds)) {
 				this.bounds.add(bounds);
-				new MapillaryDownloader(mapillaryData).getImages(
-						bounds.getMin(), bounds.getMax());
-			}
-		}
-	}
-
-	/**
-	 * Returs the MapillaryData object, which acts as the database of the Layer.
+				new MapillaryDownloader().getImages(bounds.getMin(),
+						bounds.getMax());
+			}
+		}
+	}
+
+	/**
+	 * Returns the MapillaryData object, which acts as the database of the
+	 * Layer.
 	 * 
 	 * @return
@@ -125,5 +125,5 @@
 
 	/**
-	 * Method invoqued when the layer is destroyed.
+	 * Method invoked when the layer is destroyed.
 	 */
 	@Override
@@ -134,5 +134,5 @@
 		MapillaryLayer.INSTANCE = null;
 		MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false);
-		MapillaryData.deleteInstance();
+		MapillaryData.INSTANCE = null;
 		Main.map.mapView.removeMouseListener(this);
 		MapView.removeEditLayerChangeListener(this);
@@ -147,9 +147,7 @@
 	@Override
 	public boolean isModified() {
-		for (MapillaryImage image : mapillaryData.getImages()) {
-			if (image.isModified()) {
+		for (MapillaryImage image : mapillaryData.getImages())
+			if (image.isModified())
 				return true;
-			}
-		}
 		return false;
 	}
@@ -208,15 +206,16 @@
 				int width = icon.getIconWidth();
 				int height = icon.getIconHeight();
-				
+
 				// Rotate the image
 				double rotationRequired = Math.toRadians(image.getCa());
 				double locationX = width / 2;
 				double locationY = height / 2;
-				AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY);
-				AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
-				
-				g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y - (height / 2),
-						Main.map.mapView);
-				
+				AffineTransform tx = AffineTransform.getRotateInstance(
+						rotationRequired, locationX, locationY);
+				AffineTransformOp op = new AffineTransformOp(tx,
+						AffineTransformOp.TYPE_BILINEAR);
+
+				g.drawImage(op.filter(bi, null), p.x - (width / 2), p.y
+						- (height / 2), Main.map.mapView);
 			}
 		}
@@ -278,10 +277,8 @@
 	@Override
 	public void mouseClicked(MouseEvent e) {
-		if (e.getButton() != MouseEvent.BUTTON1) {
+		if (e.getButton() != MouseEvent.BUTTON1)
 			return;
-		}
-		if (Main.map.mapView.getActiveLayer() != this) {
+		if (Main.map.mapView.getActiveLayer() != this)
 			return;
-		}
 		Point clickPoint = e.getPoint();
 		double snapDistance = 10;
@@ -290,6 +287,4 @@
 		for (MapillaryImage image : mapillaryData.getImages()) {
 			Point imagePoint = Main.map.mapView.getPoint(image.getLatLon());
-			// move the note point to the center of the icon where users are
-			// most likely to click when selecting
 			imagePoint.setLocation(imagePoint.getX(), imagePoint.getY());
 			double dist = clickPoint.distanceSq(imagePoint);
@@ -371,6 +366,5 @@
 				sleep(1000);
 			} catch (InterruptedException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				Main.error(e);
 			}
 			MapillaryLayer.getInstance().download();
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31176)
@@ -29,14 +29,13 @@
 	public static final int ICON_SIZE = 24;
 
-	MapillaryDownloadAction downloadAction;
-	MapillaryExportAction exportAction;
+	private final MapillaryDownloadAction downloadAction;
+	private final MapillaryExportAction exportAction;
 
 	public static JMenuItem DOWNLOAD_MENU;
 	public static JMenuItem EXPORT_MENU;
 
-	public static String DIR;
-
 	public MapillaryPlugin(PluginInformation info) {
 		super(info);
+		Main.logLevel = 1;
 		downloadAction = new MapillaryDownloadAction();
 		exportAction = new MapillaryExportAction();
@@ -47,6 +46,4 @@
 				false, 14);
 		EXPORT_MENU.setEnabled(false);
-		MapillaryPlugin.DIR = this.getPluginDir();
-
 	}
 
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/cache/MapillaryCache.java	(revision 31176)
@@ -6,4 +6,5 @@
 
 import org.apache.commons.jcs.access.behavior.ICacheAccess;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
 import org.openstreetmap.josm.data.cache.JCSCachedTileLoaderJob;
@@ -36,6 +37,5 @@
 			}
 		} catch (MalformedURLException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			Main.error(e);
 		}
 	}
@@ -66,5 +66,4 @@
 	// @Override
 	protected boolean handleNotFound() {
-		// TODO Auto-generated method stub
 		return false;
 	}
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31176)
@@ -2,5 +2,4 @@
 
 import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
@@ -21,8 +20,6 @@
 	private String[] parameters = { "lat", "lon", "distance", "limit",
 			"min_lat", "min_lon", "max_lat", "max_lon" };
-	private MapillaryData data;
 
-	public MapillaryDownloader(MapillaryData data) {
-		this.data = data;
+	public MapillaryDownloader() {
 	}
 
@@ -49,7 +46,7 @@
 		url2 += buildParameters(hash);
 		try {
-			Main.worker.submit(new MapillarySquareDownloadManagerThread(this.data,
-					url1, url2, new Bounds(minLatLon, maxLatLon)));
+			Main.worker.submit(new MapillarySquareDownloadManagerThread(url1, url2, new Bounds(minLatLon, maxLatLon)));
 		} catch (Exception e) {
+			Main.error(e);
 		}
 	}
@@ -57,8 +54,7 @@
 	private String buildParameters(ConcurrentHashMap<String, Double> hash) {
 		String ret = "?client_id=" + CLIENT_ID;
-		for (int i = 0; i < parameters.length; i++) {
+		for (int i = 0; i < parameters.length; i++)
 			if (hash.get(parameters[i]) != null)
 				ret += "&" + parameters[i] + "=" + hash.get(parameters[i]);
-		}
 		return ret;
 	}
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java	(revision 31176)
@@ -11,4 +11,5 @@
 
 import org.apache.commons.jcs.access.CacheAccess;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.cache.BufferedImageCacheEntry;
 import org.openstreetmap.josm.data.cache.CacheEntry;
@@ -56,9 +57,7 @@
 					.submit(this, false);
 		} catch (MalformedURLException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			Main.error(e);
 		} catch (IOException e) {
-			// TODO -generated catch block
-			e.printStackTrace();
+			Main.error(e);
 		}
 	}
@@ -72,9 +71,7 @@
 
 		} catch (InterruptedException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			Main.error(e);
 		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
+			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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31176)
@@ -1,4 +1,5 @@
 package org.openstreetmap.josm.plugins.mapillary.downloads;
 
+import static org.openstreetmap.josm.tools.I18n.tr;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
@@ -8,4 +9,5 @@
 import java.util.concurrent.TimeUnit;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
@@ -33,9 +35,7 @@
 	String path;
 
-	public MapillaryExportManager(String title, List<MapillaryImage> images,
-			String path) {
-		super(title,
-				new PleaseWaitProgressMonitor("Exporting Mapillary Images"),
-				true);
+	public MapillaryExportManager(List<MapillaryImage> images, String path) {
+		super(tr("Downloading") + "...", new PleaseWaitProgressMonitor(
+				"Exporting Mapillary Images"), true);
 		queue = new ArrayBlockingQueue<>(10);
 		queueImages = new ArrayBlockingQueue<>(10);
@@ -48,5 +48,4 @@
 	protected void cancel() {
 		// TODO Auto-generated method stub
-
 	}
 
@@ -54,7 +53,8 @@
 	protected void realRun() throws SAXException, IOException,
 			OsmTransferException {
+		// Starts a writer thread in order to write the pictures on the disk.
 		Thread writer = new Thread(new MapillaryExportWriterThread(path, queue,
 				queueImages, images.size(), this.getProgressMonitor()));
-		writer.start();
+		Main.worker.submit(writer);
 		ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25,
 				TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
@@ -64,11 +64,13 @@
 						queueImages));
 			} catch (Exception e) {
-				System.out.println("Exception");
+				Main.error(e);
 			}
 			try {
+				// If the queue is full, waits for it to have more space
+				// available before executing anything else.
 				while (ex.getQueue().remainingCapacity() == 0)
 					Thread.sleep(100);
 			} catch (Exception e) {
-				System.out.println(e);
+				Main.error(e);
 			}
 		}
@@ -76,4 +78,5 @@
 			writer.join();
 		} catch (Exception e) {
+			Main.error(e);
 		}
 
@@ -83,6 +86,4 @@
 	protected void finish() {
 		// TODO Auto-generated method stub
-
 	}
-
 }
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java	(revision 31176)
@@ -22,4 +22,5 @@
 import org.apache.sanselan.formats.tiff.write.TiffOutputField;
 import org.apache.sanselan.formats.tiff.write.TiffOutputSet;
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
@@ -34,9 +35,9 @@
 public class MapillaryExportWriterThread implements Runnable {
 
-	private String path;
-	private ArrayBlockingQueue<BufferedImage> queue;
-	private ArrayBlockingQueue<MapillaryImage> queueImages;
-	private int amount;
-	private ProgressMonitor monitor;
+	private final String path;
+	private final ArrayBlockingQueue<BufferedImage> queue;
+	private final ArrayBlockingQueue<MapillaryImage> queueImages;
+	private final int amount;
+	private final ProgressMonitor monitor;
 
 	public MapillaryExportWriterThread(String path,
@@ -63,6 +64,7 @@
 				mimg = queueImages.take();
 				finalPath = path + "/" + mimg.getKey();
+				// 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);
 
@@ -72,8 +74,12 @@
 						.getOrCreateGPSDirectory();
 				FieldType fieldType = TiffFieldTypeConstants.FIELD_TYPE_RATIONAL;
-				TiffOutputField directionref = TiffOutputField.create(GPSTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF, outputSet.byteOrder, "T");
+				TiffOutputField directionref = TiffOutputField.create(
+						GPSTagConstants.GPS_TAG_GPS_IMG_DIRECTION_REF,
+						outputSet.byteOrder, "T");
 				exifDirectory.add(directionref);
-				TiffOutputField direction = TiffOutputField.create(
-						new TagInfo("GPS Img Direction", 17, fieldType , 1, TiffDirectoryConstants.EXIF_DIRECTORY_GPS), outputSet.byteOrder, mimg.getCa());
+				TiffOutputField direction = TiffOutputField.create(new TagInfo(
+						"GPS Img Direction", 17, fieldType, 1,
+						TiffDirectoryConstants.EXIF_DIRECTORY_GPS),
+						outputSet.byteOrder, mimg.getCa());
 				exifDirectory.add(direction);
 				try {
@@ -81,6 +87,5 @@
 							.getLatLon().lat());
 				} catch (ImageWriteException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
+					Main.error(e);
 				}
 				OutputStream os = new BufferedOutputStream(
@@ -90,19 +95,15 @@
 				tempFile.delete();
 				os.close();
-
-			} catch (InterruptedException e1) {
-				// TODO Auto-generated catch block
-				e1.printStackTrace();
+			} catch (InterruptedException e) {
+				Main.error(e);
 			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				Main.error(e);
 			} catch (ImageReadException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				Main.error(e);
 			} catch (ImageWriteException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				Main.error(e);
 			}
 
+			// Increases the progress bar.
 			monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / amount);
 			monitor.setCustomText("Downloaded " + (i + 1) + "/" + amount);
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31176)
@@ -14,4 +14,5 @@
 import java.util.concurrent.ExecutorService;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
@@ -29,12 +30,9 @@
 public class MapillarySequenceDownloadThread implements Runnable {
 
-	private MapillaryData data;
 	private String url;
 	private ExecutorService ex;
 	private Bounds bounds;
 
-	public MapillarySequenceDownloadThread(ExecutorService ex,
-			MapillaryData data, String url, Bounds bounds) {
-		this.data = data;
+	public MapillarySequenceDownloadThread(ExecutorService ex, String url, Bounds bounds) {
 		this.url = url;
 		this.ex = ex;
@@ -47,8 +45,4 @@
 			br = new BufferedReader(new InputStreamReader(
 					new URL(url).openStream()));
-			/*
-			 * String jsonLine = ""; while (br.ready()) { jsonLine +=
-			 * br.readLine(); }
-			 */
 			JsonObject jsonall = Json.createReader(br).readObject();
 
@@ -71,13 +65,8 @@
 										.getJsonNumber(j).doubleValue()));
 					} catch (Exception e) {
-						// Mapillary service bug here
-						// System.out.println(cas.length());
-						// System.out.println(coords.length());
-						// System.out.println(keys.length());
 						System.out.println(e);
 					}
 				}
 				MapillarySequence sequence = new MapillarySequence();
-				//sequence.setTimestamp(jsonobj.getString("created_at"));
 				int first = -1;
 				int last = -1;
@@ -105,11 +94,10 @@
 					img.setSequence(sequence);
 				}
-				data.addWithoutUpdate(finalImages);
+				MapillaryData.getInstance().addWithoutUpdate(finalImages);
 				sequence.add(finalImages);
 			}
 		} catch (IOException e) {
-			return;
+			Main.error(e);
 		}
-		return;
 	}
 }
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 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31176)
@@ -5,4 +5,5 @@
 import java.util.concurrent.ArrayBlockingQueue;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
@@ -20,12 +21,9 @@
 
 	@SuppressWarnings("unused")
-	private String urlImages;
-	private String urlSequences;
-	private MapillaryData data;
-	private Bounds bounds;
+	private final String urlImages;
+	private final String urlSequences;
+	private final Bounds bounds;
 
-	public MapillarySquareDownloadManagerThread(MapillaryData data,
-			String urlImages, String urlSequences, Bounds bounds) {
-		this.data = data;
+	public MapillarySquareDownloadManagerThread(String urlImages, String urlSequences, Bounds bounds) {
 		this.urlImages = urlImages;
 		this.urlSequences = urlSequences;
@@ -34,15 +32,13 @@
 
 	public void run() {
-		fullfillSequences();
-		return;
+		downloadSequences();
 	}
 
-	public void fullfillSequences() {
+	public void downloadSequences() {
 		ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25,
 				TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
-		;
 		int page = 0;
 		while (!ex.isShutdown()) {
-			ex.execute(new MapillarySequenceDownloadThread(ex, data,
+			ex.execute(new MapillarySequenceDownloadThread(ex,
 					urlSequences + "&page=" + page + "&limit=1", bounds));
 			try {
@@ -50,5 +46,5 @@
 					Thread.sleep(100);
 			} catch (Exception e) {
-				System.out.println(e);
+				Main.error(e);
 			}
 			page++;
@@ -58,7 +54,7 @@
 			}
 		} catch (Exception e) {
-			System.out.println(e);
+			Main.error(e);
 		}
-		data.dataUpdated();
+		MapillaryData.getInstance().dataUpdated();
 	}
 }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java	(revision 31175)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadThread.java	(revision 31176)
@@ -12,4 +12,5 @@
 import java.util.concurrent.ExecutorService;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
@@ -22,12 +23,10 @@
  */
 public class MapillarySquareDownloadThread implements Runnable {
-	String url;
-	MapillaryData data;
-	ExecutorService ex;
+	private final String url;
+	private final ExecutorService ex;
 
 	public MapillarySquareDownloadThread(ExecutorService ex,
 			MapillaryData data, String url) {
 		this.ex = ex;
-		this.data = data;
 		this.url = url;
 	}
@@ -38,8 +37,4 @@
 			br = new BufferedReader(new InputStreamReader(
 					new URL(url).openStream()));
-			/*
-			 * String jsonLine = ""; while (br.ready()) { jsonLine +=
-			 * br.readLine(); }
-			 */
 			JsonObject jsonobj = Json.createReader(br).readObject();
 			if (!jsonobj.getBoolean("more")) {
@@ -57,11 +52,10 @@
 							.getJsonNumber("ca").doubleValue()));
 				} catch (Exception e) {
-					System.out.println(e);
+					Main.error(e);
 				}
 			}
-			data.add(images);
-			return;
+			MapillaryData.getInstance().add(images);
 		} catch (Exception e) {
-			return;
+			Main.error(e);
 		}
 	}
