Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPlugin.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPlugin.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPlugin.java	(revision 34539)
@@ -8,46 +8,46 @@
 
 /**
- *
+ * OSM rec plugin
  * @author imis-nkarag
  */
 public class OSMRecPlugin extends Plugin {
 
-	private final MenuExportAction menuExportAction;
-	private static MapFrame mapFrame;
-	public OSMRecPlugin plugin;
+    private final MenuExportAction menuExportAction;
+    private static MapFrame mapFrame;
+    public OSMRecPlugin plugin;
 
-	public OSMRecPlugin(PluginInformation info) { // NO_UCD (unused code)
-		super(info);
-		menuExportAction = new MenuExportAction();
-		MainApplication.getMenu().toolsMenu.add(menuExportAction);
-	}
+    public OSMRecPlugin(PluginInformation info) { // NO_UCD (unused code)
+        super(info);
+        menuExportAction = new MenuExportAction();
+        MainApplication.getMenu().toolsMenu.add(menuExportAction);
+    }
 
-	@Override
-	public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
-		if (oldFrame == null && newFrame != null) { // map frame added
-			setCurrentMapFrame(newFrame);
-			setState(this);
-		}
-	}
+    @Override
+    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
+        if (oldFrame == null && newFrame != null) { // map frame added
+            setCurrentMapFrame(newFrame);
+            setState(this);
+        }
+    }
 
-	private void setCurrentMapFrame(MapFrame newFrame) {
-		OSMRecPlugin.mapFrame = newFrame;
-	}
+    private void setCurrentMapFrame(MapFrame newFrame) {
+        OSMRecPlugin.mapFrame = newFrame;
+    }
 
-	public static MapFrame getCurrentMapFrame() {
-		return mapFrame;
-	}
+    public static MapFrame getCurrentMapFrame() {
+        return mapFrame;
+    }
 
-	private void setState(OSMRecPlugin plugin) {
-		this.plugin = plugin;
-	}
+    private void setState(OSMRecPlugin plugin) {
+        this.plugin = plugin;
+    }
 
-	public OSMRecPlugin getState() {
-		return plugin;
-	}
+    public OSMRecPlugin getState() {
+        return plugin;
+    }
 
-	//    @Override
-	//    public PreferenceSetting getPreferenceSetting() {
-	//        return new PreferenceEditor();
-	//    }
+    //    @Override
+    //    public PreferenceSetting getPreferenceSetting() {
+    //        return new PreferenceEditor();
+    //    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPluginHelper.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPluginHelper.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecPluginHelper.java	(revision 34539)
@@ -90,8 +90,9 @@
 import org.opengis.referencing.operation.MathTransform;
 import org.opengis.referencing.operation.TransformException;
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
 import org.openstreetmap.josm.command.ChangePropertyCommand;
+import org.openstreetmap.josm.data.UndoRedoHandler;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.OsmDataManager;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Tag;
@@ -122,4 +123,5 @@
 import org.openstreetmap.josm.plugins.osmrec.parsers.TextualStatistics;
 import org.openstreetmap.josm.plugins.osmrec.personalization.UserDataExtractAndTrainWorker;
+import org.openstreetmap.josm.spi.preferences.Config;
 import org.openstreetmap.josm.tools.GBC;
 import org.openstreetmap.josm.tools.Logging;
@@ -165,5 +167,4 @@
     private String customSVMModelPath;
     private final String combinedModelClasses;
-    private final String combinedModel;
 
     // Selection that we are editing by using both dialogs
@@ -195,5 +196,5 @@
     OSMRecPluginHelper(DefaultTableModel propertyData, Map<String, Map<String, Integer>> valueCount) {
         this.tagData = propertyData;
-        fileHistory = Main.pref.getList("file-open.history");
+        fileHistory = Config.getPref().getList("file-open.history");
         if (!fileHistory.isEmpty()) {
             MAIN_PATH = (String) fileHistory.toArray()[0];
@@ -204,5 +205,4 @@
         TEXTUAL_LIST_PATH = MODEL_PATH + "/textualList.txt";
         combinedModelClasses = MODEL_PATH + "/combinedModel.1";
-        combinedModel = MODEL_PATH + "/combinedModel.0";
         bestModelPath = MODEL_PATH + "/best_model";
         customSVMModelPath = bestModelPath;
@@ -221,5 +221,5 @@
     public void addTag() {
         changedKey = null;
-        sel = Main.main.getInProgressSelection();
+        sel = OsmDataManager.getInstance().getInProgressSelection();
         if (sel == null || sel.isEmpty()) return;
 
@@ -243,8 +243,7 @@
     public void editTag(final int row, boolean focusOnKey) {
         changedKey = null;
-        sel = Main.main.getInProgressSelection();
+        sel = OsmDataManager.getInstance().getInProgressSelection();
         String key = "";
 
-        @SuppressWarnings("unchecked")
         Map<String, Integer> dumPar = new HashMap<>();
         dumPar.put(" ", -1);
@@ -282,5 +281,5 @@
         if (PROPERTY_REMEMBER_TAGS.get() && recentTags.isEmpty()) {
             recentTags.clear();
-            Collection<String> c = Main.pref.getList("properties.recent-tags");
+            Collection<String> c = Config.getPref().getList("properties.recent-tags");
             Iterator<String> it = c.iterator();
             String key, value;
@@ -303,5 +302,5 @@
                 c.add(t.getValue());
             }
-            Main.pref.putList("properties.recent-tags", c);
+            Config.getPref().putList("properties.recent-tags", c);
         }
     }
@@ -315,5 +314,5 @@
     private boolean warnOverwriteKey(String action, String togglePref) {
         ExtendedDialog ed = new ExtendedDialog(
-                Main.parent,
+                MainApplication.getMainFrame(),
                 tr("Overwrite key"),
                 new String[]{tr("Replace"), tr("Cancel")});
@@ -367,5 +366,5 @@
 
         private TrainingDialog(String key, int row, Map<String, Integer> map, final boolean initialFocusOnKey) {
-            super(Main.parent, tr("Training process configuration"), new String[] {tr("Cancel")});
+            super(MainApplication.getMainFrame(), tr("Training process configuration"), new String[] {tr("Cancel")});
 
             setButtonIcons(new String[] {"ok", "cancel"});
@@ -424,5 +423,5 @@
             daysField.setColumns(FIELD_COLUMNS);
 
-            Collection<String> fileHistory = Main.pref.getList("file-open.history");
+            Collection<String> fileHistory = Config.getPref().getList("file-open.history");
             if (!fileHistory.isEmpty()) {
                 inputFileField.setText(MAIN_PATH);
@@ -930,5 +929,5 @@
 
             setRememberWindowGeometry(getClass().getName() + ".geometry",
-                    WindowGeometry.centerInWindow(Main.parent, size));
+                    WindowGeometry.centerInWindow(MainApplication.getMainFrame(), size));
         }
 
@@ -1200,5 +1199,5 @@
             };
 
-            dlg = pane.createDialog(Main.parent, tr("Model Settings"));
+            dlg = pane.createDialog(MainApplication.getMainFrame(), tr("Model Settings"));
             dlg.setVisible(true);
         }
@@ -1430,5 +1429,5 @@
 
         AddTagsDialog() {
-            super(Main.parent, tr("Add value?"), new String[] {tr("OK"), tr("Cancel")});
+            super(MainApplication.getMainFrame(), tr("Add value?"), new String[] {tr("OK"), tr("Cancel")});
             setButtonIcons(new String[] {"ok", "cancel"});
             setCancelButton(2);
@@ -1831,10 +1830,10 @@
             AutoCompletionManager.rememberUserInput(key, value, false);
             commandCount++;
-            MainApplication.undoRedo.add(new ChangePropertyCommand(sel, key, value));
+            UndoRedoHandler.getInstance().add(new ChangePropertyCommand(sel, key, value));
             changedKey = key;
         }
 
         public void undoAllTagsAdding() {
-            MainApplication.undoRedo.undo(commandCount);
+            UndoRedoHandler.getInstance().undo(commandCount);
         }
 
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/OSMRecToggleDialog.java	(revision 34539)
@@ -31,9 +31,9 @@
 import javax.swing.table.TableModel;
 
-import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.JosmAction;
-import org.openstreetmap.josm.data.SelectionChangedListener;
+import org.openstreetmap.josm.data.osm.DataSelectionListener;
 import org.openstreetmap.josm.data.osm.DefaultNameFormatter;
 import org.openstreetmap.josm.data.osm.IRelation;
+import org.openstreetmap.josm.data.osm.OsmDataManager;
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Relation;
@@ -70,390 +70,388 @@
  */
 public class OSMRecToggleDialog extends ToggleDialog
-implements SelectionChangedListener, DataSetListenerAdapter.Listener {
-
-	/**
-	 * The tag data of selected objects.
-	 */
-	private final DefaultTableModel tagData = new ReadOnlyTableModel();
-
-	/**
-	 * The membership data of selected objects.
-	 */
-	private final DefaultTableModel membershipData = new ReadOnlyTableModel();
-
-	/**
-	 * The tags table.
-	 */
-	private final JTable tagTable = new JTable(tagData);
-
-	/**
-	 * The membership table.
-	 */
-	private final JTable membershipTable = new JTable(membershipData);
-
-	/** JPanel containing both previous tables */
-	private final JPanel bothTables = new JPanel();
-
-	private final transient Map<String, Map<String, Integer>> valueCount = new TreeMap<>();
-	/**
-	 * This sub-object is responsible for all adding and editing of tags
-	 */
-	private final transient OSMRecPluginHelper editHelper = new OSMRecPluginHelper(tagData, valueCount);
-
-	private final AddAction addAction = new AddAction();
-	private final EditActionTrain editAction = new EditActionTrain();
-	//    private final DeleteAction deleteAction = new DeleteAction();
-	//    private final JosmAction[] josmActions = new JosmAction[]{addAction, editAction, deleteAction};
-
-	/**
-	 * The Add button (needed to be able to disable it)
-	 */
-	private final SideButton btnAdd = new SideButton(addAction);
-	/**
-	 * The Edit button (needed to be able to disable it)
-	 */
-	private final SideButton btnEdit = new SideButton(editAction);
-
-	/**
-	 * Text to display when nothing selected.
-	 */
-	private final JLabel selectSth = new JLabel("<html><p>"
-			+ tr("Select objects or create new objects and get recommendation.") + "</p></html>");
-
-	// <editor-fold defaultstate="collapsed" desc="Dialog construction and helper methods">
-
-	/**
-	 * Create a new OSMRecToggleDialog
-	 */
-	public OSMRecToggleDialog() {
-		super(tr("Tags/Memberships"), "propertiesdialog", tr("Tags for selected objects."),
-				Shortcut.registerShortcut("subwindow:properties", tr("Toggle: {0}", tr("Tags/Memberships")), KeyEvent.VK_P,
-						Shortcut.ALT_SHIFT), 150, true);
-
-		System.out.println("cleaning test..");
-		bothTables.setLayout(new GridBagLayout());
-		bothTables.setVisible(false); //my
-		// Let the actions know when selection in the tables change
-		tagTable.getSelectionModel().addListSelectionListener(editAction);
-		membershipTable.getSelectionModel().addListSelectionListener(editAction);
-
-		JScrollPane scrollPane = (JScrollPane) createLayout(bothTables, true,
-				Arrays.asList(this.btnAdd, this.btnEdit));
-
-		MouseClickWatch mouseClickWatch = new MouseClickWatch();
-		tagTable.addMouseListener(mouseClickWatch);
-		membershipTable.addMouseListener(mouseClickWatch);
-		scrollPane.addMouseListener(mouseClickWatch);
-		editHelper.loadTagsIfNeeded();
-
-	}
-
-	/**
-	 * This simply fires up an {@link RelationEditor} for the relation shown; everything else
-	 * is the editor's business.
-	 *
-	 * @param row position
-	 */
-	private void editMembership(int row) {
-		Relation relation = (Relation) membershipData.getValueAt(row, 0);
-		MainApplication.getMap().relationListDialog.selectRelation(relation);
-	}
-
-	private int findRow(TableModel model, Object value) {
-		for (int i = 0; i < model.getRowCount(); i++) {
-			if (model.getValueAt(i, 0).equals(value))
-				return i;
-		}
-		return -1;
-	}
-
-	/**
-	 * Update selection status, call @{link #selectionChanged} function.
-	 */
-	private void updateSelection() {
-		// Parameter is ignored in this class
-		selectionChanged(null);
-	}
-
-	// </editor-fold>
-
-	// <editor-fold defaultstate="collapsed" desc="Event listeners methods">
-
-	@Override
-	public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) {
-		if (tagTable == null)
-			return; // selection changed may be received in base class constructor before init
-		if (tagTable.getCellEditor() != null) {
-			tagTable.getCellEditor().cancelCellEditing();
-		}
-
-		// 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();
-		}
-
-		String selectedTag;
-		Relation selectedRelation = null;
-		selectedTag = editHelper.getChangedKey(); // select last added or last edited key by default
-		if (selectedTag == null && tagTable.getSelectedRowCount() == 1) {
-			selectedTag = (String) tagData.getValueAt(tagTable.getSelectedRow(), 0);
-		}
-		if (membershipTable.getSelectedRowCount() == 1) {
-			selectedRelation = (Relation) membershipData.getValueAt(membershipTable.getSelectedRow(), 0);
-		}
-
-		// re-load tag data
-		tagData.setRowCount(0);
-
-		final Map<String, String> tags = new HashMap<>();
-		valueCount.clear();
-		for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) {
-			int count = 0;
-			for (Entry<String, Integer> e1 : e.getValue().entrySet()) {
-				count += e1.getValue();
-			}
-			if (count < newSel.size()) {
-				e.getValue().put("", newSel.size() - count);
-			}
-			tagData.addRow(new Object[]{e.getKey(), e.getValue()});
-			tags.put(e.getKey(), e.getValue().size() == 1
-					? e.getValue().keySet().iterator().next() : tr("<different>"));
-		}
-
-		membershipData.setRowCount(0);
-
-		Map<Relation, MemberInfo> roles = new HashMap<>();
-		for (OsmPrimitive primitive: newSel) {
-			for (OsmPrimitive ref: primitive.getReferrers(true)) {
-				if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {
-					Relation r = (Relation) ref;
-					MemberInfo mi = roles.get(r);
-					if (mi == null) {
-						mi = new MemberInfo(newSel);
-					}
-					roles.put(r, mi);
-					int i = 1;
-					for (RelationMember m : r.getMembers()) {
-						if (m.getMember() == primitive) {
-							mi.add(m, i);
-						}
-						++i;
-					}
-				}
-			}
-		}
-
-		List<Relation> sortedRelations = new ArrayList<>(roles.keySet());
-		Collections.sort(sortedRelations, new Comparator<Relation>() {
-			@Override public int compare(Relation o1, Relation o2) {
-				int comp = Boolean.valueOf(o1.isDisabledAndHidden()).compareTo(o2.isDisabledAndHidden());
-				return comp != 0 ? comp : DefaultNameFormatter.getInstance().getRelationComparator().compare(o1, o2);
-			} });
-
-		for (Relation r: sortedRelations) {
-			membershipData.addRow(new Object[]{r, roles.get(r)});
-		}
-
-		membershipTable.getTableHeader().setVisible(membershipData.getRowCount() > 0);
-		membershipTable.setVisible(membershipData.getRowCount() > 0);
-
-		boolean hasSelection = !newSel.isEmpty();
-		boolean hasTags = hasSelection && tagData.getRowCount() > 0;
-		boolean hasMemberships = hasSelection && membershipData.getRowCount() > 0;
-
-		addAction.setEnabled(hasSelection);
-		//editAction.setEnabled(hasTags || hasMemberships);
-		editAction.setEnabled(true);
-		tagTable.setVisible(hasTags);
-		tagTable.getTableHeader().setVisible(hasTags);
-		selectSth.setVisible(!hasSelection);
-
-		int selectedIndex;
-		if (selectedTag != null && (selectedIndex = findRow(tagData, selectedTag)) != -1) {
-			tagTable.changeSelection(selectedIndex, 0, false, false);
-		} else if (selectedRelation != null && (selectedIndex = findRow(membershipData, selectedRelation)) != -1) {
-			membershipTable.changeSelection(selectedIndex, 0, false, false);
-		} else if (hasTags) {
-			tagTable.changeSelection(0, 0, false, false);
-		} else if (hasMemberships) {
-			membershipTable.changeSelection(0, 0, false, false);
-		}
-	}
-
-	@Override
-	public void processDatasetEvent(AbstractDatasetChangedEvent event) {
-		updateSelection();
-	}
-
-	// </editor-fold>
-
-	// <editor-fold defaultstate="collapsed" desc="Methods that are called by plugins to extend fuctionality ">
-
-
-	/**
-	 * Returns the selected tag.
-	 * @return The current selected tag
-	 */
-	@SuppressWarnings("unchecked")
-	public Tag getSelectedProperty() {
-		int row = tagTable.getSelectedRow();
-		if (row == -1) return null;
-		Map<String, Integer> map = (TreeMap<String, Integer>) tagData.getValueAt(row, 1);
-		return new Tag(
-				tagData.getValueAt(row, 0).toString(),
-				map.size() > 1 ? "" : map.keySet().iterator().next());
-	}
-
-	/**
-	 * Returns the selected relation membership.
-	 * @return The current selected relation membership
-	 */
-	public IRelation getSelectedMembershipRelation() {
-		int row = membershipTable.getSelectedRow();
-		return row > -1 ? (IRelation) membershipData.getValueAt(row, 0) : null;
-	}
-
-	// </editor-fold>
-
-	/**
-	 * Class that watches for mouse clicks
-	 * @author imi
-	 */
-	public class MouseClickWatch extends MouseAdapter {
-		@Override
-		public void mouseClicked(MouseEvent e) {
-			if (e.getClickCount() < 2) {
-				// single click, clear selection in other table not clicked in
-				if (e.getSource() == tagTable) {
-					membershipTable.clearSelection();
-				} else if (e.getSource() == membershipTable) {
-					tagTable.clearSelection();
-				}
-			} else if (e.getSource() == tagTable) {
-				// double click, edit or add tag
-				int row = tagTable.rowAtPoint(e.getPoint());
-				if (row > -1) {
-					boolean focusOnKey = tagTable.columnAtPoint(e.getPoint()) == 0;
-					editHelper.editTag(row, focusOnKey);
-				} else {
-					editHelper.addTag();
-				}
-			} else if (e.getSource() == membershipTable) {
-				int row = membershipTable.rowAtPoint(e.getPoint());
-				if (row > -1) {
-					editMembership(row);
-				}
-			} else {
-				editHelper.addTag();
-			}
-		}
-
-		@Override
-		public void mousePressed(MouseEvent e) {
-			if (e.getSource() == tagTable) {
-				membershipTable.clearSelection();
-			} else if (e.getSource() == membershipTable) {
-				tagTable.clearSelection();
-			}
-		}
-	}
-
-	static class MemberInfo {
-		private List<RelationMember> role = new ArrayList<>();
-		private Set<OsmPrimitive> members = new HashSet<>();
-		private List<Integer> position = new ArrayList<>();
-		private Iterable<OsmPrimitive> selection;
-		private String positionString;
-		private String roleString;
-
-		MemberInfo(Iterable<OsmPrimitive> selection) {
-			this.selection = selection;
-		}
-
-		void add(RelationMember r, Integer p) {
-			role.add(r);
-			members.add(r.getMember());
-			position.add(p);
-		}
-
-		@Override
-		public String toString() {
-			return "MemberInfo{" +
-					"roles='" + roleString + '\'' +
-					", positions='" + positionString + '\'' +
-					'}';
-		}
-	}
-
-	/**
-	 * Class that allows fast creation of read-only table model with String columns
-	 */
-	public static class ReadOnlyTableModel extends DefaultTableModel {
-		@Override
-		public boolean isCellEditable(int row, int column) {
-			return false;
-		}
-
-		@Override
-		public Class<?> getColumnClass(int columnIndex) {
-			return String.class;
-		}
-	}
-
-	/**
-	 * Action handling add button press in properties dialog.
-	 */
-	class AddAction extends JosmAction {
-		AddAction() {
-			super(tr("Add Recommendation"), /* ICON() */ "dialogs/add", tr("Add a recommended key/value pair to your object"),
-					Shortcut.registerShortcut("properties:add", tr("Add Tag"), KeyEvent.VK_A,
-							Shortcut.ALT), false);
-		}
-
-		@Override
-		public void actionPerformed(ActionEvent e) {
-			editHelper.addTag();
-			btnAdd.requestFocusInWindow();
-		}
-	}
-
-	/**
-	 * Action handling edit button press in properties dialog.
-	 * training process dialog/configuration
-	 */
-	class EditActionTrain extends JosmAction implements ListSelectionListener {
-		EditActionTrain() {
-			super(tr("Train a Model"), /* ICON() */ "dialogs/fix", tr("Start the training engine!"),
-					Shortcut.registerShortcut("properties:edit", tr("Edit Tags"), KeyEvent.VK_S,
-							Shortcut.ALT), false);
-			setEnabled(true);
-			updateEnabledState();
-		}
-
-		@Override
-		public void actionPerformed(ActionEvent e) {
-			if (!isEnabled())
-				return;
-			if (tagTable.getSelectedRowCount() == 1) {
-				int row = tagTable.getSelectedRow();
-				editHelper.editTag(row, false);
-			} else if (membershipTable.getSelectedRowCount() == 1) {
-				int row = membershipTable.getSelectedRow();
-				editHelper.editTag(row, false);
-			} else {
-				editHelper.editTag(1, false);
-			}
-		}
-
-		@Override
-		protected void updateEnabledState() {
-			setEnabled(true);
-		}
-
-		@Override
-		public void valueChanged(ListSelectionEvent e) {
-			updateEnabledState();
-		}
-	}
+implements DataSelectionListener, DataSetListenerAdapter.Listener {
+
+    /**
+     * The tag data of selected objects.
+     */
+    private final DefaultTableModel tagData = new ReadOnlyTableModel();
+
+    /**
+     * The membership data of selected objects.
+     */
+    private final DefaultTableModel membershipData = new ReadOnlyTableModel();
+
+    /**
+     * The tags table.
+     */
+    private final JTable tagTable = new JTable(tagData);
+
+    /**
+     * The membership table.
+     */
+    private final JTable membershipTable = new JTable(membershipData);
+
+    /** JPanel containing both previous tables */
+    private final JPanel bothTables = new JPanel();
+
+    private final transient Map<String, Map<String, Integer>> valueCount = new TreeMap<>();
+    /**
+     * This sub-object is responsible for all adding and editing of tags
+     */
+    private final transient OSMRecPluginHelper editHelper = new OSMRecPluginHelper(tagData, valueCount);
+
+    private final AddAction addAction = new AddAction();
+    private final EditActionTrain editAction = new EditActionTrain();
+    //    private final DeleteAction deleteAction = new DeleteAction();
+    //    private final JosmAction[] josmActions = new JosmAction[]{addAction, editAction, deleteAction};
+
+    /**
+     * The Add button (needed to be able to disable it)
+     */
+    private final SideButton btnAdd = new SideButton(addAction);
+    /**
+     * The Edit button (needed to be able to disable it)
+     */
+    private final SideButton btnEdit = new SideButton(editAction);
+
+    /**
+     * Text to display when nothing selected.
+     */
+    private final JLabel selectSth = new JLabel("<html><p>"
+            + tr("Select objects or create new objects and get recommendation.") + "</p></html>");
+
+    // <editor-fold defaultstate="collapsed" desc="Dialog construction and helper methods">
+
+    /**
+     * Create a new OSMRecToggleDialog
+     */
+    public OSMRecToggleDialog() {
+        super(tr("Tags/Memberships"), "propertiesdialog", tr("Tags for selected objects."),
+                Shortcut.registerShortcut("subwindow:properties", tr("Toggle: {0}", tr("Tags/Memberships")), KeyEvent.VK_P,
+                        Shortcut.ALT_SHIFT), 150, true);
+
+        System.out.println("cleaning test..");
+        bothTables.setLayout(new GridBagLayout());
+        bothTables.setVisible(false); //my
+        // Let the actions know when selection in the tables change
+        tagTable.getSelectionModel().addListSelectionListener(editAction);
+        membershipTable.getSelectionModel().addListSelectionListener(editAction);
+
+        JScrollPane scrollPane = (JScrollPane) createLayout(bothTables, true,
+                Arrays.asList(this.btnAdd, this.btnEdit));
+
+        MouseClickWatch mouseClickWatch = new MouseClickWatch();
+        tagTable.addMouseListener(mouseClickWatch);
+        membershipTable.addMouseListener(mouseClickWatch);
+        scrollPane.addMouseListener(mouseClickWatch);
+        editHelper.loadTagsIfNeeded();
+
+    }
+
+    /**
+     * This simply fires up an {@link RelationEditor} for the relation shown; everything else
+     * is the editor's business.
+     *
+     * @param row position
+     */
+    private void editMembership(int row) {
+        Relation relation = (Relation) membershipData.getValueAt(row, 0);
+        MainApplication.getMap().relationListDialog.selectRelation(relation);
+    }
+
+    private int findRow(TableModel model, Object value) {
+        for (int i = 0; i < model.getRowCount(); i++) {
+            if (model.getValueAt(i, 0).equals(value))
+                return i;
+        }
+        return -1;
+    }
+
+    /**
+     * Update selection status, call @{link #selectionChanged} function.
+     */
+    private void updateSelection() {
+        // Parameter is ignored in this class
+        selectionChanged(null);
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Event listeners methods">
+
+    @Override
+    public void selectionChanged(SelectionChangeEvent event) {
+        if (tagTable == null)
+            return; // selection changed may be received in base class constructor before init
+        if (tagTable.getCellEditor() != null) {
+            tagTable.getCellEditor().cancelCellEditing();
+        }
+
+        // Ignore parameter as we do not want to operate always on real selection here, especially in draw mode
+        Collection<OsmPrimitive> newSel = OsmDataManager.getInstance().getInProgressSelection();
+        if (newSel == null) {
+            newSel = Collections.<OsmPrimitive>emptyList();
+        }
+
+        String selectedTag;
+        Relation selectedRelation = null;
+        selectedTag = editHelper.getChangedKey(); // select last added or last edited key by default
+        if (selectedTag == null && tagTable.getSelectedRowCount() == 1) {
+            selectedTag = (String) tagData.getValueAt(tagTable.getSelectedRow(), 0);
+        }
+        if (membershipTable.getSelectedRowCount() == 1) {
+            selectedRelation = (Relation) membershipData.getValueAt(membershipTable.getSelectedRow(), 0);
+        }
+
+        // re-load tag data
+        tagData.setRowCount(0);
+
+        final Map<String, String> tags = new HashMap<>();
+        valueCount.clear();
+        for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) {
+            int count = 0;
+            for (Entry<String, Integer> e1 : e.getValue().entrySet()) {
+                count += e1.getValue();
+            }
+            if (count < newSel.size()) {
+                e.getValue().put("", newSel.size() - count);
+            }
+            tagData.addRow(new Object[]{e.getKey(), e.getValue()});
+            tags.put(e.getKey(), e.getValue().size() == 1
+                    ? e.getValue().keySet().iterator().next() : tr("<different>"));
+        }
+
+        membershipData.setRowCount(0);
+
+        Map<Relation, MemberInfo> roles = new HashMap<>();
+        for (OsmPrimitive primitive: newSel) {
+            for (OsmPrimitive ref: primitive.getReferrers(true)) {
+                if (ref instanceof Relation && !ref.isIncomplete() && !ref.isDeleted()) {
+                    Relation r = (Relation) ref;
+                    MemberInfo mi = roles.get(r);
+                    if (mi == null) {
+                        mi = new MemberInfo();
+                    }
+                    roles.put(r, mi);
+                    int i = 1;
+                    for (RelationMember m : r.getMembers()) {
+                        if (m.getMember() == primitive) {
+                            mi.add(m, i);
+                        }
+                        ++i;
+                    }
+                }
+            }
+        }
+
+        List<Relation> sortedRelations = new ArrayList<>(roles.keySet());
+        Collections.sort(sortedRelations, new Comparator<Relation>() {
+            @Override public int compare(Relation o1, Relation o2) {
+                int comp = Boolean.valueOf(o1.isDisabledAndHidden()).compareTo(o2.isDisabledAndHidden());
+                return comp != 0 ? comp : DefaultNameFormatter.getInstance().getRelationComparator().compare(o1, o2);
+            } });
+
+        for (Relation r: sortedRelations) {
+            membershipData.addRow(new Object[]{r, roles.get(r)});
+        }
+
+        membershipTable.getTableHeader().setVisible(membershipData.getRowCount() > 0);
+        membershipTable.setVisible(membershipData.getRowCount() > 0);
+
+        boolean hasSelection = !newSel.isEmpty();
+        boolean hasTags = hasSelection && tagData.getRowCount() > 0;
+        boolean hasMemberships = hasSelection && membershipData.getRowCount() > 0;
+
+        addAction.setEnabled(hasSelection);
+        //editAction.setEnabled(hasTags || hasMemberships);
+        editAction.setEnabled(true);
+        tagTable.setVisible(hasTags);
+        tagTable.getTableHeader().setVisible(hasTags);
+        selectSth.setVisible(!hasSelection);
+
+        int selectedIndex;
+        if (selectedTag != null && (selectedIndex = findRow(tagData, selectedTag)) != -1) {
+            tagTable.changeSelection(selectedIndex, 0, false, false);
+        } else if (selectedRelation != null && (selectedIndex = findRow(membershipData, selectedRelation)) != -1) {
+            membershipTable.changeSelection(selectedIndex, 0, false, false);
+        } else if (hasTags) {
+            tagTable.changeSelection(0, 0, false, false);
+        } else if (hasMemberships) {
+            membershipTable.changeSelection(0, 0, false, false);
+        }
+    }
+
+    @Override
+    public void processDatasetEvent(AbstractDatasetChangedEvent event) {
+        updateSelection();
+    }
+
+    // </editor-fold>
+
+    // <editor-fold defaultstate="collapsed" desc="Methods that are called by plugins to extend fuctionality ">
+
+
+    /**
+     * Returns the selected tag.
+     * @return The current selected tag
+     */
+    @SuppressWarnings("unchecked")
+    public Tag getSelectedProperty() {
+        int row = tagTable.getSelectedRow();
+        if (row == -1) return null;
+        Map<String, Integer> map = (TreeMap<String, Integer>) tagData.getValueAt(row, 1);
+        return new Tag(
+                tagData.getValueAt(row, 0).toString(),
+                map.size() > 1 ? "" : map.keySet().iterator().next());
+    }
+
+    /**
+     * Returns the selected relation membership.
+     * @return The current selected relation membership
+     */
+    public IRelation<?> getSelectedMembershipRelation() {
+        int row = membershipTable.getSelectedRow();
+        return row > -1 ? (IRelation<?>) membershipData.getValueAt(row, 0) : null;
+    }
+
+    // </editor-fold>
+
+    /**
+     * Class that watches for mouse clicks
+     * @author imi
+     */
+    public class MouseClickWatch extends MouseAdapter {
+        @Override
+        public void mouseClicked(MouseEvent e) {
+            if (e.getClickCount() < 2) {
+                // single click, clear selection in other table not clicked in
+                if (e.getSource() == tagTable) {
+                    membershipTable.clearSelection();
+                } else if (e.getSource() == membershipTable) {
+                    tagTable.clearSelection();
+                }
+            } else if (e.getSource() == tagTable) {
+                // double click, edit or add tag
+                int row = tagTable.rowAtPoint(e.getPoint());
+                if (row > -1) {
+                    boolean focusOnKey = tagTable.columnAtPoint(e.getPoint()) == 0;
+                    editHelper.editTag(row, focusOnKey);
+                } else {
+                    editHelper.addTag();
+                }
+            } else if (e.getSource() == membershipTable) {
+                int row = membershipTable.rowAtPoint(e.getPoint());
+                if (row > -1) {
+                    editMembership(row);
+                }
+            } else {
+                editHelper.addTag();
+            }
+        }
+
+        @Override
+        public void mousePressed(MouseEvent e) {
+            if (e.getSource() == tagTable) {
+                membershipTable.clearSelection();
+            } else if (e.getSource() == membershipTable) {
+                tagTable.clearSelection();
+            }
+        }
+    }
+
+    static class MemberInfo {
+        private List<RelationMember> role = new ArrayList<>();
+        private Set<OsmPrimitive> members = new HashSet<>();
+        private List<Integer> position = new ArrayList<>();
+        private String positionString;
+        private String roleString;
+
+        MemberInfo() {
+        }
+
+        void add(RelationMember r, Integer p) {
+            role.add(r);
+            members.add(r.getMember());
+            position.add(p);
+        }
+
+        @Override
+        public String toString() {
+            return "MemberInfo{" +
+                    "roles='" + roleString + '\'' +
+                    ", positions='" + positionString + '\'' +
+                    '}';
+        }
+    }
+
+    /**
+     * Class that allows fast creation of read-only table model with String columns
+     */
+    public static class ReadOnlyTableModel extends DefaultTableModel {
+        @Override
+        public boolean isCellEditable(int row, int column) {
+            return false;
+        }
+
+        @Override
+        public Class<?> getColumnClass(int columnIndex) {
+            return String.class;
+        }
+    }
+
+    /**
+     * Action handling add button press in properties dialog.
+     */
+    class AddAction extends JosmAction {
+        AddAction() {
+            super(tr("Add Recommendation"), /* ICON() */ "dialogs/add", tr("Add a recommended key/value pair to your object"),
+                    Shortcut.registerShortcut("properties:add", tr("Add Tag"), KeyEvent.VK_A,
+                            Shortcut.ALT), false);
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            editHelper.addTag();
+            btnAdd.requestFocusInWindow();
+        }
+    }
+
+    /**
+     * Action handling edit button press in properties dialog.
+     * training process dialog/configuration
+     */
+    class EditActionTrain extends JosmAction implements ListSelectionListener {
+        EditActionTrain() {
+            super(tr("Train a Model"), /* ICON() */ "dialogs/fix", tr("Start the training engine!"),
+                    Shortcut.registerShortcut("properties:edit", tr("Edit Tags"), KeyEvent.VK_S,
+                            Shortcut.ALT), false);
+            setEnabled(true);
+            updateEnabledState();
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (!isEnabled())
+                return;
+            if (tagTable.getSelectedRowCount() == 1) {
+                int row = tagTable.getSelectedRow();
+                editHelper.editTag(row, false);
+            } else if (membershipTable.getSelectedRowCount() == 1) {
+                int row = membershipTable.getSelectedRow();
+                editHelper.editTag(row, false);
+            } else {
+                editHelper.editTag(1, false);
+            }
+        }
+
+        @Override
+        protected void updateEnabledState() {
+            setEnabled(true);
+        }
+
+        @Override
+        public void valueChanged(ListSelectionEvent e) {
+            updateEnabledState();
+        }
+    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/core/TrainWorker.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/core/TrainWorker.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/core/TrainWorker.java	(revision 34539)
@@ -697,5 +697,5 @@
     protected void done() {
         try {
-            System.out.println("Training process complete! - > " + get());
+            get();
             setProgress(100);
         } catch (InterruptedException | ExecutionException ignore) {
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/Analyzer.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/Analyzer.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/Analyzer.java	(revision 34539)
@@ -6,4 +6,5 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.AbstractMap;
 import java.util.AbstractMap.SimpleEntry;
@@ -383,5 +384,5 @@
         InputStream fstream = Analyzer.class.getResourceAsStream("/resources/files/stopWords.txt");
 
-        try (BufferedReader br = new BufferedReader(new InputStreamReader(fstream))) {
+        try (BufferedReader br = new BufferedReader(new InputStreamReader(fstream, StandardCharsets.UTF_8))) {
             String strLine;
 
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/FrequenceExtractor.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/FrequenceExtractor.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/FrequenceExtractor.java	(revision 34539)
@@ -14,5 +14,5 @@
 import org.openstreetmap.josm.plugins.osmrec.container.OSMWay;
 import org.openstreetmap.josm.tools.Logging;
-import org.openstreetmap.josm.tools.Utils;
+import org.openstreetmap.josm.tools.XmlUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -27,176 +27,176 @@
 public class FrequenceExtractor extends DefaultHandler {
 
-	private final List<OSMNode> nodeList; //will be populated with nodes
-	private final List<OSMRelation> relationList;
-	private final Map<String, OSMNode> nodesWithIDs; //map containing IDs as Strings and the corresponding OSMNode objects
-	private final List<OSMWay> wayList;  //populated with ways of the OSM file
-	private final String osmXmlFileName;
-	private OSMNode nodeTmp;
-	private OSMWay wayTmp;
-	private OSMRelation relationTmp;
-	private boolean inWay = false; //when parser is in a way node becomes true in order to track the parser position
-	private boolean inNode = false; //becomes true when the parser is in a simple node
-	private boolean inRelation = false; //becomes true when the parser is in a relarion node
-	private Map<String, Integer> frequency;
-
-	public FrequenceExtractor(String osmXmlFileName) {
-		this.osmXmlFileName = osmXmlFileName;
-		nodeList = new ArrayList<>();
-		wayList = new ArrayList<>();
-		relationList = new ArrayList<>();
-		nodesWithIDs = new HashMap<>();
-		frequency = new HashMap<>();
-		for (int i = 0; i < 100; i++) {
-			frequency.put("", 0);
-		}
-	}
-
-	public void parseDocument() {
-		Logging.info("extracting frequencies...");
-		try {
-			Utils.newSafeSAXParser().parse(osmXmlFileName, this);
-		} catch (ParserConfigurationException | IOException | SAXException e) {
-			Logging.error(e);
-		}
-	}
-
-	@Override
-	public void startElement(String s, String s1, String elementName, Attributes attributes) throws SAXException {
-
-		// if current element is an OSMNode , create new node and populate with the appropriate values
-		if (elementName.equalsIgnoreCase("node")) {
-			nodeTmp = new OSMNode();
-			inNode = true;
-			inWay = false;
-			inRelation = false;
-
-		} else if (elementName.equalsIgnoreCase("way")) {
-			wayTmp = new OSMWay();
-			//wayTmp.setID(attributes.getValue("id"));
-			inWay = true;
-			inNode = false;
-			inRelation = false;
-		} else if (elementName.equalsIgnoreCase("relation")) {
-			relationTmp = new OSMRelation();
-			//relationTmp.setID(attributes.getValue("id"));
-			inRelation = true;
-			inWay = false;
-			inNode = false;
-		} else if (elementName.equalsIgnoreCase("nd")) {
-			//wayTmp.addNodeReference(attributes.getValue("ref"));
-
-		} else if (elementName.equalsIgnoreCase("tag")) {
-
-			if (inNode) {
-				//if the path is in an OSMNode set tagKey and value to the corresponding node
-				nodeTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			} else if (inWay) {
-				//else if the path is in an OSM way set tagKey and value to the corresponding way
-				wayTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			} else if (inRelation) {
-				//set the key-value pairs of relation tags
-				relationTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			}
-
-		} else if (elementName.equalsIgnoreCase("member")) {
-			//relationTmp.addMemberReference(attributes.getValue("ref"));
-		}
-	}
-
-	@Override
-	public void endElement(String s, String s1, String element) throws SAXException {
-		// if end of node element, add to appropriate list
-		if (element.equalsIgnoreCase("node")) {
-			Map<String, String> tags = nodeTmp.getTagKeyValue();
-			if (tags.keySet().contains("name")) {
-				for (Map.Entry<String, String> tag : tags.entrySet()) {
-					if (tag.getKey().equals("name")) {
-						//split name value in each white space and store the values separetely. Count each occurance
-						String name = tag.getValue();
-						String[] SplitName = name.split("\\s+");
-
-						for (String split : SplitName) {
-							//put all splits with zero, at the constructor. put here the incremented values. for tomoro
-							if (frequency.get(split) != null) {
-								int k = frequency.get(split) +1;
-								frequency.put(split, k);
-							} else {
-								frequency.put(split, 1);
-							}
-						}
-					}
-				}
-			}
-		}
-
-		if (element.equalsIgnoreCase("way")) {
-			//name frequency
-			Map<String, String> tags = wayTmp.getTagKeyValue();
-
-			if (tags.keySet().contains("name")) {
-				for (Map.Entry<String, String> tag : tags.entrySet()) {
-					if (tag.getKey().equals("name")) {
-						//split name value in each white space and store the values separetely. Count each occurance
-						String name = tag.getValue();
-						String[] SplitName = name.split("\\s+");
-						for (String split : SplitName) {
-							//put all splits with zero, at the constructor. put here the incremented values. for tomoro
-							if (frequency.get(split) != null) {
-								int k = frequency.get(split) +1;
-								frequency.put(split, k);
-							} else {
-								frequency.put(split, 1);
-							}
-						}
-					}
-				}
-			}
-		}
-
-		if (element.equalsIgnoreCase("relation")) {
-			//name frequency
-			Map<String, String> tags = relationTmp.getTagKeyValue();
-
-			if (tags.keySet().contains("name")) {
-				for (Map.Entry<String, String> tag : tags.entrySet()) {
-					if (tag.getKey().equals("name")) {
-						//split name value in each white space and store the values separetely. Count each occurance
-						String name = tag.getValue();
-						String[] SplitName = name.split("\\s+");
-
-						for (String split : SplitName) {
-							//put all splits with zero, at the constructor. put here the incremented values. for tomoro
-							if (frequency.get(split) != null) {
-								int k = frequency.get(split) +1;
-								frequency.put(split, k);
-							} else {
-								frequency.put(split, 1);
-							}
-						}
-					}
-				}
-			}
-		}
-	}
-
-	public List<OSMNode> getNodeList() {
-		return nodeList;
-	}
-
-	public List<OSMWay> getWayList() {
-		return wayList;
-	}
-
-	public List<OSMRelation> getRelationList() {
-		return relationList;
-	}
-
-	public Map<String, OSMNode> getNodesWithIDs() {
-		return nodesWithIDs;
-	}
-
-	//frequency temp
-	public Map<String, Integer> getFrequency() {
-		return frequency;
-	}
+    private final List<OSMNode> nodeList; //will be populated with nodes
+    private final List<OSMRelation> relationList;
+    private final Map<String, OSMNode> nodesWithIDs; //map containing IDs as Strings and the corresponding OSMNode objects
+    private final List<OSMWay> wayList;  //populated with ways of the OSM file
+    private final String osmXmlFileName;
+    private OSMNode nodeTmp;
+    private OSMWay wayTmp;
+    private OSMRelation relationTmp;
+    private boolean inWay = false; //when parser is in a way node becomes true in order to track the parser position
+    private boolean inNode = false; //becomes true when the parser is in a simple node
+    private boolean inRelation = false; //becomes true when the parser is in a relarion node
+    private Map<String, Integer> frequency;
+
+    public FrequenceExtractor(String osmXmlFileName) {
+        this.osmXmlFileName = osmXmlFileName;
+        nodeList = new ArrayList<>();
+        wayList = new ArrayList<>();
+        relationList = new ArrayList<>();
+        nodesWithIDs = new HashMap<>();
+        frequency = new HashMap<>();
+        for (int i = 0; i < 100; i++) {
+            frequency.put("", 0);
+        }
+    }
+
+    public void parseDocument() {
+        Logging.info("extracting frequencies...");
+        try {
+            XmlUtils.newSafeSAXParser().parse(osmXmlFileName, this);
+        } catch (ParserConfigurationException | IOException | SAXException e) {
+            Logging.error(e);
+        }
+    }
+
+    @Override
+    public void startElement(String s, String s1, String elementName, Attributes attributes) throws SAXException {
+
+        // if current element is an OSMNode , create new node and populate with the appropriate values
+        if (elementName.equalsIgnoreCase("node")) {
+            nodeTmp = new OSMNode();
+            inNode = true;
+            inWay = false;
+            inRelation = false;
+
+        } else if (elementName.equalsIgnoreCase("way")) {
+            wayTmp = new OSMWay();
+            //wayTmp.setID(attributes.getValue("id"));
+            inWay = true;
+            inNode = false;
+            inRelation = false;
+        } else if (elementName.equalsIgnoreCase("relation")) {
+            relationTmp = new OSMRelation();
+            //relationTmp.setID(attributes.getValue("id"));
+            inRelation = true;
+            inWay = false;
+            inNode = false;
+        } else if (elementName.equalsIgnoreCase("nd")) {
+            //wayTmp.addNodeReference(attributes.getValue("ref"));
+
+        } else if (elementName.equalsIgnoreCase("tag")) {
+
+            if (inNode) {
+                //if the path is in an OSMNode set tagKey and value to the corresponding node
+                nodeTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            } else if (inWay) {
+                //else if the path is in an OSM way set tagKey and value to the corresponding way
+                wayTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            } else if (inRelation) {
+                //set the key-value pairs of relation tags
+                relationTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            }
+
+        } else if (elementName.equalsIgnoreCase("member")) {
+            //relationTmp.addMemberReference(attributes.getValue("ref"));
+        }
+    }
+
+    @Override
+    public void endElement(String s, String s1, String element) throws SAXException {
+        // if end of node element, add to appropriate list
+        if (element.equalsIgnoreCase("node")) {
+            Map<String, String> tags = nodeTmp.getTagKeyValue();
+            if (tags.keySet().contains("name")) {
+                for (Map.Entry<String, String> tag : tags.entrySet()) {
+                    if (tag.getKey().equals("name")) {
+                        //split name value in each white space and store the values separetely. Count each occurance
+                        String name = tag.getValue();
+                        String[] SplitName = name.split("\\s+");
+
+                        for (String split : SplitName) {
+                            //put all splits with zero, at the constructor. put here the incremented values. for tomoro
+                            if (frequency.get(split) != null) {
+                                int k = frequency.get(split) +1;
+                                frequency.put(split, k);
+                            } else {
+                                frequency.put(split, 1);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (element.equalsIgnoreCase("way")) {
+            //name frequency
+            Map<String, String> tags = wayTmp.getTagKeyValue();
+
+            if (tags.keySet().contains("name")) {
+                for (Map.Entry<String, String> tag : tags.entrySet()) {
+                    if (tag.getKey().equals("name")) {
+                        //split name value in each white space and store the values separetely. Count each occurance
+                        String name = tag.getValue();
+                        String[] SplitName = name.split("\\s+");
+                        for (String split : SplitName) {
+                            //put all splits with zero, at the constructor. put here the incremented values. for tomoro
+                            if (frequency.get(split) != null) {
+                                int k = frequency.get(split) +1;
+                                frequency.put(split, k);
+                            } else {
+                                frequency.put(split, 1);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        if (element.equalsIgnoreCase("relation")) {
+            //name frequency
+            Map<String, String> tags = relationTmp.getTagKeyValue();
+
+            if (tags.keySet().contains("name")) {
+                for (Map.Entry<String, String> tag : tags.entrySet()) {
+                    if (tag.getKey().equals("name")) {
+                        //split name value in each white space and store the values separetely. Count each occurance
+                        String name = tag.getValue();
+                        String[] SplitName = name.split("\\s+");
+
+                        for (String split : SplitName) {
+                            //put all splits with zero, at the constructor. put here the incremented values. for tomoro
+                            if (frequency.get(split) != null) {
+                                int k = frequency.get(split) +1;
+                                frequency.put(split, k);
+                            } else {
+                                frequency.put(split, 1);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public List<OSMNode> getNodeList() {
+        return nodeList;
+    }
+
+    public List<OSMWay> getWayList() {
+        return wayList;
+    }
+
+    public List<OSMRelation> getRelationList() {
+        return relationList;
+    }
+
+    public Map<String, OSMNode> getNodesWithIDs() {
+        return nodesWithIDs;
+    }
+
+    //frequency temp
+    public Map<String, Integer> getFrequency() {
+        return frequency;
+    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/LanguageDetector.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/LanguageDetector.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/extractor/LanguageDetector.java	(revision 34539)
@@ -23,97 +23,97 @@
 public final class LanguageDetector {
 
-	private static LanguageDetector languageDetector = null;
+    private static LanguageDetector languageDetector = null;
 
-	private LanguageDetector() {
-		//prevent instatiation
-	}
+    private LanguageDetector() {
+        //prevent instatiation
+    }
 
-	public static LanguageDetector getInstance(String languageProfilesPath) {
-		if (languageDetector == null) {
-			languageDetector = new LanguageDetector();
-			loadProfilesFromStream(languageProfilesPath);
-			//profilesLoaded = true;
-		}
-		return languageDetector;
-	}
+    public static LanguageDetector getInstance(String languageProfilesPath) {
+        if (languageDetector == null) {
+            languageDetector = new LanguageDetector();
+            loadProfilesFromStream(languageProfilesPath);
+            //profilesLoaded = true;
+        }
+        return languageDetector;
+    }
 
-	public static void loadProfilesFromStream(String languageProfilesPath) { //create profiles directory in system from stream and load them
+    public static void loadProfilesFromStream(String languageProfilesPath) { //create profiles directory in system from stream and load them
 
-		/*  supported languages
+        /*  supported languages
             el:greek, en:english, de:german, fr:french, es:spanish, ru:russian, tr:turkish, zh-cn:chinese, hi:hindi
-		 */
-		InputStream languageProfilesInputStreamEl = LanguageDetector.class.getResourceAsStream("/profiles/el");
-		InputStream languageProfilesInputStreamEn = LanguageDetector.class.getResourceAsStream("/profiles/en");
-		InputStream languageProfilesInputStreamDe = LanguageDetector.class.getResourceAsStream("/profiles/de");
-		InputStream languageProfilesInputStreamFr = LanguageDetector.class.getResourceAsStream("/profiles/fr");
-		InputStream languageProfilesInputStreamEs = LanguageDetector.class.getResourceAsStream("/profiles/es");
-		InputStream languageProfilesInputStreamRu = LanguageDetector.class.getResourceAsStream("/profiles/ru");
-		InputStream languageProfilesInputStreamTr = LanguageDetector.class.getResourceAsStream("/profiles/tr");
-		InputStream languageProfilesInputStreamZh = LanguageDetector.class.getResourceAsStream("/profiles/zh-cn");
-		InputStream languageProfilesInputStreamHi = LanguageDetector.class.getResourceAsStream("/profiles/hi");
-		//InputStream languageProfilesInputStream2 = LanguageDetector.class.getResourceAsStream("/resources/profiles/en");
+         */
+        InputStream languageProfilesInputStreamEl = LanguageDetector.class.getResourceAsStream("/profiles/el");
+        InputStream languageProfilesInputStreamEn = LanguageDetector.class.getResourceAsStream("/profiles/en");
+        InputStream languageProfilesInputStreamDe = LanguageDetector.class.getResourceAsStream("/profiles/de");
+        InputStream languageProfilesInputStreamFr = LanguageDetector.class.getResourceAsStream("/profiles/fr");
+        InputStream languageProfilesInputStreamEs = LanguageDetector.class.getResourceAsStream("/profiles/es");
+        InputStream languageProfilesInputStreamRu = LanguageDetector.class.getResourceAsStream("/profiles/ru");
+        InputStream languageProfilesInputStreamTr = LanguageDetector.class.getResourceAsStream("/profiles/tr");
+        InputStream languageProfilesInputStreamZh = LanguageDetector.class.getResourceAsStream("/profiles/zh-cn");
+        InputStream languageProfilesInputStreamHi = LanguageDetector.class.getResourceAsStream("/profiles/hi");
+        //InputStream languageProfilesInputStream2 = LanguageDetector.class.getResourceAsStream("/resources/profiles/en");
 
-		if (!new File(languageProfilesPath).exists()) {
-			Utils.mkDirs(new File(languageProfilesPath));
-		}
+        if (!new File(languageProfilesPath).exists()) {
+            Utils.mkDirs(new File(languageProfilesPath));
+        }
 
-		File languageProfilesOutputFileEl = new File(languageProfilesPath + "/el");
-		File languageProfilesOutputFileEn = new File(languageProfilesPath + "/en");
-		File languageProfilesOutputFileDe = new File(languageProfilesPath + "/de");
-		File languageProfilesOutputFileFr = new File(languageProfilesPath + "/fr");
-		File languageProfilesOutputFileEs = new File(languageProfilesPath + "/es");
-		File languageProfilesOutputFileRu = new File(languageProfilesPath + "/ru");
-		File languageProfilesOutputFileTr = new File(languageProfilesPath + "/tr");
-		File languageProfilesOutputFileZh = new File(languageProfilesPath + "/zh-cn");
-		File languageProfilesOutputFileHi = new File(languageProfilesPath + "/hi");
+        File languageProfilesOutputFileEl = new File(languageProfilesPath + "/el");
+        File languageProfilesOutputFileEn = new File(languageProfilesPath + "/en");
+        File languageProfilesOutputFileDe = new File(languageProfilesPath + "/de");
+        File languageProfilesOutputFileFr = new File(languageProfilesPath + "/fr");
+        File languageProfilesOutputFileEs = new File(languageProfilesPath + "/es");
+        File languageProfilesOutputFileRu = new File(languageProfilesPath + "/ru");
+        File languageProfilesOutputFileTr = new File(languageProfilesPath + "/tr");
+        File languageProfilesOutputFileZh = new File(languageProfilesPath + "/zh-cn");
+        File languageProfilesOutputFileHi = new File(languageProfilesPath + "/hi");
 
-		try {
-			languageProfilesOutputFileEl.createNewFile();
-			languageProfilesOutputFileEn.createNewFile();
-			languageProfilesOutputFileDe.createNewFile();
-			languageProfilesOutputFileFr.createNewFile();
-			languageProfilesOutputFileEs.createNewFile();
-			languageProfilesOutputFileRu.createNewFile();
-			languageProfilesOutputFileTr.createNewFile();
-			languageProfilesOutputFileZh.createNewFile();
-			languageProfilesOutputFileHi.createNewFile();
-		} catch (IOException ex) {
-			Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
-			Logging.error(ex);
-		}
+        try {
+            languageProfilesOutputFileEl.createNewFile();
+            languageProfilesOutputFileEn.createNewFile();
+            languageProfilesOutputFileDe.createNewFile();
+            languageProfilesOutputFileFr.createNewFile();
+            languageProfilesOutputFileEs.createNewFile();
+            languageProfilesOutputFileRu.createNewFile();
+            languageProfilesOutputFileTr.createNewFile();
+            languageProfilesOutputFileZh.createNewFile();
+            languageProfilesOutputFileHi.createNewFile();
+        } catch (IOException ex) {
+            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
+            Logging.error(ex);
+        }
 
-		try {
-			Files.copy(languageProfilesInputStreamEl, languageProfilesOutputFileEl.toPath());
-			Files.copy(languageProfilesInputStreamEn, languageProfilesOutputFileEn.toPath());
-			Files.copy(languageProfilesInputStreamDe, languageProfilesOutputFileDe.toPath());
-			Files.copy(languageProfilesInputStreamFr, languageProfilesOutputFileFr.toPath());
-			Files.copy(languageProfilesInputStreamEs, languageProfilesOutputFileEs.toPath());
-			Files.copy(languageProfilesInputStreamRu, languageProfilesOutputFileRu.toPath());
-			Files.copy(languageProfilesInputStreamTr, languageProfilesOutputFileTr.toPath());
-			Files.copy(languageProfilesInputStreamZh, languageProfilesOutputFileZh.toPath());
-			Files.copy(languageProfilesInputStreamHi, languageProfilesOutputFileHi.toPath());
-		} catch (IOException ex) {
-			Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
-			Logging.error(ex);
-		}
+        try {
+            Files.copy(languageProfilesInputStreamEl, languageProfilesOutputFileEl.toPath());
+            Files.copy(languageProfilesInputStreamEn, languageProfilesOutputFileEn.toPath());
+            Files.copy(languageProfilesInputStreamDe, languageProfilesOutputFileDe.toPath());
+            Files.copy(languageProfilesInputStreamFr, languageProfilesOutputFileFr.toPath());
+            Files.copy(languageProfilesInputStreamEs, languageProfilesOutputFileEs.toPath());
+            Files.copy(languageProfilesInputStreamRu, languageProfilesOutputFileRu.toPath());
+            Files.copy(languageProfilesInputStreamTr, languageProfilesOutputFileTr.toPath());
+            Files.copy(languageProfilesInputStreamZh, languageProfilesOutputFileZh.toPath());
+            Files.copy(languageProfilesInputStreamHi, languageProfilesOutputFileHi.toPath());
+        } catch (IOException ex) {
+            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
+            Logging.error(ex);
+        }
 
-		try {
-			DetectorFactory.loadProfile(languageProfilesPath);
-		} catch (LangDetectException ex) {
-			Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
-			Logging.error(ex);
-		}
-	}
+        try {
+            DetectorFactory.loadProfile(languageProfilesPath);
+        } catch (LangDetectException ex) {
+            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
+            Logging.error(ex);
+        }
+    }
 
-	public String detect(String text) {
-		try {
-			Detector detector = DetectorFactory.create();
-			detector.append(text);
-			return detector.detect();
-		} catch (LangDetectException ex) {
-			Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
-			Logging.error(ex);
-			return "en"; //default lang to return if anything goes wrong at detection
-		}
-	}
+    public String detect(String text) {
+        try {
+            Detector detector = DetectorFactory.create();
+            detector.append(text);
+            return detector.detect();
+        } catch (LangDetectException ex) {
+            Logger.getLogger(LanguageDetector.class.getName()).log(Level.SEVERE, null, ex);
+            Logging.error(ex);
+            return "en"; //default lang to return if anything goes wrong at detection
+        }
+    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/Mapper.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/Mapper.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/Mapper.java	(revision 34539)
@@ -29,9 +29,7 @@
         mappingsWithIDs = new HashMap<>();
         idsWithMappings = new HashMap<>();
-
     }
 
     public void parseFile(InputStream inps) throws FileNotFoundException {
-
         Scanner input = new Scanner(inps, "UTF-8"); //the Map file contains lines of the mappings separated with the symbol "|"
         //e.g. highway motorway | Motorway
@@ -50,6 +48,4 @@
         constructMappingsWithIDs();
         constructIDsWithMappings();
-        System.out.println("Mappings file parsed successfully!");
-        //LOG.info("Mappings file parsed successfully!");
     }
 
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/OSMParser.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/OSMParser.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/OSMParser.java	(revision 34539)
@@ -25,5 +25,5 @@
 import org.openstreetmap.josm.plugins.osmrec.container.OSMWay;
 import org.openstreetmap.josm.tools.Logging;
-import org.openstreetmap.josm.tools.Utils;
+import org.openstreetmap.josm.tools.XmlUtils;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -45,179 +45,179 @@
 public class OSMParser extends DefaultHandler {
 
-	//private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OSMParser.class);
-
-	//change from wgs84 to cartesian for later processing of the geometry
-	private static final CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
-	private static final CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN;
-	private final GeometryFactory geometryFactory = new GeometryFactory();
-	private static MathTransform transform = null;
-	private final List<OSMNode> nodeList; //will be populated with nodes
-	private final List<OSMRelation> relationList;
-	private final Map<String, OSMNode> nodesWithIDs; //map containing IDs as Strings and the corresponding OSMNode objects
-	private final List<OSMWay> wayList;  //populated with ways of the OSM file
-	private final String osmXmlFileName;
-	private OSMNode nodeTmp; //variable to hold the node object
-	private OSMWay wayTmp;   //variable to hold the way object
-	private OSMRelation relationTmp;
-	private boolean inWay = false; //when parser is in a way node becomes true in order to track the parser position
-	private boolean inNode = false; //becomes true when the parser is in a simple node
-	private boolean inRelation = false; //becomes true when the parser is in a relarion node
-
-	public OSMParser(String osmXmlFileName) {
-		this.osmXmlFileName = osmXmlFileName;
-		nodeList = new ArrayList<>();
-		wayList = new ArrayList<>();
-		relationList = new ArrayList<>();
-		nodesWithIDs = new HashMap<>();
-		try {
-			transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
-		} catch (FactoryException ex) {
-			Logger.getLogger(OSMParser.class.getName()).log(Level.SEVERE, null, ex);
-		}
-	}
-
-	public void parseDocument() {
-		try {
-			Utils.newSafeSAXParser().parse(osmXmlFileName, this);
-		} catch (ParserConfigurationException | SAXException | IOException e) {
-			Logging.error(e);
-		}
-	}
-
-	@Override
-	public void startElement(String s, String s1, String elementName, Attributes attributes) throws SAXException {
-
-		// if current element is an OSMNode , create new node and populate with the appropriate values
-		if (elementName.equalsIgnoreCase("node")) {
-			nodeTmp = new OSMNode();
-			nodeTmp.setID(attributes.getValue("id"));
-			nodeTmp.setUser(attributes.getValue("user"));
-			//parse geometry
-			double longitude = Double.parseDouble(attributes.getValue("lon"));
-			double latitude = Double.parseDouble(attributes.getValue("lat"));
-
-			Coordinate targetGeometry = null;
-			Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
-			try {
-				targetGeometry = JTS.transform(sourceCoordinate, null, transform);
-			} catch (MismatchedDimensionException | TransformException ex) {
-				Logger.getLogger(OSMParser.class.getName()).log(Level.SEVERE, null, ex);
-			}
-
-			//create geometry object
-			Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
-			nodeTmp.setGeometry(geom);
-			inNode = true;
-			inWay = false;
-			inRelation = false;
-
-		} else if (elementName.equalsIgnoreCase("way")) {
-			wayTmp = new OSMWay();
-			wayTmp.setID(attributes.getValue("id"));
-
-			if (attributes.getValue("user") != null) {
-				wayTmp.setUser(attributes.getValue("user"));
-			} else {
-				wayTmp.setUser("undefined");
-			}
-
-			inWay = true;
-			inNode = false;
-			inRelation = false;
-		} else if (elementName.equalsIgnoreCase("relation")) {
-			relationTmp = new OSMRelation();
-			relationTmp.setID(attributes.getValue("id"));
-			inRelation = true;
-			inWay = false;
-			inNode = false;
-		} else if (elementName.equalsIgnoreCase("nd")) {
-			wayTmp.addNodeReference(attributes.getValue("ref"));
-
-		} else if (elementName.equalsIgnoreCase("tag")) {
-
-			if (inNode) {
-				//if the path is in an OSMNode set tagKey and value to the corresponding node
-				nodeTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			} else if (inWay) {
-				//else if the path is in an OSM way set tagKey and value to the corresponding way
-				wayTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			} else if (inRelation) {
-				//set the key-value pairs of relation tags
-				relationTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
-			}
-		} else if (elementName.equalsIgnoreCase("member")) {
-			relationTmp.addMemberReference(attributes.getValue("ref"));
-		}
-	}
-
-	@Override
-	public void endElement(String s, String s1, String element) throws SAXException {
-		// if end of node element, add to appropriate list
-		if (element.equalsIgnoreCase("node")) {
-			nodeList.add(nodeTmp);
-			nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
-		}
-
-		if (element.equalsIgnoreCase("way")) {
-
-			//construct the Way geometry from each node of the node references
-			List<String> references = wayTmp.getNodeReferences();
-
-			for (String entry: references) {
-				Geometry geometry = nodesWithIDs.get(entry).getGeometry(); //get the geometry of the node with ID=entry
-				wayTmp.addNodeGeometry(geometry); //add the node geometry in this way
-
-			}
-			Geometry geom = geometryFactory.buildGeometry(wayTmp.getNodeGeometries());
-
-			if ((wayTmp.getNumberOfNodes() > 3) &&
-					wayTmp.getNodeGeometries().get(0).equals(wayTmp.getNodeGeometries()
-							.get(wayTmp.getNodeGeometries().size()-1))) {
-				//checks if the beginning and ending node are the same and the number of nodes are more than 3.
-				//the nodes must be more than 3, because jts does not allow a construction of a linear ring with less points.
-
-				if (!((wayTmp.getTagKeyValue().containsKey("barrier")) || wayTmp.getTagKeyValue().containsKey("highway"))) {
-					//this is not a barrier nor a road, so construct a polygon geometry
-
-					LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
-					Polygon poly = new Polygon(linear, null, geometryFactory);
-					wayTmp.setGeometry(poly);
-				} else {
-					//it is either a barrier or a road, so construct a linear ring geometry
-					LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
-					wayTmp.setGeometry(linear);
-				}
-			} else if (wayTmp.getNumberOfNodes() > 1) {
-				//it is an open geometry with more than one nodes, make it linestring
-
-				LineString lineString = geometryFactory.createLineString(geom.getCoordinates());
-				wayTmp.setGeometry(lineString);
-			} else { //we assume all the rest geometries are points
-				//some ways happen to have only one point. Construct a  Point.
-				Point point = geometryFactory.createPoint(geom.getCoordinate());
-				wayTmp.setGeometry(point);
-			}
-			wayList.add(wayTmp);
-		}
-
-		if (element.equalsIgnoreCase("relation")) {
-			relationList.add(relationTmp);
-		}
-	}
-
-	public List<OSMNode> getNodeList() {
-		return nodeList;
-	}
-
-	public List<OSMWay> getWayList() {
-		return wayList;
-	}
-
-	public List<OSMRelation> getRelationList() {
-		return relationList;
-	}
-
-	public Map<String, OSMNode> getNodesWithIDs() {
-		return nodesWithIDs;
-	}
+    //private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(OSMParser.class);
+
+    //change from wgs84 to cartesian for later processing of the geometry
+    private static final CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
+    private static final CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN;
+    private final GeometryFactory geometryFactory = new GeometryFactory();
+    private static MathTransform transform = null;
+    private final List<OSMNode> nodeList; //will be populated with nodes
+    private final List<OSMRelation> relationList;
+    private final Map<String, OSMNode> nodesWithIDs; //map containing IDs as Strings and the corresponding OSMNode objects
+    private final List<OSMWay> wayList;  //populated with ways of the OSM file
+    private final String osmXmlFileName;
+    private OSMNode nodeTmp; //variable to hold the node object
+    private OSMWay wayTmp;   //variable to hold the way object
+    private OSMRelation relationTmp;
+    private boolean inWay = false; //when parser is in a way node becomes true in order to track the parser position
+    private boolean inNode = false; //becomes true when the parser is in a simple node
+    private boolean inRelation = false; //becomes true when the parser is in a relarion node
+
+    public OSMParser(String osmXmlFileName) {
+        this.osmXmlFileName = osmXmlFileName;
+        nodeList = new ArrayList<>();
+        wayList = new ArrayList<>();
+        relationList = new ArrayList<>();
+        nodesWithIDs = new HashMap<>();
+        try {
+            transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
+        } catch (FactoryException ex) {
+            Logger.getLogger(OSMParser.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public void parseDocument() {
+        try {
+            XmlUtils.newSafeSAXParser().parse(osmXmlFileName, this);
+        } catch (ParserConfigurationException | SAXException | IOException e) {
+            Logging.error(e);
+        }
+    }
+
+    @Override
+    public void startElement(String s, String s1, String elementName, Attributes attributes) throws SAXException {
+
+        // if current element is an OSMNode , create new node and populate with the appropriate values
+        if (elementName.equalsIgnoreCase("node")) {
+            nodeTmp = new OSMNode();
+            nodeTmp.setID(attributes.getValue("id"));
+            nodeTmp.setUser(attributes.getValue("user"));
+            //parse geometry
+            double longitude = Double.parseDouble(attributes.getValue("lon"));
+            double latitude = Double.parseDouble(attributes.getValue("lat"));
+
+            Coordinate targetGeometry = null;
+            Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
+            try {
+                targetGeometry = JTS.transform(sourceCoordinate, null, transform);
+            } catch (MismatchedDimensionException | TransformException ex) {
+                Logger.getLogger(OSMParser.class.getName()).log(Level.SEVERE, null, ex);
+            }
+
+            //create geometry object
+            Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
+            nodeTmp.setGeometry(geom);
+            inNode = true;
+            inWay = false;
+            inRelation = false;
+
+        } else if (elementName.equalsIgnoreCase("way")) {
+            wayTmp = new OSMWay();
+            wayTmp.setID(attributes.getValue("id"));
+
+            if (attributes.getValue("user") != null) {
+                wayTmp.setUser(attributes.getValue("user"));
+            } else {
+                wayTmp.setUser("undefined");
+            }
+
+            inWay = true;
+            inNode = false;
+            inRelation = false;
+        } else if (elementName.equalsIgnoreCase("relation")) {
+            relationTmp = new OSMRelation();
+            relationTmp.setID(attributes.getValue("id"));
+            inRelation = true;
+            inWay = false;
+            inNode = false;
+        } else if (elementName.equalsIgnoreCase("nd")) {
+            wayTmp.addNodeReference(attributes.getValue("ref"));
+
+        } else if (elementName.equalsIgnoreCase("tag")) {
+
+            if (inNode) {
+                //if the path is in an OSMNode set tagKey and value to the corresponding node
+                nodeTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            } else if (inWay) {
+                //else if the path is in an OSM way set tagKey and value to the corresponding way
+                wayTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            } else if (inRelation) {
+                //set the key-value pairs of relation tags
+                relationTmp.setTagKeyValue(attributes.getValue("k"), attributes.getValue("v"));
+            }
+        } else if (elementName.equalsIgnoreCase("member")) {
+            relationTmp.addMemberReference(attributes.getValue("ref"));
+        }
+    }
+
+    @Override
+    public void endElement(String s, String s1, String element) throws SAXException {
+        // if end of node element, add to appropriate list
+        if (element.equalsIgnoreCase("node")) {
+            nodeList.add(nodeTmp);
+            nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
+        }
+
+        if (element.equalsIgnoreCase("way")) {
+
+            //construct the Way geometry from each node of the node references
+            List<String> references = wayTmp.getNodeReferences();
+
+            for (String entry: references) {
+                Geometry geometry = nodesWithIDs.get(entry).getGeometry(); //get the geometry of the node with ID=entry
+                wayTmp.addNodeGeometry(geometry); //add the node geometry in this way
+
+            }
+            Geometry geom = geometryFactory.buildGeometry(wayTmp.getNodeGeometries());
+
+            if ((wayTmp.getNumberOfNodes() > 3) &&
+                    wayTmp.getNodeGeometries().get(0).equals(wayTmp.getNodeGeometries()
+                            .get(wayTmp.getNodeGeometries().size()-1))) {
+                //checks if the beginning and ending node are the same and the number of nodes are more than 3.
+                //the nodes must be more than 3, because jts does not allow a construction of a linear ring with less points.
+
+                if (!((wayTmp.getTagKeyValue().containsKey("barrier")) || wayTmp.getTagKeyValue().containsKey("highway"))) {
+                    //this is not a barrier nor a road, so construct a polygon geometry
+
+                    LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
+                    Polygon poly = new Polygon(linear, null, geometryFactory);
+                    wayTmp.setGeometry(poly);
+                } else {
+                    //it is either a barrier or a road, so construct a linear ring geometry
+                    LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
+                    wayTmp.setGeometry(linear);
+                }
+            } else if (wayTmp.getNumberOfNodes() > 1) {
+                //it is an open geometry with more than one nodes, make it linestring
+
+                LineString lineString = geometryFactory.createLineString(geom.getCoordinates());
+                wayTmp.setGeometry(lineString);
+            } else { //we assume all the rest geometries are points
+                //some ways happen to have only one point. Construct a  Point.
+                Point point = geometryFactory.createPoint(geom.getCoordinate());
+                wayTmp.setGeometry(point);
+            }
+            wayList.add(wayTmp);
+        }
+
+        if (element.equalsIgnoreCase("relation")) {
+            relationList.add(relationTmp);
+        }
+    }
+
+    public List<OSMNode> getNodeList() {
+        return nodeList;
+    }
+
+    public List<OSMWay> getWayList() {
+        return wayList;
+    }
+
+    public List<OSMRelation> getRelationList() {
+        return relationList;
+    }
+
+    public Map<String, OSMNode> getNodesWithIDs() {
+        return nodesWithIDs;
+    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/TextualStatistics.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/TextualStatistics.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/parsers/TextualStatistics.java	(revision 34539)
@@ -14,8 +14,6 @@
  * @author imis-nkarag
  */
-
 public class TextualStatistics {
 
-    //private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TextualStatistics.class);
     private List<String> textualList;
 
@@ -28,5 +26,4 @@
             textualList.add(nextLine);
         }
-        //LOG.info("Name occurences parsed successfully!");
     }
 
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/HistoryParser.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/HistoryParser.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/HistoryParser.java	(revision 34539)
@@ -29,5 +29,5 @@
 import org.openstreetmap.josm.tools.HttpClient;
 import org.openstreetmap.josm.tools.Logging;
-import org.openstreetmap.josm.tools.Utils;
+import org.openstreetmap.josm.tools.XmlUtils;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -48,217 +48,217 @@
  */
 public class HistoryParser {
-	private static final String OSM_API = OsmApi.getOsmApi().getBaseUrl();
-	private static final CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
-	private static final CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN;
-	private static final GeometryFactory geometryFactory = new GeometryFactory();
-	private MathTransform transform;
-	private OSMNode nodeTmp;
-
-	private final List<OSMNode> nodeList;
-	private final Map<String, OSMNode> nodesWithIDs;
-	private final List<OSMWay> wayList;
-	private OSMWay wayTmp;
-	private final String username;
-
-	/**
-	 * Constructs a new {@code HistoryParser}.
-	 * @param username user name
-	 */
-	public HistoryParser(String username) {
-		this.username = username;
-		transform = null;
-		try {
-			transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
-		} catch (FactoryException ex) {
-			Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-		}
-		nodeList = new ArrayList<>();
-		nodesWithIDs = new HashMap<>();
-		wayList = new ArrayList<>();
-	}
-
-	public void historyParse(String timeInterval) {
-
-		HashSet<String> changesetIDsList = new HashSet<>();
-
-		try {
-			String osmUrl = OSM_API + "changesets?display_name=" + username + "&time=" + timeInterval;
-			InputStream xml = HttpClient.create(new URL(osmUrl)).connect().getContent();
-			NodeList nodes = Utils.parseSafeDOM(xml).getElementsByTagName("changeset");
-
-			Logging.debug("changeset size "+ nodes.getLength());
-			for (int i = 0; i < nodes.getLength(); i++) {
-				Logging.debug("attributes of " + i + "th changeset");
-				String id = nodes.item(i).getAttributes().item(3).toString();
-				Logging.debug("id:" + nodes.item(i).getAttributes().item(3));
-				id = stripQuotes(id);
-				changesetIDsList.add(id);
-			}
-
-			for (String id : changesetIDsList) {
-				getChangesetByID(id);
-			}
-		} catch (IOException | ParserConfigurationException | SAXException ex) {
-			Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-		}
-	}
-
-	private void getChangesetByID(String id) {
-		try {
-			String changesetByIDURL = OSM_API+ "changeset/" + id + "/download";
-			InputStream xml = HttpClient.create(new URL(changesetByIDURL)).connect().getContent();
-			Node osmChange = Utils.parseSafeDOM(xml).getFirstChild();
-
-			//get all nodes first, in order to be able to call all nodes references and create the geometries
-			for (int i = 0; i < osmChange.getChildNodes().getLength(); i++) {
-				String changeType = osmChange.getChildNodes().item(i).getNodeName();
-				if (!(changeType.equals("#text") || changeType.equals("delete"))) {
-
-					NodeList changeChilds = osmChange.getChildNodes().item(i).getChildNodes();
-
-					Node osmObject = changeChilds.item(1);
-
-					if (osmObject.getNodeName().equals("node")) {
-						//node data
-						nodeTmp = new OSMNode();
-						nodeTmp.setID(osmObject.getAttributes().getNamedItem("id").getNodeValue());
-
-						//parse geometry
-						double longitude = Double.parseDouble(osmObject.getAttributes().getNamedItem("lon").getNodeValue());
-						double latitude = Double.parseDouble(osmObject.getAttributes().getNamedItem("lat").getNodeValue());
-						Coordinate targetGeometry = null;
-						Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
-						try {
-							targetGeometry = JTS.transform(sourceCoordinate, null, transform);
-						} catch (MismatchedDimensionException | TransformException ex) {
-							Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-						}
-
-						//create geometry object
-						Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
-						nodeTmp.setGeometry(geom);
-
-						nodeList.add(nodeTmp);
-						nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
-					}
-				}
-			}
-
-			for (int i = 0; i < osmChange.getChildNodes().getLength(); i++) {
-				String changeType = osmChange.getChildNodes().item(i).getNodeName();
-				if (!(changeType.equals("#text") || changeType.equals("delete"))) {
-					NodeList changeChilds = osmChange.getChildNodes().item(i).getChildNodes();
-
-					Node osmObject = changeChilds.item(1);
-					if (osmObject.getNodeName().equals("way")) {
-
-						//get way data
-						wayTmp = new OSMWay();
-						wayTmp.setID(osmObject.getAttributes().getNamedItem("id").getNodeValue());
-						// extract tags, then set tags to osm object
-						Logging.debug("\n\nWAY: " + wayTmp.getID());
-						for (int l = 0; l < osmObject.getChildNodes().getLength(); l++) {
-							String wayChild = osmObject.getChildNodes().item(l).getNodeName();
-
-							if (wayChild.equals("tag")) {
-								String key = osmObject.getChildNodes().item(l).getAttributes().getNamedItem("k").getNodeValue();
-								String value = osmObject.getChildNodes().item(l).getAttributes().getNamedItem("v").getNodeValue();
-								System.out.println("key: " + key + " value: " + value);
-								wayTmp.setTagKeyValue(key, value);
-							} else if (wayChild.equals("nd")) {
-								wayTmp.addNodeReference(osmObject.getChildNodes().item(l).getAttributes().getNamedItem("ref").getNodeValue());
-							}
-						}
-
-						//construct the Way geometry from each node of the node references
-						List<String> references = wayTmp.getNodeReferences();
-
-						for (String entry: references) {
-							if (nodesWithIDs.containsKey(entry)) {
-								Geometry geometry = nodesWithIDs.get(entry).getGeometry(); //get the geometry of the node with ID=entry
-								wayTmp.addNodeGeometry(geometry); //add the node geometry in this way
-							} else {
-								Logging.debug("nodes with ids, no entry " + entry);
-								getNodeFromAPI(entry);
-							}
-						}
-
-						Geometry geom = geometryFactory.buildGeometry(wayTmp.getNodeGeometries());
-						if ((wayTmp.getNodeGeometries().size() > 3) &&
-								wayTmp.getNodeGeometries().get(0).equals(wayTmp.getNodeGeometries()
-										.get(wayTmp.getNodeGeometries().size()-1))) {
-							//checks if the beginning and ending node are the same and the number of nodes are more than 3.
-							//the nodes must be more than 3, because jts does not allow a construction of a linear ring with less points.
-
-							if (!((wayTmp.getTagKeyValue().containsKey("barrier")) || wayTmp.getTagKeyValue().containsKey("highway"))) {
-								//this is not a barrier nor a road, so construct a polygon geometry
-
-								LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
-								Polygon poly = new Polygon(linear, null, geometryFactory);
-								wayTmp.setGeometry(poly);
-							} else {
-								//it is either a barrier or a road, so construct a linear ring geometry
-								LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
-								wayTmp.setGeometry(linear);
-							}
-						} else if (wayTmp.getNodeGeometries().size() > 1) {
-							//it is an open geometry with more than one nodes, make it linestring
-
-							LineString lineString = geometryFactory.createLineString(geom.getCoordinates());
-							wayTmp.setGeometry(lineString);
-						} else { //we assume all the rest geometries are points
-							//some ways happen to have only one point. Construct a  Point.
-							Point point = geometryFactory.createPoint(geom.getCoordinate());
-							wayTmp.setGeometry(point);
-						}
-						wayList.add(wayTmp);
-					}
-				}
-			}
-		} catch (IOException | ParserConfigurationException | SAXException ex) {
-			Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-		}
-	}
-
-	private String stripQuotes(String id) {
-		return id.substring(4, id.length()-1);
-	}
-
-	private void getNodeFromAPI(String nodeID) {
-		try {
-			String osmUrl = OSM_API + "node/" + nodeID;
-			InputStream xml = HttpClient.create(new URL(osmUrl)).connect().getContent();
-			NodeList nodes = Utils.parseSafeDOM(xml).getElementsByTagName("node");
-			String lat = nodes.item(0).getAttributes().getNamedItem("lat").getNodeValue();
-			String lon = nodes.item(0).getAttributes().getNamedItem("lon").getNodeValue();
-
-			nodeTmp = new OSMNode();
-			nodeTmp.setID(nodeID);
-
-			//parse geometry
-			double longitude = Double.parseDouble(lon);
-			double latitude = Double.parseDouble(lat);
-			Coordinate targetGeometry = null;
-			Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
-			try {
-				targetGeometry = JTS.transform(sourceCoordinate, null, transform);
-			} catch (MismatchedDimensionException | TransformException ex) {
-				Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-			}
-
-			//create geometry object
-			Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
-			nodeTmp.setGeometry(geom);
-
-			nodeList.add(nodeTmp);
-			nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
-
-		} catch (IOException | ParserConfigurationException | SAXException ex) {
-			Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
-		}
-	}
-
-	public List<OSMWay> getWayList() {
-		return wayList;
-	}
+    private static final String OSM_API = OsmApi.getOsmApi().getBaseUrl();
+    private static final CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;
+    private static final CoordinateReferenceSystem targetCRS = DefaultGeocentricCRS.CARTESIAN;
+    private static final GeometryFactory geometryFactory = new GeometryFactory();
+    private MathTransform transform;
+    private OSMNode nodeTmp;
+
+    private final List<OSMNode> nodeList;
+    private final Map<String, OSMNode> nodesWithIDs;
+    private final List<OSMWay> wayList;
+    private OSMWay wayTmp;
+    private final String username;
+
+    /**
+     * Constructs a new {@code HistoryParser}.
+     * @param username user name
+     */
+    public HistoryParser(String username) {
+        this.username = username;
+        transform = null;
+        try {
+            transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
+        } catch (FactoryException ex) {
+            Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        nodeList = new ArrayList<>();
+        nodesWithIDs = new HashMap<>();
+        wayList = new ArrayList<>();
+    }
+
+    public void historyParse(String timeInterval) {
+
+        HashSet<String> changesetIDsList = new HashSet<>();
+
+        try {
+            String osmUrl = OSM_API + "changesets?display_name=" + username + "&time=" + timeInterval;
+            InputStream xml = HttpClient.create(new URL(osmUrl)).connect().getContent();
+            NodeList nodes = XmlUtils.parseSafeDOM(xml).getElementsByTagName("changeset");
+
+            Logging.debug("changeset size "+ nodes.getLength());
+            for (int i = 0; i < nodes.getLength(); i++) {
+                Logging.debug("attributes of " + i + "th changeset");
+                String id = nodes.item(i).getAttributes().item(3).toString();
+                Logging.debug("id:" + nodes.item(i).getAttributes().item(3));
+                id = stripQuotes(id);
+                changesetIDsList.add(id);
+            }
+
+            for (String id : changesetIDsList) {
+                getChangesetByID(id);
+            }
+        } catch (IOException | ParserConfigurationException | SAXException ex) {
+            Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private void getChangesetByID(String id) {
+        try {
+            String changesetByIDURL = OSM_API+ "changeset/" + id + "/download";
+            InputStream xml = HttpClient.create(new URL(changesetByIDURL)).connect().getContent();
+            Node osmChange = XmlUtils.parseSafeDOM(xml).getFirstChild();
+
+            //get all nodes first, in order to be able to call all nodes references and create the geometries
+            for (int i = 0; i < osmChange.getChildNodes().getLength(); i++) {
+                String changeType = osmChange.getChildNodes().item(i).getNodeName();
+                if (!(changeType.equals("#text") || changeType.equals("delete"))) {
+
+                    NodeList changeChilds = osmChange.getChildNodes().item(i).getChildNodes();
+
+                    Node osmObject = changeChilds.item(1);
+
+                    if (osmObject.getNodeName().equals("node")) {
+                        //node data
+                        nodeTmp = new OSMNode();
+                        nodeTmp.setID(osmObject.getAttributes().getNamedItem("id").getNodeValue());
+
+                        //parse geometry
+                        double longitude = Double.parseDouble(osmObject.getAttributes().getNamedItem("lon").getNodeValue());
+                        double latitude = Double.parseDouble(osmObject.getAttributes().getNamedItem("lat").getNodeValue());
+                        Coordinate targetGeometry = null;
+                        Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
+                        try {
+                            targetGeometry = JTS.transform(sourceCoordinate, null, transform);
+                        } catch (MismatchedDimensionException | TransformException ex) {
+                            Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+                        }
+
+                        //create geometry object
+                        Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
+                        nodeTmp.setGeometry(geom);
+
+                        nodeList.add(nodeTmp);
+                        nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
+                    }
+                }
+            }
+
+            for (int i = 0; i < osmChange.getChildNodes().getLength(); i++) {
+                String changeType = osmChange.getChildNodes().item(i).getNodeName();
+                if (!(changeType.equals("#text") || changeType.equals("delete"))) {
+                    NodeList changeChilds = osmChange.getChildNodes().item(i).getChildNodes();
+
+                    Node osmObject = changeChilds.item(1);
+                    if (osmObject.getNodeName().equals("way")) {
+
+                        //get way data
+                        wayTmp = new OSMWay();
+                        wayTmp.setID(osmObject.getAttributes().getNamedItem("id").getNodeValue());
+                        // extract tags, then set tags to osm object
+                        Logging.debug("\n\nWAY: " + wayTmp.getID());
+                        for (int l = 0; l < osmObject.getChildNodes().getLength(); l++) {
+                            String wayChild = osmObject.getChildNodes().item(l).getNodeName();
+
+                            if (wayChild.equals("tag")) {
+                                String key = osmObject.getChildNodes().item(l).getAttributes().getNamedItem("k").getNodeValue();
+                                String value = osmObject.getChildNodes().item(l).getAttributes().getNamedItem("v").getNodeValue();
+                                System.out.println("key: " + key + " value: " + value);
+                                wayTmp.setTagKeyValue(key, value);
+                            } else if (wayChild.equals("nd")) {
+                                wayTmp.addNodeReference(osmObject.getChildNodes().item(l).getAttributes().getNamedItem("ref").getNodeValue());
+                            }
+                        }
+
+                        //construct the Way geometry from each node of the node references
+                        List<String> references = wayTmp.getNodeReferences();
+
+                        for (String entry: references) {
+                            if (nodesWithIDs.containsKey(entry)) {
+                                Geometry geometry = nodesWithIDs.get(entry).getGeometry(); //get the geometry of the node with ID=entry
+                                wayTmp.addNodeGeometry(geometry); //add the node geometry in this way
+                            } else {
+                                Logging.debug("nodes with ids, no entry " + entry);
+                                getNodeFromAPI(entry);
+                            }
+                        }
+
+                        Geometry geom = geometryFactory.buildGeometry(wayTmp.getNodeGeometries());
+                        if ((wayTmp.getNodeGeometries().size() > 3) &&
+                                wayTmp.getNodeGeometries().get(0).equals(wayTmp.getNodeGeometries()
+                                        .get(wayTmp.getNodeGeometries().size()-1))) {
+                            //checks if the beginning and ending node are the same and the number of nodes are more than 3.
+                            //the nodes must be more than 3, because jts does not allow a construction of a linear ring with less points.
+
+                            if (!((wayTmp.getTagKeyValue().containsKey("barrier")) || wayTmp.getTagKeyValue().containsKey("highway"))) {
+                                //this is not a barrier nor a road, so construct a polygon geometry
+
+                                LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
+                                Polygon poly = new Polygon(linear, null, geometryFactory);
+                                wayTmp.setGeometry(poly);
+                            } else {
+                                //it is either a barrier or a road, so construct a linear ring geometry
+                                LinearRing linear = geometryFactory.createLinearRing(geom.getCoordinates());
+                                wayTmp.setGeometry(linear);
+                            }
+                        } else if (wayTmp.getNodeGeometries().size() > 1) {
+                            //it is an open geometry with more than one nodes, make it linestring
+
+                            LineString lineString = geometryFactory.createLineString(geom.getCoordinates());
+                            wayTmp.setGeometry(lineString);
+                        } else { //we assume all the rest geometries are points
+                            //some ways happen to have only one point. Construct a  Point.
+                            Point point = geometryFactory.createPoint(geom.getCoordinate());
+                            wayTmp.setGeometry(point);
+                        }
+                        wayList.add(wayTmp);
+                    }
+                }
+            }
+        } catch (IOException | ParserConfigurationException | SAXException ex) {
+            Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private String stripQuotes(String id) {
+        return id.substring(4, id.length()-1);
+    }
+
+    private void getNodeFromAPI(String nodeID) {
+        try {
+            String osmUrl = OSM_API + "node/" + nodeID;
+            InputStream xml = HttpClient.create(new URL(osmUrl)).connect().getContent();
+            NodeList nodes = XmlUtils.parseSafeDOM(xml).getElementsByTagName("node");
+            String lat = nodes.item(0).getAttributes().getNamedItem("lat").getNodeValue();
+            String lon = nodes.item(0).getAttributes().getNamedItem("lon").getNodeValue();
+
+            nodeTmp = new OSMNode();
+            nodeTmp.setID(nodeID);
+
+            //parse geometry
+            double longitude = Double.parseDouble(lon);
+            double latitude = Double.parseDouble(lat);
+            Coordinate targetGeometry = null;
+            Coordinate sourceCoordinate = new Coordinate(longitude, latitude);
+            try {
+                targetGeometry = JTS.transform(sourceCoordinate, null, transform);
+            } catch (MismatchedDimensionException | TransformException ex) {
+                Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+            }
+
+            //create geometry object
+            Geometry geom = geometryFactory.createPoint(new Coordinate(targetGeometry));
+            nodeTmp.setGeometry(geom);
+
+            nodeList.add(nodeTmp);
+            nodesWithIDs.put(nodeTmp.getID(), nodeTmp);
+
+        } catch (IOException | ParserConfigurationException | SAXException ex) {
+            Logger.getLogger(HistoryParser.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    public List<OSMWay> getWayList() {
+        return wayList;
+    }
 }
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/TrainByUser.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/TrainByUser.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/TrainByUser.java	(revision 34539)
@@ -701,5 +701,5 @@
     protected void done() {
         try {
-            System.out.println("Training process complete! - > " + get());
+            get();
             firePropertyChange("progress", getProgress(), 100);
             setProgress(100);
Index: applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/UserDataExtractAndTrainWorker.java
===================================================================
--- applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/UserDataExtractAndTrainWorker.java	(revision 34144)
+++ applications/editors/josm/plugins/OSMRecPlugin/src/org/openstreetmap/josm/plugins/osmrec/personalization/UserDataExtractAndTrainWorker.java	(revision 34539)
@@ -40,5 +40,4 @@
     private final boolean topKIsSelected;
     private final LanguageDetector languageDetector;
-    private int userTrainProgress = 0;
 
     public UserDataExtractAndTrainWorker(String inputFilePath, String username, Integer days, boolean byArea, boolean validateFlag,
