Index: trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java	(revision 6623)
@@ -211,5 +211,4 @@
                 return null;
             // try to zoom to the first selected layer
-            //
             Layer l = getFirstSelectedLayer();
             if (l == null) return null;
@@ -245,6 +244,5 @@
             // ensure reasonable zoom level when zooming onto single nodes.
             v.enlargeToMinDegrees(0.0005);
-        }
-        else if (mode.equals("download")) {
+        } else if (mode.equals("download")) {
             Bounds bounds = DownloadDialog.getSavedDownloadBounds();
             if (bounds != null) {
Index: trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/actions/CreateMultipolygonAction.java	(revision 6623)
@@ -61,9 +61,9 @@
     /**
      * Constructs a new {@code CreateMultipolygonAction}.
+     * @param update {@code true} if the multipolygon must be updated, {@code false} if it must be created
      */
     public CreateMultipolygonAction(final boolean update) {
         super(getName(update), "multipoly_create", getName(update),
-                update
-                        ? null
+                update  ? null
                         : Shortcut.registerShortcut("tools:multipoly", tr("Tool: {0}", getName(false)), KeyEvent.VK_A, Shortcut.ALT_CTRL),
                 true, update ? "multipoly_update" : "multipoly_create", true);
@@ -73,4 +73,52 @@
     private static String getName(boolean update) {
         return update ? tr("Update multipolygon") : tr("Create multipolygon");
+    }
+    
+    private class CreateUpdateMultipolygonTask implements Runnable {
+        private final Collection<Way> selectedWays;
+        private final Relation multipolygonRelation;
+
+        public CreateUpdateMultipolygonTask(Collection<Way> selectedWays, Relation multipolygonRelation) {
+            this.selectedWays = selectedWays;
+            this.multipolygonRelation = multipolygonRelation;
+        }
+
+        @Override
+        public void run() {
+            final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation);
+            if (commandAndRelation == null) {
+                return;
+            }
+            final Command command = commandAndRelation.a;
+            final Relation relation = commandAndRelation.b;
+
+
+            // to avoid EDT violations
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    Main.main.undoRedo.add(command);
+                }
+            });
+
+            // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
+            // knows about the new relation before we try to select it.
+            // (Yes, we are already in event dispatch thread. But DatasetEventManager
+            // uses 'SwingUtilities.invokeLater' to fire events so we have to do
+            // the same.)
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    Main.map.relationListDialog.selectRelation(relation);
+                    if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) {
+                        //Open relation edit window, if set up in preferences
+                        RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null);
+
+                        editor.setModal(true);
+                        editor.setVisible(true);
+                    }
+                }
+            });
+        }
     }
 
@@ -109,45 +157,4 @@
                 : null;
 
-        // runnable to create/update multipolygon relation
-        final Runnable createOrUpdateMultipolygonTask = new Runnable() {
-            @Override
-            public void run() {
-                final Pair<SequenceCommand, Relation> commandAndRelation = createMultipolygonCommand(selectedWays, multipolygonRelation);
-                if (commandAndRelation == null) {
-                    return;
-                }
-                final Command command = commandAndRelation.a;
-                final Relation relation = commandAndRelation.b;
-
-
-                // to avoid EDT violations
-                SwingUtilities.invokeLater(new Runnable() {
-                    @Override
-                    public void run() {
-                        Main.main.undoRedo.add(command);
-                    }
-                });
-
-                // Use 'SwingUtilities.invokeLater' to make sure the relationListDialog
-                // knows about the new relation before we try to select it.
-                // (Yes, we are already in event dispatch thread. But DatasetEventManager
-                // uses 'SwingUtilities.invokeLater' to fire events so we have to do
-                // the same.)
-                SwingUtilities.invokeLater(new Runnable() {
-                    @Override
-                    public void run() {
-                        Main.map.relationListDialog.selectRelation(relation);
-                        if (Main.pref.getBoolean("multipoly.show-relation-editor", false)) {
-                            //Open relation edit window, if set up in preferences
-                            RelationEditor editor = RelationEditor.getEditor(Main.main.getEditLayer(), relation, null);
-
-                            editor.setModal(true);
-                            editor.setVisible(true);
-                        }
-                    }
-                });
-            }
-        };
-
         // download incomplete relation if necessary
         if (multipolygonRelation != null && (multipolygonRelation.isIncomplete() || multipolygonRelation.hasIncompleteMembers())) {
@@ -155,5 +162,5 @@
         }
         // create/update multipolygon relation
-        Main.worker.submit(createOrUpdateMultipolygonTask);
+        Main.worker.submit(new CreateUpdateMultipolygonTask(selectedWays, multipolygonRelation));
 
     }
@@ -181,8 +188,8 @@
 
         // add ways of existing relation to include them in polygon analysis
-        selectedWays = new HashSet<Way>(selectedWays);
-        selectedWays.addAll(selectedMultipolygonRelation.getMemberPrimitives(Way.class));
-
-        final MultipolygonCreate polygon = analyzeWays(selectedWays, true);
+        Set<Way> ways = new HashSet<Way>(selectedWays);
+        ways.addAll(selectedMultipolygonRelation.getMemberPrimitives(Way.class));
+
+        final MultipolygonCreate polygon = analyzeWays(ways, true);
         if (polygon == null) {
             return null; //could not make multipolygon.
@@ -206,5 +213,5 @@
 
     /**
-     * Returns a pair of a multipolygon creating/modifying {@link Command} as well as the multipolygon {@link Relation}.
+     * Returns a {@link Pair} of a multipolygon creating/modifying {@link Command} as well as the multipolygon {@link Relation}.
      */
     public static Pair<SequenceCommand, Relation> createMultipolygonCommand(Collection<Way> selectedWays, Relation selectedMultipolygonRelation) {
@@ -309,5 +316,5 @@
     }
 
-    static public final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
+    public static final List<String> DEFAULT_LINEAR_TAGS = Arrays.asList(new String[] {"barrier", "source"});
 
     /**
Index: trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java	(revision 6623)
@@ -4,4 +4,5 @@
 import java.util.Collection;
 import java.util.LinkedList;
+import java.util.Set;
 import java.util.TreeSet;
 
@@ -20,9 +21,9 @@
      * outer endpoints of selected ways
      */
-    TreeSet<Node> outerNodes;
+    Set<Node> outerNodes;
     /**
      * endpoints of selected ways
      */
-    TreeSet<Node> nodes;
+    Set<Node> nodes;
 
     /**
Index: trunk/src/org/openstreetmap/josm/data/osm/history/History.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/history/History.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/data/osm/history/History.java	(revision 6623)
@@ -209,5 +209,5 @@
     }
 
-    public HistoryOsmPrimitive get(int idx) {
+    public HistoryOsmPrimitive get(int idx) throws IndexOutOfBoundsException {
         if (idx < 0 || idx >= versions.size())
             throw new IndexOutOfBoundsException(MessageFormat.format("Parameter ''{0}'' in range 0..{1} expected. Got ''{2}''.", "idx", versions.size()-1, idx));
@@ -231,5 +231,9 @@
     }
 
-    public boolean isEmpty() {
+    /**
+     * Returns true if this history contains no version.
+     * @return {@code true} if this history contains no version, {@code false} otherwise
+     */
+    public final boolean isEmpty() {
         return versions.isEmpty();
     }
Index: trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java	(revision 6623)
@@ -156,10 +156,8 @@
         double enlargeEast = Math.min(maxEnlargePercent - 10*Math.log(diffEast), 1)/100;
         double enlargeNorth = Math.min(maxEnlargePercent - 10*Math.log(diffNorth), 1)/100;
-        System.out.println(enlargeEast);
 
         visit(bounds.getMin().add(-enlargeEast/2, -enlargeNorth/2));
         visit(bounds.getMax().add(+enlargeEast/2, +enlargeNorth/2));
     }
-
 
     /**
Index: trunk/src/org/openstreetmap/josm/data/validation/Test.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/data/validation/Test.java	(revision 6623)
@@ -34,6 +34,6 @@
  * @author frsantos
  */
-public class Test extends AbstractVisitor
-{
+public class Test extends AbstractVisitor {
+
     /** Name of the test */
     protected final String name;
@@ -90,13 +90,26 @@
      * A test that forwards all primitives to {@link #check(OsmPrimitive)}.
      */
-    public static abstract class TagTest extends Test {
+    public abstract static class TagTest extends Test {
+        /**
+         * Constructs a new {@code TagTest} with given name and description.
+         * @param name The test name
+         * @param description The test description
+         */
         public TagTest(String name, String description) {
             super(name, description);
         }
 
+        /**
+         * Constructs a new {@code TagTest} with given name.
+         * @param name The test name
+         */
         public TagTest(String name) {
             super(name);
         }
 
+        /**
+         * Checks the tags of the given primitive.
+         * @param p The primitive to test
+         */
         public abstract void check(final OsmPrimitive p);
 
@@ -163,5 +176,5 @@
      * actions and destroy the used structures.
      * <p>
-     * If you override this method, don't forget to cleanup {@link #progressMonitor}
+     * If you override this method, don't forget to cleanup {@code progressMonitor}
      * (most overrides call {@code super.endTest()} to do this).
      */
@@ -191,4 +204,9 @@
     }
 
+    /**
+     * Determines if the primitive is usable for tests.
+     * @param p The primitive
+     * @return {@code true} if the primitive can be tested, {@code false} otherwise
+     */
     public boolean isPrimitiveUsable(OsmPrimitive p) {
         return p.isUsable() && (!(p instanceof Way) || (((Way) p).getNodesCount() > 1)); // test only Ways with at least 2 nodes
@@ -222,4 +240,5 @@
     /**
      * Called when the used submits the preferences
+     * @return {@code true} if restart is required, {@code false} otherwise
      */
     public boolean ok() {
@@ -265,8 +284,16 @@
     }
 
+    /**
+     * Returns the test name.
+     * @return The test name
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Determines if the test has been canceled.
+     * @return {@code true} if the test has been canceled, {@code false} otherwise
+     */
     public boolean isCanceled() {
         return progressMonitor.isCanceled();
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java	(revision 6623)
@@ -33,4 +33,8 @@
 public abstract class CrossingWays extends Test {
     protected static final int CROSSING_WAYS = 601;
+    
+    private static final String HIGHWAY = "highway";
+    private static final String RAILWAY = "railway";
+    private static final String WATERWAY = "waterway";
 
     /** All way segments, grouped by cells */
@@ -47,7 +51,7 @@
             return super.isPrimitiveUsable(w)
                     && !isProposedOrAbandoned(w)
-                    && (w.hasKey("highway")
-                    || w.hasKey("waterway")
-                    || (w.hasKey("railway") && !isSubwayOrTram(w))
+                    && (w.hasKey(HIGHWAY)
+                    || w.hasKey(WATERWAY)
+                    || (w.hasKey(RAILWAY) && !isSubwayOrTram(w))
                     || isCoastline(w)
                     || isBuilding(w));
@@ -59,5 +63,5 @@
                 return true;
             }
-            if (w1.hasKey("highway") && w2.hasKey("highway") && !Utils.equal(w1.get("level"), w2.get("level"))) {
+            if (w1.hasKey(HIGHWAY) && w2.hasKey(HIGHWAY) && !Utils.equal(w1.get("level"), w2.get("level"))) {
                 return true;
             }
@@ -68,6 +72,6 @@
                 return true;
             }
-            if ((w1.hasTag("waterway", "river") && w2.hasTag("waterway", "riverbank"))
-                    || (w2.hasTag("waterway", "river") && w1.hasTag("waterway", "riverbank"))) {
+            if ((w1.hasTag(WATERWAY, "river") && w2.hasTag(WATERWAY, "riverbank"))
+                    || (w2.hasTag(WATERWAY, "river") && w1.hasTag(WATERWAY, "riverbank"))) {
                 return true;
             }
@@ -82,8 +86,8 @@
             if (isBuilding(w1)) {
                 return ("Crossing buildings");
-            } else if (w1.hasKey("waterway") && w2.hasKey("waterway")) {
+            } else if (w1.hasKey(WATERWAY) && w2.hasKey(WATERWAY)) {
                 return tr("Crossing waterways");
-            } else if ((w1.hasKey("highway") && w2.hasKey("waterway"))
-                    || (w2.hasKey("highway") && w1.hasKey("waterway"))) {
+            } else if ((w1.hasKey(HIGHWAY) && w2.hasKey(WATERWAY))
+                    || (w2.hasKey(HIGHWAY) && w1.hasKey(WATERWAY))) {
                 return tr("Crossing waterway/highway");
             } else {
@@ -207,9 +211,9 @@
 
     static boolean isSubwayOrTram(OsmPrimitive w) {
-        return w.hasTag("railway", "subway", "tram");
+        return w.hasTag(RAILWAY, "subway", "tram");
     }
 
     static boolean isProposedOrAbandoned(OsmPrimitive w) {
-        return w.hasTag("highway", "proposed") || w.hasTag("railway", "proposed", "abandoned");
+        return w.hasTag(HIGHWAY, "proposed") || w.hasTag(RAILWAY, "proposed", "abandoned");
     }
 
Index: trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java	(revision 6623)
@@ -17,8 +17,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.command.ChangePropertyCommand;
-import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
-import org.openstreetmap.josm.data.osm.Relation;
-import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.data.validation.FixableTestError;
 import org.openstreetmap.josm.data.validation.Severity;
@@ -194,7 +191,7 @@
             return Collections.emptyList();
         }
+        final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>();
         try {
             final Object r = parse(value, mode);
-            final List<OpeningHoursTestError> errors = new ArrayList<OpeningHoursTestError>();
             String prettifiedValue = null;
             try {
@@ -212,8 +209,10 @@
                 errors.add(new OpeningHoursTestError(tr("opening_hours value can be prettified"), Severity.OTHER, prettifiedValue));
             }
-            return errors;
-        } catch (final Exception ex) {
-            throw new RuntimeException(ex);
-        }
+        } catch (ScriptException ex) {
+            Main.error(ex);
+        } catch (NoSuchMethodException ex) {
+            Main.error(ex);
+        }
+        return errors;
     }
 
Index: trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/ConditionalOptionPaneUtil.java	(revision 6623)
@@ -33,5 +33,5 @@
  */
 public final class ConditionalOptionPaneUtil {
-    static public final int DIALOG_DISABLED_OPTION = Integer.MIN_VALUE;
+    public static final int DIALOG_DISABLED_OPTION = Integer.MIN_VALUE;
 
     /** (preference key => return value) mappings valid for the current operation (no, those two maps cannot be combined) */
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java	(revision 6623)
@@ -14,4 +14,5 @@
 import javax.swing.table.TableCellRenderer;
 
+import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.conflict.ConflictColors;
 import org.openstreetmap.josm.gui.widgets.JosmComboBox;
@@ -64,4 +65,6 @@
                         setBackground(ConflictColors.BGCOLOR_TAG_KEEP_ALL.get());
                         break;
+                    default:
+                        Main.error("Unknown decision type: "+decision.getDecisionType());
                     }
                 } else {
@@ -143,6 +146,6 @@
 
         MultiValueResolutionDecision decision = (MultiValueResolutionDecision)value;
-        TagConflictResolverModel model = (TagConflictResolverModel) table.getModel();
-        boolean conflict = model.getKeysWithConflicts().contains(model.getKey(row));
+        TagConflictResolverModel tagModel = (TagConflictResolverModel) table.getModel();
+        boolean conflict = tagModel.getKeysWithConflicts().contains(tagModel.getKey(row));
         renderColors(decision, isSelected, conflict);
         renderToolTipText(decision);
Index: trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java	(revision 6623)
@@ -18,4 +18,24 @@
 public class RelationMemberConflictResolverColumnModel extends DefaultTableColumnModel {
 
+    private final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
+    
+    private final OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
+        @Override
+        public Component getTableCellRendererComponent(JTable table,
+                Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+            return setColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
+                    table, isSelected, row);
+        }
+    };
+    
+    private final TableCellRenderer tableRenderer = new TableCellRenderer() {
+        @Override
+        public Component getTableCellRendererComponent(JTable table, Object value,
+                boolean isSelected, boolean hasFocus, int row, int column) {
+            return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
+                    table, isSelected, row);
+        }
+    };
+    
     private static Component setColors(Component comp, JTable table, boolean isSelected, int row) {
         RelationMemberConflictResolverModel model = (RelationMemberConflictResolverModel) table.getModel();
@@ -40,24 +60,5 @@
     }
     
-    protected void createColumns() {
-        final DefaultTableCellRenderer defaultTableCellRenderer = new DefaultTableCellRenderer();
-        
-        OsmPrimitivRenderer primitiveRenderer = new OsmPrimitivRenderer() {
-            @Override
-            public Component getTableCellRendererComponent(JTable table,
-                    Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-                return setColors(super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
-                        table, isSelected, row);
-            }
-        };
-        
-        TableCellRenderer tableRenderer = new TableCellRenderer() {
-            @Override
-            public Component getTableCellRendererComponent(JTable table, Object value,
-                    boolean isSelected, boolean hasFocus, int row, int column) {
-                return setColors(defaultTableCellRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column),
-                        table, isSelected, row);
-            }
-        };
+    protected final void createColumns() {
         
         AutoCompletingTextField roleEditor = new AutoCompletingTextField();
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java	(revision 6623)
@@ -560,8 +560,8 @@
         }
         
-        // Discard parameter as we do not want to operate always on real selection here, especially in draw mode
-        newSelection = Main.main.getInProgressSelection();
-        if (newSelection == null) {
-            newSelection = Collections.<OsmPrimitive>emptyList();
+        // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode
+        Collection<OsmPrimitive> newSel = Main.main.getInProgressSelection();
+        if (newSel == null) {
+            newSel = Collections.<OsmPrimitive>emptyList();
         }
 
@@ -584,5 +584,5 @@
         valueCount.clear();
         EnumSet<TaggingPresetType> types = EnumSet.noneOf(TaggingPresetType.class);
-        for (OsmPrimitive osm : newSelection) {
+        for (OsmPrimitive osm : newSel) {
             types.add(TaggingPresetType.forPrimitive(osm));
             for (String key : osm.keySet()) {
@@ -606,6 +606,6 @@
                 count += e1.getValue();
             }
-            if (count < newSelection.size()) {
-                e.getValue().put("", newSelection.size() - count);
+            if (count < newSel.size()) {
+                e.getValue().put("", newSel.size() - count);
             }
             tagData.addRow(new Object[]{e.getKey(), e.getValue()});
@@ -617,5 +617,5 @@
 
         Map<Relation, MemberInfo> roles = new HashMap<Relation, MemberInfo>();
-        for (OsmPrimitive primitive: newSelection) {
+        for (OsmPrimitive primitive: newSel) {
             for (OsmPrimitive ref: primitive.getReferrers()) {
                 if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {
@@ -657,5 +657,5 @@
         membershipTable.setVisible(membershipData.getRowCount() > 0);
 
-        boolean hasSelection = !newSelection.isEmpty();
+        boolean hasSelection = !newSel.isEmpty();
         boolean hasTags = hasSelection && tagData.getRowCount() > 0;
         boolean hasMemberships = hasSelection && membershipData.getRowCount() > 0;
Index: trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/history/VersionTable.java	(revision 6623)
@@ -31,4 +31,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.AbstractInfoAction;
+import org.openstreetmap.josm.data.osm.history.History;
 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
@@ -58,22 +59,20 @@
             public void keyReleased(KeyEvent e) {
                 // navigate history down/up using the corresponding arrow keys.
-                try {
-                    final HistoryOsmPrimitive ref = model.getReferencePointInTime();
-                    final HistoryOsmPrimitive cur = model.getCurrentPointInTime();
-                    if (e.getKeyCode() == KeyEvent.VK_DOWN) {
-                        // compute both values first and set them afterwards such that nothing is changed in case of an exception (e.g., reached top/bottom)
-                        final HistoryOsmPrimitive refNext = model.getHistory().from(ref.getVersion()).sortAscending().get(1);
-                        final HistoryOsmPrimitive curNext = model.getHistory().from(cur.getVersion()).sortAscending().get(1);
-                        model.setReferencePointInTime(refNext);
-                        model.setCurrentPointInTime(curNext);
-                    } else if (e.getKeyCode() == KeyEvent.VK_UP) {
-                        // compute both values first and set them afterwards such that nothing is changed in case of an exception (e.g., reached top/bottom)
-                        final HistoryOsmPrimitive refNext = model.getHistory().until(ref.getVersion()).sortDescending().get(1);
-                        final HistoryOsmPrimitive curNext = model.getHistory().until(cur.getVersion()).sortDescending().get(1);
-                        model.setReferencePointInTime(refNext);
-                        model.setCurrentPointInTime(curNext);
+                long ref = model.getReferencePointInTime().getVersion();
+                long cur = model.getCurrentPointInTime().getVersion();
+                if (e.getKeyCode() == KeyEvent.VK_DOWN) {
+                    History refNext = model.getHistory().from(ref);
+                    History curNext = model.getHistory().from(cur);
+                    if (refNext.getNumVersions() > 1 && curNext.getNumVersions() > 1) {
+                        model.setReferencePointInTime(refNext.sortAscending().get(1));
+                        model.setCurrentPointInTime(curNext.sortAscending().get(1));
                     }
-                } catch (NullPointerException ignore) {
-                } catch (IndexOutOfBoundsException ignore) {
+                } else if (e.getKeyCode() == KeyEvent.VK_UP) {
+                    History refNext = model.getHistory().until(ref);
+                    History curNext = model.getHistory().until(cur);
+                    if (refNext.getNumVersions() > 1 && curNext.getNumVersions() > 1) {
+                        model.setReferencePointInTime(refNext.sortDescending().get(1));
+                        model.setCurrentPointInTime(curNext.sortDescending().get(1));
+                    }
                 }
             }
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/LabelCompositionStrategy.java	(revision 6623)
@@ -153,5 +153,5 @@
          * The list of default name tags from which a label candidate is derived.
          */
-        public static final String[] DEFAULT_NAME_TAGS = {
+        private static final String[] DEFAULT_NAME_TAGS = {
             "name:" + LanguageInfo.getJOSMLocaleCode(),
             "name",
@@ -165,7 +165,6 @@
         /**
          * The list of default name complement tags from which a label candidate is derived.
-         * @since 6541
-         */
-        public static final String[] DEFAULT_NAME_COMPLEMENT_TAGS = {
+         */
+        private static final String[] DEFAULT_NAME_COMPLEMENT_TAGS = {
             "capacity"
         };
Index: trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java	(revision 6623)
@@ -181,5 +181,5 @@
         }
 
-        private class CrossingFinder extends AbstractFinder {
+        private final class CrossingFinder extends AbstractFinder {
             private CrossingFinder(Environment e) {
                 super(e);
@@ -197,5 +197,5 @@
         }
 
-        private class ContainsFinder extends AbstractFinder {
+        private final class ContainsFinder extends AbstractFinder {
             private ContainsFinder(Environment e) {
                 super(e);
Index: trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginPreference.java	(revision 6623)
@@ -13,4 +13,5 @@
 import java.awt.event.ComponentAdapter;
 import java.awt.event.ComponentEvent;
+import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -138,5 +139,6 @@
         gc.gridx = 1;
         gc.weightx = 1.0;
-        pnl.add(tfFilter = new JosmTextField(), gc);
+        tfFilter = new JosmTextField();
+        pnl.add(tfFilter, gc);
         tfFilter.setToolTipText(tr("Enter a search expression"));
         SelectAllOnFocusGainedDecorator.decorate(tfFilter);
@@ -158,5 +160,6 @@
         pnl.add(buildSearchFieldPanel(), BorderLayout.NORTH);
         model  = new PluginPreferencesModel();
-        spPluginPreferences = new JScrollPane(pnlPluginPreferences = new PluginListPanel(model));
+        pnlPluginPreferences = new PluginListPanel(model);
+        spPluginPreferences = new JScrollPane(pnlPluginPreferences);
         spPluginPreferences.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
         spPluginPreferences.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
@@ -181,6 +184,7 @@
     protected JTabbedPane buildContentPane() {
         JTabbedPane pane = getTabPane();
+        pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel();
         pane.addTab(tr("Plugins"), buildPluginListPanel());
-        pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy = new PluginUpdatePolicyPanel());
+        pane.addTab(tr("Plugin update policy"), pnlPluginUpdatePolicy);
         return pane;
     }
@@ -363,6 +367,8 @@
                     }
                 });
-            } catch (Exception e) {
-                e.printStackTrace();
+            } catch (InterruptedException e) {
+                Main.error(e);
+            } catch (InvocationTargetException e) {
+                Main.error(e);
             }
         }
@@ -482,5 +488,5 @@
         private DefaultListModel model;
 
-        protected void build() {
+        protected final void build() {
             setLayout(new GridBagLayout());
             add(new JLabel(tr("Add JOSM Plugin description URL.")), GBC.eol());
Index: trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreference.java	(revision 6623)
@@ -79,5 +79,6 @@
         remote.add(portLabel, GBC.eol().insets(5, 5, 0, 10).fill(GBC.HORIZONTAL));
 
-        remote.add(enableRemoteControl = new JCheckBox(tr("Enable remote control"), RemoteControl.PROP_REMOTECONTROL_ENABLED.get()), GBC.eol());
+        enableRemoteControl = new JCheckBox(tr("Enable remote control"), RemoteControl.PROP_REMOTECONTROL_ENABLED.get());
+        remote.add(enableRemoteControl, GBC.eol());
 
         final JPanel wrapper = new JPanel();
@@ -88,7 +89,6 @@
 
         wrapper.add(new JLabel(tr("Permitted actions:")), GBC.eol());
-        int INDENT = 15;
         for (JCheckBox p : prefs.values()) {
-            wrapper.add(p, GBC.eol().insets(INDENT, 5, 0, 0).fill(GBC.HORIZONTAL));
+            wrapper.add(p, GBC.eol().insets(15, 5, 0, 0).fill(GBC.HORIZONTAL));
         }
 
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreference.java	(revision 6623)
@@ -14,5 +14,5 @@
  * @since 6523
  */
-public class AuthenticationPreference implements SubPreferenceSetting {
+public final class AuthenticationPreference implements SubPreferenceSetting {
 
     /**
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/AuthenticationPreferencesPanel.java	(revision 6623)
@@ -113,5 +113,5 @@
      * Initializes the panel from preferences
      */
-    public void initFromPreferences() {
+    public final void initFromPreferences() {
         String authMethod = Main.pref.get("osm-server.auth-method", "basic");
         if (authMethod.equals("basic")) {
@@ -131,5 +131,5 @@
      * Saves the current values to preferences
      */
-    public void saveToPreferences() {
+    public final void saveToPreferences() {
         // save the authentication method
         String authMethod;
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/ProxyPreference.java	(revision 6623)
@@ -17,5 +17,5 @@
  * @since 6523
  */
-public class ProxyPreference implements SubPreferenceSetting {
+public final class ProxyPreference implements SubPreferenceSetting {
 
     /**
Index: trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/gui/preferences/server/ServerAccessPreference.java	(revision 6623)
@@ -80,5 +80,6 @@
         gc.weightx = 1.0;
         gc.insets = new Insets(0,0,0,0);
-        pnl.add(pnlApiUrlPreferences = new OsmApiUrlInputPanel(), gc);
+        pnlApiUrlPreferences = new OsmApiUrlInputPanel();
+        pnl.add(pnlApiUrlPreferences, gc);
 
         // the remaining access properties
Index: trunk/src/org/openstreetmap/josm/tools/Utils.java
===================================================================
--- trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6622)
+++ trunk/src/org/openstreetmap/josm/tools/Utils.java	(revision 6623)
@@ -887,9 +887,8 @@
      *  a subclass of <code>klass</code>. The casted value otherwise.
      */
+    @SuppressWarnings("unchecked")
     public static <T> T cast(Object o, Class<T> klass) {
         if (klass.isInstance(o)) {
-            @SuppressWarnings("unchecked")
-            T ret = (T) o;
-            return ret;
+            return (T) o;
         }
         return null;
