Index: /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 13838)
+++ /trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java	(revision 13839)
@@ -177,14 +177,16 @@
             formats.setToolTipText(tr("Select image format for WMS layer"));
 
-            if (!GraphicsEnvironment.isHeadless() &&
-                1 != new ExtendedDialog(Main.parent, tr("Select WMS layers"), tr("Add layers"), tr("Cancel")) { {
-                    final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
-                    scrollPane.setPreferredSize(new Dimension(400, 400));
-                    final JPanel panel = new JPanel(new GridBagLayout());
-                    panel.add(scrollPane, GBC.eol().fill());
-                    panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
-                    setContent(panel);
-            } }.showDialog().getValue()) {
-                return null;
+            if (!GraphicsEnvironment.isHeadless()) {
+                ExtendedDialog dialog = new ExtendedDialog(Main.parent, tr("Select WMS layers"), tr("Add layers"), tr("Cancel"));
+                final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree());
+                scrollPane.setPreferredSize(new Dimension(400, 400));
+                final JPanel panel = new JPanel(new GridBagLayout());
+                panel.add(scrollPane, GBC.eol().fill());
+                panel.add(formats, GBC.eol().fill(GBC.HORIZONTAL));
+                dialog.setContent(panel);
+
+                if (dialog.showDialog().getValue() != 1) {
+                    return null;
+                }
             }
 
Index: /trunk/src/org/openstreetmap/josm/data/imagery/WMTSCapabilities.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/imagery/WMTSCapabilities.java	(revision 13838)
+++ /trunk/src/org/openstreetmap/josm/data/imagery/WMTSCapabilities.java	(revision 13839)
@@ -19,4 +19,5 @@
 
     /**
+     * Constructor for the class
      *
      * @param baseUrl of this service
@@ -29,5 +30,5 @@
 
     /**
-     *
+     * Adds layers to this WMTS service response
      * @param layers layers to add to this document
      */
@@ -37,5 +38,5 @@
 
     /**
-     *
+     * Layers of this WMTS service
      * @return layers defined by this service
      */
@@ -45,5 +46,5 @@
 
     /**
-     *
+     * base URL of this WMTS service
      * @return base url for this service
      */
@@ -53,5 +54,5 @@
 
     /**
-     *
+     * TransferMode for this service
      * @return transfer mode (KVP or RESTful) for this service
      */
Index: /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 13838)
+++ /trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java	(revision 13839)
@@ -1358,22 +1358,23 @@
                     if (info == null) {
                         List<Tile> allTiles = this.allExistingTiles();
-                        info = new TileSetInfo();
-                        info.hasLoadingTiles = allTiles.size() < this.size();
-                        info.hasAllLoadedTiles = true;
+                        TileSetInfo newInfo = new TileSetInfo();
+                        newInfo.hasLoadingTiles = allTiles.size() < this.size();
+                        newInfo.hasAllLoadedTiles = true;
                         for (Tile t : allTiles) {
                             if ("no-tile".equals(t.getValue("tile-info"))) {
-                                info.hasOverzoomedTiles = true;
+                                newInfo.hasOverzoomedTiles = true;
                             }
                             if (t.isLoaded()) {
                                 if (!t.hasError()) {
-                                    info.hasVisibleTiles = true;
+                                    newInfo.hasVisibleTiles = true;
                                 }
                             } else {
-                                info.hasAllLoadedTiles = false;
+                                newInfo.hasAllLoadedTiles = false;
                                 if (t.isLoading()) {
-                                    info.hasLoadingTiles = true;
+                                    newInfo.hasLoadingTiles = true;
                                 }
                             }
                         }
+                        info = newInfo;
                     }
                 }
