Index: applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java
===================================================================
--- applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java	(revision 30709)
+++ applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java	(revision 30710)
@@ -96,4 +96,9 @@
         fixed.add(coor);
     }
+
+    public Set<LatLon> getFixedPoints() {
+        return fixed;
+    }
+    
     void addLast(LatLon coor) {
         if (closedFlag && lastIdx>points.size()-1) return;
Index: applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java
===================================================================
--- applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java	(revision 30709)
+++ applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java	(revision 30710)
@@ -8,6 +8,4 @@
 import java.text.ParseException;
 import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
 
 import javax.swing.AbstractAction;
@@ -30,28 +28,28 @@
 public class FastDrawConfigDialog extends ExtendedDialog {
 
+    private final JLabel label1=new JLabel(tr("Epsilon multiplier"));
+    private final JLabel label2=new JLabel(tr("Starting Epsilon"));
+    private final JLabel label3=new JLabel(tr("Max points count per 1 km"));
+    private final JLabel label4=new JLabel(/* I18n: Combobox to select what a press to return key does */ tr("Enter key mode"));
+    private final JLabel label5=new JLabel(tr("Auto add tags"));
+    private final JFormattedTextField text1=new JFormattedTextField(NumberFormat.getInstance());
+    private final JFormattedTextField text2=new  JFormattedTextField(NumberFormat.getInstance());
+    private final JFormattedTextField text3=new  JFormattedTextField(NumberFormat.getInstance());
+    private final JComboBox<String> combo1=new JComboBox<>(new String[]{tr("Autosimplify"),
+        tr("Simplify with initial epsilon"),tr("Save as is")});
+    private final JCheckBox snapCb=new JCheckBox(tr("Snap to nodes"));
+    private final JCheckBox fixedClickCb = new JCheckBox(tr("Add fixed points on click"));
+    private final JCheckBox fixedSpaceCb = new JCheckBox(tr("Add fixed points on spacebar"));
+    private final JCheckBox drawClosedCb = new JCheckBox(tr("Draw closed polygons only"));
+    private final HistoryComboBox addTags = new HistoryComboBox();
+    private final FDSettings settings;
+
     public FastDrawConfigDialog(FDSettings settings) {
         super(Main.parent,tr("FastDraw configuration"),new String[] {tr("Ok"), tr("Cancel")});
+        this.settings = settings;
+        
         JPanel all = new JPanel();
         GridBagLayout layout = new GridBagLayout();
         all.setLayout(layout);
-        
-        JLabel label1=new JLabel(tr("Epsilon multiplier"));
-        JLabel label2=new JLabel(tr("Starting Epsilon"));
-        JLabel label3=new JLabel(tr("Max points count per 1 km"));
-        JLabel label4=new JLabel(/* I18n: Combobox to select what a press to return key does */ tr("Enter key mode"));
-        JLabel label5=new JLabel(tr("Auto add tags"));
-        JFormattedTextField text1=new JFormattedTextField(NumberFormat.getInstance());
-        JFormattedTextField text2=new  JFormattedTextField(NumberFormat.getInstance());
-        JFormattedTextField text3=new  JFormattedTextField(NumberFormat.getInstance());
-//        JComboBox combo1=new JComboBox(new String[]{tr("Autosimplify and wait"),
-//            tr("Autosimplify and save"),tr("Simplify and wait"),tr("Simplify and save"),
-//            tr("Save as is")});
-        JComboBox<String> combo1=new JComboBox<>(new String[]{tr("Autosimplify"),
-            tr("Simplify with initial epsilon"),tr("Save as is")});
-        JCheckBox snapCb=new JCheckBox(tr("Snap to nodes"));
-        JCheckBox fixedClickCb = new JCheckBox(tr("Add fixed points on click"));
-        JCheckBox fixedSpaceCb = new JCheckBox(tr("Add fixed points on spacebar"));
-        JCheckBox drawClosedCb = new JCheckBox(tr("Draw closed polygons only"));
-        final HistoryComboBox addTags = new HistoryComboBox();
         JButton pasteButton = new JButton(new AbstractAction(tr("Paste"), ImageProvider.get("apply")) {
             @Override
@@ -64,4 +62,5 @@
         });
         pasteButton.setToolTipText(tr("Try copying tags from properties table"));
+        
         ArrayList<String> history = new ArrayList<>(Main.pref.getCollection("fastdraw.tags-history"));
         while (history.remove("")) { };
@@ -98,8 +97,4 @@
         combo1.setSelectedIndex(settings.simplifyMode);
         
-        ExtendedDialog dialog = new ExtendedDialog(Main.parent,
-                tr("FastDraw settings"),
-                new String[] {tr("Ok"), tr("Cancel")}
-        );
         setContent(all, false);
         setButtonIcons(new String[] {"ok.png", "cancel.png"});
@@ -110,21 +105,25 @@
         setDefaultButton(1);
         //configureContextsensitiveHelp("/Action/DownloadObject", true /* show help button */);
-        showDialog();
-        if (dialog.getValue() == 0) {
+    }
+
+    @Override
+    public ExtendedDialog showDialog() {
+        ExtendedDialog result = super.showDialog();
+        if (getValue() == 0) {
             try {
-            settings.epsilonMult=NumberFormat.getInstance().parse(text1.getText()).doubleValue();
-            settings.startingEps=NumberFormat.getInstance().parse(text2.getText()).doubleValue();
-            settings.maxPointsPerKm=NumberFormat.getInstance().parse(text3.getText()).doubleValue();
-            settings.snapNodes=snapCb.isSelected();
-            settings.fixedClick=fixedClickCb.isSelected();
-            settings.fixedSpacebar=fixedSpaceCb.isSelected();
-            settings.drawClosed=drawClosedCb.isSelected();
-            settings.simplifyMode=combo1.getSelectedIndex();
-            settings.autoTags=addTags.getText();
-            if (!settings.autoTags.isEmpty()) {
-                addTags.addCurrentItemToHistory();
-            }
-            Main.pref.putCollection("fastdraw.tags-history", addTags.getHistory());
-            settings.savePrefs();
+                settings.epsilonMult=NumberFormat.getInstance().parse(text1.getText()).doubleValue();
+                settings.startingEps=NumberFormat.getInstance().parse(text2.getText()).doubleValue();
+                settings.maxPointsPerKm=NumberFormat.getInstance().parse(text3.getText()).doubleValue();
+                settings.snapNodes=snapCb.isSelected();
+                settings.fixedClick=fixedClickCb.isSelected();
+                settings.fixedSpacebar=fixedSpaceCb.isSelected();
+                settings.drawClosed=drawClosedCb.isSelected();
+                settings.simplifyMode=combo1.getSelectedIndex();
+                settings.autoTags=addTags.getText();
+                if (!settings.autoTags.isEmpty()) {
+                    addTags.addCurrentItemToHistory();
+                }
+                Main.pref.putCollection("fastdraw.tags-history", addTags.getHistory());
+                settings.savePrefs();
             } catch (ParseException e) {
               JOptionPane.showMessageDialog(Main.parent,
@@ -132,5 +131,6 @@
             }
         }
-            
+        return result;
+        
     }
     
Index: applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
===================================================================
--- applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java	(revision 30709)
+++ applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java	(revision 30710)
@@ -7,18 +7,19 @@
 package org.openstreetmap.josm.plugins.fastdraw;
 
-import java.awt.AWTEvent;
 import java.awt.Color;
-import java.awt.Component;
 import java.awt.Cursor;
 import java.awt.Graphics2D;
-import java.awt.KeyboardFocusManager;
 import java.awt.Point;
-import java.awt.Toolkit;
-import java.awt.event.*;
-import java.util.*;
-import javax.swing.JFrame;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
 
 import org.openstreetmap.josm.Main;
@@ -31,7 +32,7 @@
 import org.openstreetmap.josm.data.Bounds;
 import org.openstreetmap.josm.data.coor.LatLon;
-import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
+import org.openstreetmap.josm.data.osm.Tag;
 import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
@@ -41,12 +42,13 @@
 import org.openstreetmap.josm.gui.layer.MapViewPaintable;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+import org.openstreetmap.josm.gui.util.KeyPressReleaseListener;
+import org.openstreetmap.josm.gui.util.ModifierListener;
+import static org.openstreetmap.josm.tools.I18n.tr;
 import org.openstreetmap.josm.tools.ImageProvider;
 import org.openstreetmap.josm.tools.Shortcut;
 import org.openstreetmap.josm.tools.TextTagParser;
 
-import static org.openstreetmap.josm.tools.I18n.tr;
-
 class FastDrawingMode extends MapMode implements MapViewPaintable,
-        AWTEventListener {
+        KeyPressReleaseListener, ModifierListener {
     private static final String SIMPLIFYMODE_MESSAGE=
             tr("Q=Options, Enter=save, Ctrl-Enter=save with tags, Up/Down=tune");
@@ -56,10 +58,8 @@
     private FDSettings settings;
 
-    private DrawnPolyLine line;
+    private final DrawnPolyLine line;
     private MapView mv;
     private String statusText;
     private boolean drawing;
-    private boolean ctrl;
-    private boolean shift;
     private double eps;
     private final Cursor cursorDraw;
@@ -70,20 +70,12 @@
     private final Cursor cursorDrawing;
     private boolean nearSomeNode;
-    private LatLon highlighted;
-    private int nearestIdx;
+    private LatLon highlightedFragmentStart;
+    private int nearestPointIndex;
     private int dragNode=-1;
     private SequenceCommand delCmd;
     private List<Node> oldNodes;
     
-    private final TreeSet<Integer> set = new TreeSet<Integer>();
-    private Timer timer;
-  
-    private KeyEvent releaseEvent;
     private boolean lineWasSaved;
     private boolean deltaChanged;
-    /**
-     * used for skipping keyboard AWTTevents while dialogs are active
-     */
-    private boolean listenKeys = false;
     
     FastDrawingMode(MapFrame mapFrame) {
@@ -121,23 +113,7 @@
         Main.map.mapView.addMouseMotionListener(this);
         Main.map.mapView.addTemporaryLayer(this);
-
-        //tryToLoadWay();
-        
-        timer = new Timer(0, new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent ae) {
-                 timer.stop();
-                 if (set.remove(releaseEvent.getKeyCode())) {
-                  doKeyReleaseEvent(releaseEvent);
-                 }
-            }
-        });
-        
-        listenKeys = true;
-        try {
-            Toolkit.getDefaultToolkit().addAWTEventListener(this,
-                    AWTEvent.KEY_EVENT_MASK);
-        } catch (SecurityException ex) {
-        }
+        
+        Main.map.keyDetector.addKeyListener(this);
+        Main.map.keyDetector.addModifierListener(this);
     }
 
@@ -151,9 +127,8 @@
 
         Main.map.mapView.removeTemporaryLayer(this);
-
-        try {
-            Toolkit.getDefaultToolkit().removeAWTEventListener(this);
-        } catch (SecurityException ex) {
-        }
+        
+        Main.map.keyDetector.removeKeyListener(this);
+        Main.map.keyDetector.removeModifierListener(this);
+
         settings.savePrefs();
         Main.map.mapView.setCursor(cursorDraw);
@@ -171,6 +146,7 @@
     }
 
+    private final ArrayList<Point> fixedPoints =new ArrayList<>(3000); // tamporyrary storate for paint
+    
     //////////    Event listener methods
-
     @Override
     public void paint(Graphics2D g, MapView mv, Bounds bbox) {
@@ -198,25 +174,25 @@
         dp=line.wasSimplified() ? settings.bigDotSize : settings.dotSize;  rp=dp/2;
         if (pts.size() > 1) {
-        Iterator<LatLon> it1,it2;
-        it1=pts.listIterator(0);
-        it2=pts.listIterator(1);
-        for (int i = 0; i < pts.size() - 1; i++) {
+            Iterator<LatLon> it1,it2;
+            it1=pts.listIterator(0);
+            it2=pts.listIterator(1);
+            fixedPoints.clear();
+            for (int i = 0; i < pts.size() - 1; i++) {
                 pp1 = it1.next();
                 p1 = line.getPoint(pp1);
                 pp2 = it2.next();
                 p2 = line.getPoint(pp2);
-                if (shift && highlighted==pp1 && nearestIdx<0) {lineColor=settings.COLOR_SELECTEDFRAGMENT;}
+                if (shift && highlightedFragmentStart==pp1 && nearestPointIndex<0) {lineColor=settings.COLOR_SELECTEDFRAGMENT;}
                 if (!shift && line.isLastPoint(i)) { lineColor=settings.COLOR_EDITEDFRAGMENT; }
                 g.setColor(lineColor);
                 g.drawLine(p1.x, p1.y, p2.x, p2.y);
-                if (line.isFixed(pp2)) {
+                if (line.isFixed(pp2)) { 
                     lineColor=initLineColor;
-                    g.setColor(settings.COLOR_FIXED);
-                    g.fillOval(p2.x - bigDotSize/2, p2.y - bigDotSize/2, bigDotSize, bigDotSize);
+                    fixedPoints.add(p2);
                 } else {
                     g.fillRect(p2.x - rp, p2.y - rp, dp, dp);
                 }
                 if (!drawing) {
-                    if (!line.wasSimplified() && nearestIdx==i+1 ) {
+                    if (!line.wasSimplified() && nearestPointIndex==i+1 ) {
                     if (shift) {
                         // highlight node to delete
@@ -236,7 +212,11 @@
                 }
             }
+            g.setColor(settings.COLOR_FIXED);
+            for (Point p: fixedPoints) {
+                g.fillOval(p.x - bigDotSize/2, p.y - bigDotSize/2, bigDotSize, bigDotSize);
+            }
         }
         if (settings.drawLastSegment && !drawing && dragNode<0  && !shift && 
-                nearestIdx<=0 && !line.wasSimplified()) {
+                nearestPointIndex<=0 && !line.wasSimplified()) {
             // draw line to current point
             g.setColor(lineColor);
@@ -253,39 +233,4 @@
     }
 
-    @Override
-    public void eventDispatched(AWTEvent event) {
-        if (!listenKeys || Main.map == null || Main.map.mapView == null
-                || !Main.map.mapView.isActiveLayerDrawable()) {
-            return;
-        }
-        updateKeyModifiers((InputEvent) event);
-        if (event instanceof KeyEvent) {
-        KeyEvent e=(KeyEvent) event;
-        
-        if (event.getID() == KeyEvent.KEY_PRESSED) {
-             if (timer.isRunning()) {
-                  timer.stop();
-                } else {
-                  set.add((e.getKeyCode()));
-                }
-            // check if key press is done in main window, not in dialogs
-            Component focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
-            if (SwingUtilities.getWindowAncestor(focused) instanceof JFrame) {
-                doKeyEvent((KeyEvent) event);
-            }
-        }
-        if (event.getID() == KeyEvent.KEY_RELEASED) {
-            if (timer.isRunning()) {
-              timer.stop();
-               if (set.remove(e.getKeyCode())) {
-                  doKeyReleaseEvent(e);
-               }
-            } else {
-              releaseEvent = e;
-              timer.restart();
-            }
-        }
-        }
-    }
 
     @Override
@@ -293,4 +238,5 @@
         if (!isEnabled()) return;
         if (e.getButton() != MouseEvent.BUTTON1) return;
+        updateKeyModifiers(e);
         
         requestFocusInMapView();
@@ -309,5 +255,5 @@
         if (ctrl && shift) {newDrawing();repaint();return;}
         if (!ctrl && shift) {
-            if (idx>=0) {line.deleteNode(idx); nearestIdx=-1;}
+            if (idx>=0) {line.deleteNode(idx); nearestPointIndex=-1;}
             else line.tryToDeleteSegment(e.getPoint());
             return;
@@ -364,5 +310,5 @@
         dragNode = -1;
         drawing = false;
-        highlighted=null;
+        highlightedFragmentStart=null;
         if (!line.isClosed()) setStatusLine(DRAWINGMODE_MESSAGE);
         updateCursor();
@@ -378,13 +324,24 @@
     public void mouseMoved(MouseEvent e) {
         if (!isEnabled()) return;
+        updateKeyModifiers(e);
         deltaChanged=false;
         Node nd1 = getNearestNode(e.getPoint(), settings.maxDist);
         boolean nearSomeNode2=nd1!=null;
         boolean needRepaint=false;
-        if (nearSomeNode!=nearSomeNode2) {nearSomeNode=nearSomeNode2;updateCursor();needRepaint=true;}
+        if (nearSomeNode!=nearSomeNode2) {
+            nearSomeNode=nearSomeNode2;
+            updateCursor();
+            needRepaint=true;
+        }
 
         int nearestIdx2=line.findClosestPoint(e.getPoint(),settings.maxDist);
-        if (nearestIdx != nearestIdx2) {nearestIdx=nearestIdx2; updateCursor();needRepaint=true;}
-        if (settings.drawLastSegment) needRepaint=true;
+        if (nearestPointIndex != nearestIdx2) {
+            nearestPointIndex=nearestIdx2;
+            updateCursor();
+            needRepaint=true;
+        }
+        if (settings.drawLastSegment) {
+            needRepaint=true;
+        }
         
         if (!drawing) {
@@ -395,9 +352,14 @@
             }
 
-            if (shift) {
+            if (shift && nearestPointIndex == -1) {
                 // find line fragment to highlight
                 LatLon h2=line.findBigSegment(e.getPoint());
-                if (highlighted!=h2) { highlighted=h2; repaint(); }
-            } else if (needRepaint) {
+                if (highlightedFragmentStart!=h2) {
+                    highlightedFragmentStart=h2;
+                    needRepaint=true;
+                }
+            }
+            
+            if (needRepaint) {
                 repaint();
             }
@@ -407,5 +369,5 @@
 
         // do not draw points close to existing points - we do not want self-intersections
-        if (nearestIdx>=0) { return; }
+        if (nearestPointIndex>=0) { return; }
 
         Point lastP = line.getLastPoint(); // last point of line fragment being edited
@@ -428,5 +390,6 @@
     }
 
-    private void doKeyEvent(KeyEvent e) {
+    @Override
+    public void doKeyPressed(KeyEvent e) {
         if (getShortcut().isEvent(e)) { // repeated press
             tryToLoadWay();
@@ -486,6 +449,4 @@
             if (lastPoint==null || lastPoint.equals(line.getLastPoint())) {
                  if (line.getPoints().size()>5) {
-                    // no key events while the dialog is active!
-                    listenKeys = false;
                     boolean answer = ConditionalOptionPaneUtil.showConfirmationDialog(
                        "delete_drawn_line", Main.parent,
@@ -493,5 +454,4 @@
                             line.getPoints().size()), tr("Delete confirmation"),
                        JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_OPTION );
-                    listenKeys = true;
                     if(!answer) break;
                 }
@@ -503,25 +463,18 @@
         
         case KeyEvent.VK_I:
-           listenKeys = false;
            JOptionPane.showMessageDialog(Main.parent,
-                        tr("{0} m - length of the line\n{1} nodes\n{2} points per km (maximum)\n{3} points per km (average)",
-                        line.getLength(),line.getPoints().size(),line.getNodesPerKm(settings.pkmBlockSize),
-                        line.getNodesPerKm(1000000)),
-                        tr("Line information"),JOptionPane.INFORMATION_MESSAGE);
-           listenKeys = true;
+                tr("{0} m - length of the line\n{1} nodes\n{2} points per km (maximum)\n{3} points per km (average)",
+                line.getLength(),line.getPoints().size(),line.getNodesPerKm(settings.pkmBlockSize),
+                line.getNodesPerKm(1000000)),
+                tr("Line information"),JOptionPane.INFORMATION_MESSAGE);
         break;            
         case KeyEvent.VK_Q:
             // less details
             e.consume();
-            try {
-                listenKeys = false;
-                new FastDrawConfigDialog(settings);
-                if (line.wasSimplified()) {
+            new FastDrawConfigDialog(settings).showDialog();
+            if (line.wasSimplified()) {
                 eps = line.autoSimplify(settings.startingEps, settings.epsilonMult, settings.pkmBlockSize,settings.maxPointsPerKm);
                 showSimplifyHint();
-                }
-                //System.out.println("final eps="+eps);
-                listenKeys = true;
-            } catch (SecurityException ex) {  }
+            }
             repaint();
         break;
@@ -536,18 +489,17 @@
     }
     
-    private void doKeyReleaseEvent(KeyEvent keyEvent) {
-            //System.out.println("released "+keyEvent);
-            if (keyEvent.getKeyCode()==KeyEvent.VK_SPACE) stopDrawing();
-            updateCursor();
-    }
-    /**
-     * Updates shift and ctrl key states
-     */
-    protected void updateKeyModifiers(InputEvent e) {
-        ctrl = (e.getModifiers() & ActionEvent.CTRL_MASK) != 0;
-        shift = (e.getModifiers() & ActionEvent.SHIFT_MASK) != 0;
+    @Override
+    public void doKeyReleased(KeyEvent keyEvent) {
+        //System.out.println("released "+keyEvent);
+        if (keyEvent.getKeyCode()==KeyEvent.VK_SPACE) stopDrawing();
         updateCursor();
     }
 
+    @Override
+    public void modifiersChanged(int modifiers) {
+        updateKeyModifiers(modifiers);
+        updateCursor();
+    }
+    
     @Override
     protected void updateStatusLine() {
@@ -572,5 +524,5 @@
         if (line.isClosed() && n==3) pts.remove(2); // two-point way can not be closed
 
-        Collection<Command> cmds = new LinkedList<Command>();
+        Collection<Command> cmds = new LinkedList<>();
         int i = 0;
         Way w = new Way();
@@ -579,12 +531,12 @@
 
         for (LatLon p : pts) {
-            Node nd=null;
- 
-            nd = Main.map.mapView.getNearestNode(line.getPoint(p), OsmPrimitive.isSelectablePredicate);
+            Node nd = Main.map.mapView.getNearestNode(line.getPoint(p), OsmPrimitive.isSelectablePredicate);
             // there may be a node with the same coords!
             
             if (nd!=null && p.greatCircleDistance(nd.getCoor())>0.01) nd=null;
             if (nd==null) {
-                if (i>0 && p.equals(first)) nd=firstNode; else {
+                if (i>0 && p.equals(first)) {
+                    nd=firstNode;
+                } else {
                     nd = new Node(p);
                     cmds.add(new AddCommand(nd));
@@ -596,5 +548,7 @@
                 return;
             }
-            if (i==0) firstNode=nd;
+            if (i==0) {
+                firstNode=nd;
+            }
             w.addNode(nd);
             i++;
@@ -602,5 +556,5 @@
         if (ctrl) {
             // paste tags - from ctrl-shift-v
-            Set <OsmPrimitive> ts = new HashSet<OsmPrimitive>();
+            Set <OsmPrimitive> ts = new HashSet<>();
             ts.add(w);
             TagPaster tp = new TagPaster(Main.pasteBuffer.getDirectlyAdded(), ts);
@@ -684,5 +638,5 @@
 
     private void loadFromWay(Way w) {
-        Collection<Command> cmds = new LinkedList<Command>();
+        Collection<Command> cmds = new LinkedList<>();
         
         Object[] nodes = w.getNodes().toArray();
@@ -695,5 +649,5 @@
         if (w.isClosed()) line.closeLine();
         oldNodes = w.getNodes();
-        List <OsmPrimitive> wl = new ArrayList<OsmPrimitive>(); wl.add(w);
+        List <OsmPrimitive> wl = new ArrayList<>(); wl.add(w);
         
         Command c = DeleteCommand.delete(getEditLayer(), wl, false);
@@ -716,5 +670,5 @@
     private void updateCursor() {
         if (shift) Main.map.mapView.setCursor(cursorShift); else
-        if (line.isClosed() || (nearestIdx==0)) Main.map.mapView.setCursor(cursorReady); else
+        if (line.isClosed() || (nearestPointIndex==0)) Main.map.mapView.setCursor(cursorReady); else
         if (ctrl) Main.map.mapView.setCursor(cursorCtrl); else
         if (nearSomeNode && settings.snapNodes) Main.map.mapView.setCursor(cursorCtrl); else
