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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31163)
@@ -1,7 +1,16 @@
 package org.openstreetmap.josm.plugins.mapillary;
 
+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;
+import org.openstreetmap.josm.data.cache.CacheEntryAttributes;
+import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
+import org.openstreetmap.josm.data.cache.JCSCacheManager;
+import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache;
+
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
@@ -13,5 +22,5 @@
  *
  */
-public class MapillaryData {
+public class MapillaryData implements ICachedLoaderListener {
 	public volatile static MapillaryData INSTANCE;
 
@@ -125,7 +134,6 @@
 			return;
 		if (getSelectedImage().getSequence() == null)
-			throw new IllegalStateException();
-		if (getSelectedImage().next() != null)
-			setSelectedImage(getSelectedImage().next());
+			return;
+		setSelectedImage(getSelectedImage().next());
 	}
 
@@ -139,6 +147,5 @@
 		if (getSelectedImage().getSequence() == null)
 			throw new IllegalStateException();
-		if (getSelectedImage().previous() != null)
-			setSelectedImage(getSelectedImage().previous());
+		setSelectedImage(getSelectedImage().previous());
 	}
 
@@ -163,4 +170,19 @@
 			MapillaryToggleDialog.getInstance().setImage(selectedImage);
 			MapillaryToggleDialog.getInstance().updateImage();
+			CacheAccess<String, BufferedImageCacheEntry> prev = null;
+			try {
+				prev = JCSCacheManager.getCache("mapillary");
+			} catch (IOException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			}
+			if (image.next() != null)
+				new MapillaryCache(image.next().getKey(),
+						MapillaryCache.Type.FULL_IMAGE, prev, 200000, 200000,
+						new HashMap<String, String>()).submit(this, false);
+			if (image.previous() != null)
+				new MapillaryCache(image.previous().getKey(),
+						MapillaryCache.Type.FULL_IMAGE, prev, 200000, 200000,
+						new HashMap<String, String>()).submit(this, false);
 		}
 		if (Main.map != null) {
@@ -173,5 +195,6 @@
 	 * click)
 	 * 
-	 * @param image The MapillaryImage object to be added.
+	 * @param image
+	 *            The MapillaryImage object to be added.
 	 */
 	public void addMultiSelectedImage(MapillaryImage image) {
@@ -183,3 +206,10 @@
 		return multiSelectedImages;
 	}
+
+	@Override
+	public void loadingFinished(CacheEntry data,
+			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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryExportAction.java	(revision 31163)
@@ -25,6 +25,6 @@
 
 	public MapillaryExportAction() {
-		super(tr("Export images"), "icon24.png", tr("Export images."),
-				null, false);
+		super(tr("Export images"), "icon24.png", tr("Export images."), null,
+				false);
 	}
 
@@ -57,6 +57,6 @@
 	 */
 	public void export(List<MapillaryImage> images) {
-		Main.worker.submit(new MapillaryExportManager(tr("Downloading..."),
-				images, dialog.chooser.getSelectedFile().toString()));
+		new Thread(new MapillaryExportManager(tr("Downloading..."), images,
+				dialog.chooser.getSelectedFile().toString())).start();
 	}
 
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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31163)
@@ -90,4 +90,6 @@
 	 */
 	public MapillaryImage next() {
+		if (this.getSequence() == null)
+			return null;
 		return this.getSequence().next(this);
 	}
@@ -100,4 +102,6 @@
 	 */
 	public MapillaryImage previous() {
+		if (this.getSequence() == null)
+			return null;
 		return this.getSequence().previous(this);
 	}
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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31163)
@@ -98,8 +98,11 @@
 	@Override
 	public void destroy() {
-		tgd.showDefault();
+		MapillaryToggleDialog.getInstance().mapillaryImageDisplay.setImage(null);
 		INSTANCED = false;
 		MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, false);
 		MapillaryData.deleteInstance();
+		Main.map.mapView.removeMouseListener(this);
+		MapView.removeEditLayerChangeListener(this);
+		Main.map.mapView.getEditLayer().data.removeDataSetListener(this);
 		super.destroy();
 	}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java	(revision 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryToggleDialog.java	(revision 31163)
@@ -12,4 +12,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;
@@ -20,9 +21,6 @@
 import org.openstreetmap.josm.gui.SideButton;
 import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache;
-import org.openstreetmap.josm.tools.ImageProvider;
 
 import javax.imageio.ImageIO;
-import javax.swing.ImageIcon;
-import javax.swing.JLabel;
 import javax.swing.SwingUtilities;
 import javax.swing.AbstractAction;
@@ -40,5 +38,4 @@
 	public static MapillaryToggleDialog INSTANCE;
 
-	public volatile JLabel active;
 	public volatile MapillaryImage image;
 
@@ -47,4 +44,6 @@
 			new previousPictureAction());
 
+	public MapillaryImageDisplay mapillaryImageDisplay;
+
 	final JPanel buttons;
 
@@ -52,5 +51,6 @@
 		super(tr("Mapillary image"), "mapillary", tr("Open Mapillary window"),
 				null, 200);
-		showDefault();
+		mapillaryImageDisplay = new MapillaryImageDisplay();
+		this.add(mapillaryImageDisplay);
 		buttons = new JPanel();
 		buttons.setLayout(new FlowLayout(FlowLayout.CENTER));
@@ -71,15 +71,8 @@
 	}
 
-	public void showDefault() {
-		if (active != null)
-			this.remove(active);
-		JLabel label = new JLabel("", new ImageProvider(
-				"mapillary_icon_960.png").setWidth(100).setHeight(100).get(),
-				JLabel.CENTER);
-		active = label;
-		this.add(active);
-		this.updateUI();
-	}
-
+	/**
+	 * Downloads the image of the selected MapillaryImage and sets in the
+	 * MapillaryImageDisplay object.
+	 */
 	public synchronized void updateImage() {
 		if (!SwingUtilities.isEventDispatchThread()) {
@@ -92,5 +85,4 @@
 		} else {
 			if (MapillaryLayer.INSTANCED == false) {
-				showDefault();
 				return;
 			}
@@ -99,15 +91,13 @@
 				try {
 					prev = JCSCacheManager.getCache("mapillary");
-					HashMap<String, String> headers = new HashMap<>();
 					MapillaryCache cache = new MapillaryCache(image.getKey(),
 							MapillaryCache.Type.FULL_IMAGE, prev, 200000,
-							200000, headers);
-					cache.submit(MapillaryToggleDialog.getInstance(), false);
+							200000, new HashMap<String, String>());
+					cache.submit(this, false);
 				} catch (IOException e) {
 					// TODO Auto-generated catch block
 					e.printStackTrace();
 				}
-			} else
-				showDefault();
+			}
 		}
 	}
@@ -130,6 +120,9 @@
 		@Override
 		public void actionPerformed(ActionEvent e) {
-			if (MapillaryToggleDialog.getInstance().getImage() != null)
+			if (MapillaryToggleDialog.getInstance().getImage() != null) {
 				MapillaryData.getInstance().selectNext();
+				Main.map.mapView.zoomTo(MapillaryData.getInstance()
+						.getSelectedImage().getLatLon());
+			}
 		}
 	}
@@ -144,6 +137,9 @@
 		@Override
 		public void actionPerformed(ActionEvent e) {
-			if (MapillaryToggleDialog.getInstance().getImage() != null)
+			if (MapillaryToggleDialog.getInstance().getImage() != null) {
 				MapillaryData.getInstance().selectPrevious();
+				Main.map.mapView.zoomTo(MapillaryData.getInstance()
+						.getSelectedImage().getLatLon());
+			}
 		}
 	}
@@ -161,11 +157,14 @@
 		} else {
 			try {
+				/*
+				 * BufferedImage img = ImageIO.read(new
+				 * ByteArrayInputStream(data .getContent()));
+				 * this.remove(active); JLabel label = new JLabel("", new
+				 * ImageIcon(img), JLabel.CENTER); active = label;
+				 * this.add(active); this.updateUI();
+				 */
 				BufferedImage img = ImageIO.read(new ByteArrayInputStream(data
 						.getContent()));
-				this.remove(active);
-				JLabel label = new JLabel("", new ImageIcon(img), JLabel.CENTER);
-				active = label;
-				this.add(active);
-				this.updateUI();
+				mapillaryImageDisplay.setImage(img);
 			} catch (IOException e) {
 				// TODO Auto-generated catch block
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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryDownloader.java	(revision 31163)
@@ -1,4 +1,5 @@
 package org.openstreetmap.josm.plugins.mapillary.downloads;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.data.Bounds;
@@ -58,6 +59,6 @@
 		url2 += buildParameters(hash);
 		try {
-			new Thread(new MapillarySquareDownloadManagerThread(this.data,
-					url1, url2, new Bounds(minLatLon, maxLatLon))).start();
+			Main.worker.submit(new MapillarySquareDownloadManagerThread(this.data,
+					url1, url2, new Bounds(minLatLon, maxLatLon)));
 		} catch (Exception e) {
 		}
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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportDownloadThread.java	(revision 31163)
@@ -5,11 +5,8 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
-import java.net.URL;
 import java.util.HashMap;
 import java.util.concurrent.ArrayBlockingQueue;
 
 import javax.imageio.ImageIO;
-import javax.imageio.ImageWriter;
-import javax.imageio.metadata.IIOMetadata;
 
 import org.apache.commons.jcs.access.CacheAccess;
@@ -23,5 +20,5 @@
 import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache;
 
-//import com.sun.imageio.plugins.png.PNGMetadata;
+
 
 public class MapillaryExportDownloadThread implements Runnable,
@@ -30,19 +27,20 @@
 	String url;
 	ArrayBlockingQueue<BufferedImage> queue;
+	ArrayBlockingQueue<MapillaryImage> queueImages;
+
 	ProgressMonitor monitor;
 	MapillaryImage image;
 
 	public MapillaryExportDownloadThread(MapillaryImage image,
-			ArrayBlockingQueue<BufferedImage> queue) {
+			ArrayBlockingQueue<BufferedImage> queue, ArrayBlockingQueue<MapillaryImage> queueImages) {
 		url = "https://d1cuyjsrcm0gby.cloudfront.net/" + image.getKey()
 				+ "/thumb-2048.jpg";
 		this.queue = queue;
 		this.image = image;
+		this.queueImages = queueImages;
 	}
 
 	@Override
 	public void run() {
-	    ImageWriter writer = ImageIO.getImageWritersByFormatName("png").next();
-	    //IIOMetadata metadata = writer.getDefaultImageMetadata(typeSpecifier, writeParam);
 		try {
 			CacheAccess<String, BufferedImageCacheEntry> prev = JCSCacheManager
@@ -51,9 +49,5 @@
 					prev, 200000, 200000, new HashMap<String, String>())
 					.submit(this, false);
-			queue.put(ImageIO.read(new URL(url)));
 		} catch (MalformedURLException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		} catch (InterruptedException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -69,4 +63,6 @@
 		try {
 			queue.put(ImageIO.read(new ByteArrayInputStream(data.getContent())));
+			queueImages.put(image);
+			
 		} catch (InterruptedException e) {
 			// TODO Auto-generated catch block
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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31163)
@@ -17,10 +17,17 @@
 
 	ArrayBlockingQueue<BufferedImage> queue;
+	ArrayBlockingQueue<MapillaryImage> queueImages;
+	
 	List<MapillaryImage> images;
 	String path;
 
-	public MapillaryExportManager(String title, List<MapillaryImage> images, String path) {
-		super(title, new PleaseWaitProgressMonitor("Exporting Mapillary Images"), true);
+	public MapillaryExportManager(String title, List<MapillaryImage> images,
+			String path) {
+		super(title,
+				new PleaseWaitProgressMonitor("Exporting Mapillary Images"),
+				true);
 		queue = new ArrayBlockingQueue<>(10);
+		queueImages = new ArrayBlockingQueue<>(10);
+
 		this.images = images;
 		this.path = path;
@@ -36,10 +43,15 @@
 	protected void realRun() throws SAXException, IOException,
 			OsmTransferException {
-		Thread writer = new Thread(new MapillaryExportWriterThread(path, queue, images.size(), this.getProgressMonitor()));
+		Thread writer = new Thread(new MapillaryExportWriterThread(path, queue, queueImages,
+				images.size(), this.getProgressMonitor()));
 		writer.start();
 		ThreadPoolExecutor ex = new ThreadPoolExecutor(20, 35, 25,
 				TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(10));
 		for (MapillaryImage image : images) {
-			ex.execute(new MapillaryExportDownloadThread(image, queue));
+			try {
+				ex.execute(new MapillaryExportDownloadThread(image, queue, queueImages));
+			} catch (Exception e) {
+				System.out.println("Exception");
+			}
 			try {
 				while (ex.getQueue().remainingCapacity() == 0)
@@ -51,6 +63,5 @@
 		try {
 			writer.join();
-		}
-		catch(Exception e){
+		} catch (Exception 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 31161)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportWriterThread.java	(revision 31163)
@@ -10,4 +10,5 @@
 import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
 
 
@@ -16,11 +17,13 @@
 	private String path;
 	private ArrayBlockingQueue<BufferedImage> queue;
+	private ArrayBlockingQueue<MapillaryImage> queueImages;
 	private int amount;
 	private ProgressMonitor monitor;
 	
 	public MapillaryExportWriterThread(String path,
-			ArrayBlockingQueue<BufferedImage> queue, int amount, ProgressMonitor monitor) {
+			ArrayBlockingQueue<BufferedImage> queue,ArrayBlockingQueue<MapillaryImage> queueImages, int amount, ProgressMonitor monitor) {
 		this.path = path;
 		this.queue = queue;
+		this.queueImages = queueImages;
 		this.amount = amount;
 		this.monitor = monitor;
@@ -30,11 +33,15 @@
 	public void run() {
 		monitor.setCustomText("Downloaded 0/" + amount);
-		File outputfile;
+		File outputfile = null;
 		BufferedImage img;
+		MapillaryImage mimg = null;
+		String finalPath = "";
 		for (int i = 0; i < amount; i++) {
 			try {
 				img = queue.take();
-				outputfile = new File(path + "/" + i + ".jpg");
-				ImageIO.write(img, "jpg", outputfile);
+				mimg = queueImages.take();
+				finalPath = path + "/" + mimg.getKey() + ".jpeg";
+				outputfile = new File(finalPath);
+				ImageIO.write(img, "jpeg", outputfile);
 			} catch (InterruptedException e1) {
 				// TODO Auto-generated catch block
@@ -44,4 +51,5 @@
 				e.printStackTrace();
 			}
+			
 			monitor.worked(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX / amount);
 			monitor.setCustomText("Downloaded " + (i + 1) + "/" + amount);
