Index: trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmChangeTask.java	(revision 8332)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.concurrent.Future;
 import java.util.regex.Matcher;
@@ -128,5 +129,5 @@
         private final Map<OsmPrimitive, Date> toLoad;
 
-        public HistoryLoaderAndListener(Map<OsmPrimitive, Date> toLoad) {
+        private HistoryLoaderAndListener(Map<OsmPrimitive, Date> toLoad) {
             this.toLoad = toLoad;
             add(toLoad.keySet());
@@ -138,8 +139,9 @@
         public void historyUpdated(HistoryDataSet source, PrimitiveId id) {
             Map<OsmPrimitive, Date> toLoadNext = new HashMap<>();
-            for (Iterator<OsmPrimitive> it = toLoad.keySet().iterator(); it.hasNext();) {
-                OsmPrimitive p = it.next();
+            for (Iterator<Entry<OsmPrimitive, Date>> it = toLoad.entrySet().iterator(); it.hasNext();) {
+                Entry<OsmPrimitive, Date> entry = it.next();
+                OsmPrimitive p = entry.getKey();
                 History history = source.getHistory(p.getPrimitiveId());
-                Date date = toLoad.get(p);
+                Date date = entry.getValue();
                 // If the history has been loaded and a timestamp is known
                 if (history != null && date != null) {
Index: trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java	(revision 8332)
@@ -573,4 +573,7 @@
         public boolean allElements;
 
+        /**
+         * Constructs a new {@code SearchSetting}.
+         */
         public SearchSetting() {
             this("", SearchMode.replace, false /* case insensitive */,
Index: trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java	(revision 8332)
@@ -27,4 +27,7 @@
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+
+import org.openstreetmap.josm.Main;
 
 /**
@@ -86,4 +89,10 @@
     }
 
+    private void readBytes(InputStream in, byte[] b) throws IOException {
+        if (in.read(b) < b.length) {
+            Main.error("Failed to read expected amount of bytes ("+ b.length +") from stream");
+        }
+    }
+
     /**
      * Load a Grid Shift File from an InputStream. The Grid Shift node
@@ -98,5 +107,5 @@
      * @throws IOException
      */
-    public void loadGridShiftFile(InputStream in, boolean loadAccuracy ) throws IOException {
+    public void loadGridShiftFile(InputStream in, boolean loadAccuracy) throws IOException {
         byte[] b8 = new byte[8];
         boolean bigEndian = true;
@@ -104,9 +113,9 @@
         toEllipsoid = "";
         topLevelSubGrid = null;
-        in.read(b8);
+        readBytes(in, b8);
         String overviewHeaderCountId = new String(b8, StandardCharsets.UTF_8);
         if (!"NUM_OREC".equals(overviewHeaderCountId))
             throw new IllegalArgumentException("Input file is not an NTv2 grid shift file");
-        in.read(b8);
+        readBytes(in, b8);
         overviewHeaderCount = NTV2Util.getIntBE(b8, 0);
         if (overviewHeaderCount == 11) {
@@ -119,34 +128,34 @@
                 throw new IllegalArgumentException("Input file is not an NTv2 grid shift file");
         }
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         subGridHeaderCount = NTV2Util.getInt(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         subGridCount = NTV2Util.getInt(b8, bigEndian);
         NTV2SubGrid[] subGrid = new NTV2SubGrid[subGridCount];
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         shiftType = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         version = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         fromEllipsoid = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         toEllipsoid = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         fromSemiMajorAxis = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         fromSemiMinorAxis = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         toSemiMajorAxis = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         toSemiMinorAxis = NTV2Util.getDouble(b8, bigEndian);
 
@@ -166,5 +175,5 @@
     private NTV2SubGrid[] createSubGridTree(NTV2SubGrid[] subGrid) {
         int topLevelCount = 0;
-        HashMap<String, List<NTV2SubGrid>> subGridMap = new HashMap<>();
+        Map<String, List<NTV2SubGrid>> subGridMap = new HashMap<>();
         for (int i = 0; i < subGrid.length; i++) {
             if ("NONE".equalsIgnoreCase(subGrid[i].getParentSubGridName())) {
@@ -321,4 +330,3 @@
         return toEllipsoid;
     }
-
 }
Index: trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java	(revision 8332)
@@ -75,38 +75,38 @@
         byte[] b4 = new byte[4];
         byte[] b1 = new byte[1];
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         subGridName = new String(b8, StandardCharsets.UTF_8).trim();
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         parentSubGridName = new String(b8, StandardCharsets.UTF_8).trim();
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         created = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         updated = new String(b8, StandardCharsets.UTF_8);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         minLat = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         maxLat = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         minLon = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         maxLon = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         latInterval = NTV2Util.getDouble(b8, bigEndian);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         lonInterval = NTV2Util.getDouble(b8, bigEndian);
         lonColumnCount = 1 + (int)((maxLon - minLon) / lonInterval);
         latRowCount = 1 + (int)((maxLat - minLat) / latInterval);
-        in.read(b8);
-        in.read(b8);
+        readBytes(in, b8);
+        readBytes(in, b8);
         nodeCount = NTV2Util.getInt(b8, bigEndian);
         if (nodeCount != lonColumnCount * latRowCount)
@@ -123,28 +123,34 @@
             // certain VM which are not able to read byte blocks when the resource file is
             // in a .jar file (Pieren)
-            in.read(b1); b4[0] = b1[0];
-            in.read(b1); b4[1] = b1[0];
-            in.read(b1); b4[2] = b1[0];
-            in.read(b1); b4[3] = b1[0];
+            readBytes(in, b1); b4[0] = b1[0];
+            readBytes(in, b1); b4[1] = b1[0];
+            readBytes(in, b1); b4[2] = b1[0];
+            readBytes(in, b1); b4[3] = b1[0];
             latShift[i] = NTV2Util.getFloat(b4, bigEndian);
-            in.read(b1); b4[0] = b1[0];
-            in.read(b1); b4[1] = b1[0];
-            in.read(b1); b4[2] = b1[0];
-            in.read(b1); b4[3] = b1[0];
+            readBytes(in, b1); b4[0] = b1[0];
+            readBytes(in, b1); b4[1] = b1[0];
+            readBytes(in, b1); b4[2] = b1[0];
+            readBytes(in, b1); b4[3] = b1[0];
             lonShift[i] = NTV2Util.getFloat(b4, bigEndian);
-            in.read(b1); b4[0] = b1[0];
-            in.read(b1); b4[1] = b1[0];
-            in.read(b1); b4[2] = b1[0];
-            in.read(b1); b4[3] = b1[0];
+            readBytes(in, b1); b4[0] = b1[0];
+            readBytes(in, b1); b4[1] = b1[0];
+            readBytes(in, b1); b4[2] = b1[0];
+            readBytes(in, b1); b4[3] = b1[0];
             if (loadAccuracy) {
                 latAccuracy[i] = NTV2Util.getFloat(b4, bigEndian);
             }
-            in.read(b1); b4[0] = b1[0];
-            in.read(b1); b4[1] = b1[0];
-            in.read(b1); b4[2] = b1[0];
-            in.read(b1); b4[3] = b1[0];
+            readBytes(in, b1); b4[0] = b1[0];
+            readBytes(in, b1); b4[1] = b1[0];
+            readBytes(in, b1); b4[2] = b1[0];
+            readBytes(in, b1); b4[3] = b1[0];
             if (loadAccuracy) {
                 lonAccuracy[i] = NTV2Util.getFloat(b4, bigEndian);
             }
+        }
+    }
+
+    private void readBytes(InputStream in, byte[] b) throws IOException {
+        if (in.read(b) < b.length) {
+            Main.error("Failed to read expected amount of bytes ("+ b.length +") from stream");
         }
     }
@@ -194,17 +200,17 @@
      * Bi-Linear interpolation of four nearest node values as described in
      * 'GDAit Software Architecture Manual' produced by the <a
-     * href='http://www.sli.unimelb.edu.au/gda94'>Geomatics
-     * Department of the University of Melbourne</a>
+     * href='http://www.dtpli.vic.gov.au/property-and-land-titles/geodesy/geocentric-datum-of-australia-1994-gda94/gda94-useful-tools'>
+     * Geomatics Department of the University of Melbourne</a>
      * @param a value at the A node
      * @param b value at the B node
      * @param c value at the C node
      * @param d value at the D node
-     * @param X Longitude factor
-     * @param Y Latitude factor
+     * @param x Longitude factor
+     * @param y Latitude factor
      * @return interpolated value
      */
-    private final double interpolate(float a, float b, float c, float d, double X, double Y) {
-        return a + (((double)b - (double)a) * X) + (((double)c - (double)a) * Y) +
-        (((double)a + (double)d - b - c) * X * Y);
+    private final double interpolate(float a, float b, float c, float d, double x, double y) {
+        return a + (((double)b - (double)a) * x) + (((double)c - (double)a) * y) +
+        (((double)a + (double)d - b - c) * x * y);
     }
 
@@ -213,6 +219,6 @@
      * of the GridShiftFile. The algorithm is described in
      * 'GDAit Software Architecture Manual' produced by the <a
-     * href='http://www.sli.unimelb.edu.au/gda94'>Geomatics
-     * Department of the University of Melbourne</a>
+     * href='http://www.dtpli.vic.gov.au/property-and-land-titles/geodesy/geocentric-datum-of-australia-1994-gda94/gda94-useful-tools'>
+     * Geomatics Department of the University of Melbourne</a>
      * <p>This method is thread safe for both memory based and file based node data.
      * @param gs GridShift object containing the coordinate to shift and the shift values
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java	(revision 8332)
@@ -68,4 +68,8 @@
     private JPanel pnlTagResolver;
 
+    /**
+     * Constructs a new {@code PasteTagsConflictResolverDialog}.
+     * @param owner parent component
+     */
     public PasteTagsConflictResolverDialog(Component owner) {
         super(JOptionPane.getFrameForComponent(owner), ModalityType.DOCUMENT_MODAL);
@@ -114,6 +118,6 @@
         ApplyAction applyAction = new ApplyAction();
         allPrimitivesResolver.getModel().addPropertyChangeListener(applyAction);
-        for (OsmPrimitiveType type: resolvers.keySet()) {
-            resolvers.get(type).getModel().addPropertyChangeListener(applyAction);
+        for (TagConflictResolver r : resolvers.values()) {
+            r.getModel().addPropertyChangeListener(applyAction);
         }
         pnl.add(new SideButton(applyAction));
@@ -266,5 +270,5 @@
     class CancelAction extends AbstractAction {
 
-        public CancelAction() {
+        private CancelAction() {
             putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution"));
             putValue(Action.NAME, tr("Cancel"));
@@ -282,5 +286,5 @@
     class ApplyAction extends AbstractAction implements PropertyChangeListener {
 
-        public ApplyAction() {
+        private ApplyAction() {
             putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts"));
             putValue(Action.NAME, tr("Apply"));
@@ -354,10 +358,10 @@
     }
 
-    public static class StatisticsInfo {
+    private static class StatisticsInfo {
         public int numTags;
         public Map<OsmPrimitiveType, Integer> sourceInfo;
         public Map<OsmPrimitiveType, Integer> targetInfo;
 
-        public StatisticsInfo() {
+        private StatisticsInfo() {
             sourceInfo = new HashMap<>();
             targetInfo = new HashMap<>();
@@ -366,5 +370,5 @@
 
     private static class StatisticsTableColumnModel extends DefaultTableColumnModel {
-        public StatisticsTableColumnModel() {
+        private StatisticsTableColumnModel() {
             TableCellRenderer renderer = new StatisticsInfoRenderer();
             TableColumn col = null;
@@ -397,5 +401,5 @@
         private transient List<StatisticsInfo> data;
 
-        public StatisticsTableModel() {
+        private StatisticsTableModel() {
             data = new ArrayList<>();
         }
@@ -516,5 +520,5 @@
         }
 
-        public StatisticsInfoTable(StatisticsTableModel model) {
+        private StatisticsInfoTable(StatisticsTableModel model) {
             build(model);
         }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java	(revision 8332)
@@ -9,4 +9,5 @@
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.Objects;
 
 import org.openstreetmap.josm.data.osm.Relation;
@@ -121,7 +122,8 @@
         // lookup the entry for editor and remove it
         //
-        for (DialogContext context: openDialogs.keySet()) {
-            if (openDialogs.get(context) == editor) {
-                openDialogs.remove(context);
+        for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext();) {
+            Entry<DialogContext, RelationEditor> entry = it.next();
+            if (Objects.equals(entry.getValue(), editor)) {
+                it.remove();
                 break;
             }
@@ -215,13 +217,9 @@
     public void windowClosed(WindowEvent e) {
         RelationEditor editor = (RelationEditor)e.getWindow();
-        DialogContext context = null;
-        for (DialogContext c : openDialogs.keySet()) {
-            if (editor.equals(openDialogs.get(c))) {
-                context = c;
+        for (Iterator<Entry<DialogContext, RelationEditor>> it = openDialogs.entrySet().iterator(); it.hasNext(); ) {
+            if (editor.equals(it.next().getValue())) {
+                it.remove();
                 break;
             }
-        }
-        if (context != null) {
-            openDialogs.remove(context);
         }
     }
Index: trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java	(revision 8332)
@@ -9,6 +9,9 @@
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
 
 import javax.swing.JOptionPane;
@@ -105,15 +108,11 @@
      */
     public void hide(HistoryBrowserDialog dialog) {
-        long id = 0;
-        for (long i: dialogs.keySet()) {
-            if (dialogs.get(i) == dialog) {
-                id = i;
+        for (Iterator<Entry<Long, HistoryBrowserDialog>> it = dialogs.entrySet().iterator(); it.hasNext(); ) {
+            if (Objects.equals(it.next().getValue(), dialog)) {
+                it.remove();
+                if (dialogs.isEmpty()) {
+                    new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF);
+                }
                 break;
-            }
-        }
-        if (id > 0) {
-            dialogs.remove(id);
-            if (dialogs.isEmpty()) {
-                new WindowGeometry(dialog).remember(WINDOW_GEOMETRY_PREF);
             }
         }
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java	(revision 8332)
@@ -11,5 +11,4 @@
 import java.awt.FlowLayout;
 import java.awt.GridBagLayout;
-import java.awt.Image;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -28,5 +27,4 @@
 import javax.swing.BorderFactory;
 import javax.swing.Icon;
-import javax.swing.ImageIcon;
 import javax.swing.JButton;
 import javax.swing.JComponent;
Index: trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java	(revision 8332)
@@ -20,4 +20,5 @@
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import javax.swing.BorderFactory;
@@ -275,7 +276,7 @@
     protected UploadStrategy getUploadStrategy() {
         UploadStrategy strategy = null;
-        for (UploadStrategy s: rbStrategy.keySet()) {
-            if (rbStrategy.get(s).isSelected()) {
-                strategy = s;
+        for (Entry<UploadStrategy, JRadioButton> e : rbStrategy.entrySet()) {
+            if (e.getValue().isSelected()) {
+                strategy = e.getKey();
                 break;
             }
Index: trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java	(revision 8332)
@@ -12,5 +12,4 @@
 import java.awt.Graphics2D;
 import java.awt.GridBagLayout;
-import java.awt.Image;
 import java.awt.Point;
 import java.awt.Rectangle;
@@ -34,5 +33,4 @@
 import javax.swing.Action;
 import javax.swing.Icon;
-import javax.swing.ImageIcon;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java	(revision 8332)
@@ -7,4 +7,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.regex.Pattern;
 
@@ -204,7 +205,7 @@
     public String toString() {
         StringBuilder res = new StringBuilder("Cascade{ ");
-        for (String key : prop.keySet()) {
-            res.append(key+":");
-            Object val = prop.get(key);
+        for (Entry<String, Object> entry : prop.entrySet()) {
+            res.append(entry.getKey()+":");
+            Object val = entry.getValue();
             if (val instanceof float[]) {
                 res.append(Arrays.toString((float[]) val));
Index: trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java	(revision 8332)
@@ -29,4 +29,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.TreeSet;
 
@@ -1123,8 +1124,8 @@
 
             if (display != null) {
-                for (String val : lhm.keySet()) {
-                    String k = lhm.get(val).toString();
+                for (Entry<String, PresetListEntry> entry : lhm.entrySet()) {
+                    String k = entry.getValue().toString();
                     if (k != null && k.equals(display)) {
-                        value = val;
+                        value = entry.getKey();
                         break;
                     }
Index: trunk/src/org/openstreetmap/josm/io/AbstractReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/io/AbstractReader.java	(revision 8332)
@@ -9,4 +9,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.openstreetmap.josm.Main;
@@ -82,8 +83,9 @@
      */
     protected void processWaysAfterParsing() throws IllegalDataException{
-        for (Long externalWayId: ways.keySet()) {
+        for (Entry<Long, Collection<Long>> entry : ways.entrySet()) {
+            Long externalWayId = entry.getKey();
             Way w = (Way)externalIdMap.get(new SimplePrimitiveId(externalWayId, OsmPrimitiveType.WAY));
             List<Node> wayNodes = new ArrayList<>();
-            for (long id : ways.get(externalWayId)) {
+            for (long id : entry.getValue()) {
                 Node n = (Node)externalIdMap.get(new SimplePrimitiveId(id, OsmPrimitiveType.NODE));
                 if (n == null) {
@@ -132,10 +134,11 @@
         }
 
-        for (Long externalRelationId : relations.keySet()) {
+        for (Entry<Long, Collection<RelationMemberData>> entry : relations.entrySet()) {
+            Long externalRelationId = entry.getKey();
             Relation relation = (Relation) externalIdMap.get(
                     new SimplePrimitiveId(externalRelationId, OsmPrimitiveType.RELATION)
             );
             List<RelationMember> relationMembers = new ArrayList<>();
-            for (RelationMemberData rm : relations.get(externalRelationId)) {
+            for (RelationMemberData rm : entry.getValue()) {
                 OsmPrimitive primitive = null;
 
Index: trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/io/CacheCustomContent.java	(revision 8332)
@@ -19,15 +19,19 @@
  * use {@link RuntimeException} if no exception must be handled.
  * @author xeen
- *
+ * @since 1450
  */
 public abstract class CacheCustomContent<T extends Throwable> {
-    /**
-     * Common intervals
-     */
+
+    /** Update interval meaning an update is always needed */
     public static final int INTERVAL_ALWAYS = -1;
+    /** Update interval meaning an update is needed each hour */
     public static final int INTERVAL_HOURLY = 60*60;
+    /** Update interval meaning an update is needed each day */
     public static final int INTERVAL_DAILY = INTERVAL_HOURLY * 24;
+    /** Update interval meaning an update is needed each week */
     public static final int INTERVAL_WEEKLY = INTERVAL_DAILY * 7;
+    /** Update interval meaning an update is needed each month */
     public static final int INTERVAL_MONTHLY = INTERVAL_WEEKLY * 4;
+    /** Update interval meaning an update is never needed */
     public static final int INTERVAL_NEVER = Integer.MAX_VALUE;
 
@@ -61,16 +65,8 @@
 
     /**
-     * This function serves as a comfort hook to perform additional checks if the cache is valid
-     * @return True if the cached copy is still valid
-     */
-    protected boolean isCacheValid() {
-        return true;
-    }
-
-    /**
      * Initializes the class. Note that all read data will be stored in memory until it is flushed
      * by flushData().
-     * @param ident
-     * @param updateInterval
+     * @param ident ident that identifies the stored file. Includes file-ending.
+     * @param updateInterval update interval in seconds. -1 means always
      */
     public CacheCustomContent(String ident, int updateInterval) {
@@ -78,4 +74,12 @@
         this.updateInterval = updateInterval;
         this.path = new File(Main.pref.getCacheDirectory(), ident);
+    }
+
+    /**
+     * This function serves as a comfort hook to perform additional checks if the cache is valid
+     * @return True if the cached copy is still valid
+     */
+    protected boolean isCacheValid() {
+        return true;
     }
 
@@ -104,4 +108,5 @@
      * Updates data if required
      * @return Returns the data
+     * @throws T if an error occurs
      */
     public byte[] updateIfRequired() throws T {
@@ -114,4 +119,5 @@
      * Updates data if required
      * @return Returns the data as string
+     * @throws T if an error occurs
      */
     public String updateIfRequiredString() throws T {
@@ -124,4 +130,5 @@
      * Executes an update regardless of updateInterval
      * @return Returns the data
+     * @throws T if an error occurs
      */
     public byte[] updateForce() throws T {
@@ -135,4 +142,5 @@
      * Executes an update regardless of updateInterval
      * @return Returns the data as String
+     * @throws T if an error occurs
      */
     public String updateForceString() throws T {
@@ -144,4 +152,5 @@
      * Returns the data without performing any updates
      * @return the data
+     * @throws T if an error occurs
      */
     public byte[] getData() throws T {
@@ -155,4 +164,5 @@
      * Returns the data without performing any updates
      * @return the data as String
+     * @throws T if an error occurs
      */
     public String getDataString() throws T {
@@ -170,5 +180,7 @@
         try (BufferedInputStream input = new BufferedInputStream(new FileInputStream(path))) {
             this.data = new byte[input.available()];
-            input.read(this.data);
+            if (input.read(this.data) < this.data.length) {
+                Main.error("Failed to read expected contents from "+path);
+            }
         } catch (IOException e) {
             if (!isOffline()) {
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java	(revision 8332)
@@ -15,4 +15,5 @@
 import java.util.HashSet;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 
@@ -94,5 +95,5 @@
 
         private String getToolTip() {
-            StringBuilder sb=new StringBuilder();
+            StringBuilder sb = new StringBuilder();
             sb.append("<html>");
             sb.append(tr("Old values of"));
@@ -100,14 +101,13 @@
             sb.append(tag);
             sb.append("</b><br/>");
-            for (String k: valueCount.keySet()) {
+            for (Entry<String, Integer> e : valueCount.entrySet()) {
                 sb.append("<b>");
-                sb.append(valueCount.get(k));
+                sb.append(e.getValue());
                 sb.append(" x </b>");
-                sb.append(k);
+                sb.append(e.getKey());
                 sb.append("<br/>");
             }
             sb.append("</html>");
             return sb.toString();
-
         }
     }
Index: trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/AddWayHandler.java	(revision 8332)
@@ -12,4 +12,5 @@
 import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.openstreetmap.josm.Main;
@@ -119,5 +120,5 @@
      * Find the node with almost the same ccords in dataset or in already added nodes
      * @since 5845
-     **/
+     */
     Node findOrCreateNode(LatLon ll,  List<Command> commands) {
         Node nd = null;
@@ -132,7 +133,8 @@
 
         Node prev = null;
-        for (LatLon lOld: addedNodes.keySet()) {
+        for (Entry<LatLon, Node> entry : addedNodes.entrySet()) {
+            LatLon lOld = entry.getKey();
             if (lOld.greatCircleDistance(ll) < Main.pref.getDouble("remotecontrol.tolerance", 0.1)) {
-                prev = addedNodes.get(lOld);
+                prev = entry.getValue();
                 break;
             }
Index: trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 8332)
@@ -484,10 +484,10 @@
 
         layers = new ArrayList<>();
-        for (int idx : layersMap.keySet()) {
-            Layer layer = layersMap.get(idx);
+        for (Entry<Integer, Layer> entry : layersMap.entrySet()) {
+            Layer layer = entry.getValue();
             if (layer == null) {
                 continue;
             }
-            Element el = elems.get(idx);
+            Element el = elems.get(entry.getKey());
             if (el.hasAttribute("visible")) {
                 layer.setVisible(Boolean.parseBoolean(el.getAttribute("visible")));
Index: trunk/src/org/openstreetmap/josm/tools/MultiMap.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/MultiMap.java	(revision 8331)
+++ trunk/src/org/openstreetmap/josm/tools/MultiMap.java	(revision 8332)
@@ -231,6 +231,6 @@
     public String toString() {
         List<String> entries = new ArrayList<>(map.size());
-        for (A key : map.keySet()) {
-            entries.add(key + "->{" + Utils.join(",", map.get(key)) + "}");
+        for (Entry<A, Set<B>> entry : map.entrySet()) {
+            entries.add(entry.getKey() + "->{" + Utils.join(",", entry.getValue()) + "}");
         }
         return "(" + Utils.join(",", entries) + ")";
