Index: trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
===================================================================
--- trunk/src/org/openstreetmap/josm/data/osm/NoteData.java	(revision 8222)
+++ trunk/src/org/openstreetmap/josm/data/osm/NoteData.java	(revision 8224)
@@ -3,8 +3,8 @@
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
-import java.util.List;
 import java.util.Map;
 
@@ -15,4 +15,6 @@
 import org.openstreetmap.josm.data.notes.NoteComment;
 import org.openstreetmap.josm.gui.JosmUserIdentityManager;
+import org.openstreetmap.josm.tools.Predicate;
+import org.openstreetmap.josm.tools.Utils;
 
 /**
@@ -23,5 +25,5 @@
     private long newNoteId = -1;
 
-    private final List<Note> noteList;
+    private final Storage<Note> noteList;
     private Note selectedNote = null;
     private Comparator<Note> comparator = DEFAULT_COMPARATOR;
@@ -85,18 +87,11 @@
 
     /**
-     * Construct a new note container with an empty note list
-     */
-    public NoteData() {
-        noteList = new ArrayList<>();
-    }
-
-    /**
      * Construct a new note container with a given list of notes
      * @param notes The list of notes to populate the container with
      */
-    public NoteData(List<Note> notes) {
-        noteList = notes;
-        Collections.sort(notes, comparator);
+    public NoteData(Collection<Note> notes) {
+        noteList = new Storage<>();
         for (Note note : notes) {
+            noteList.add(note);
             if (note.getId() <= newNoteId) {
                 newNoteId = note.getId() - 1;
@@ -107,8 +102,18 @@
     /**
      * Returns the notes stored in this layer
-     * @return List of Note objects
-     */
-    public List<Note> getNotes() {
-        return noteList;
+     * @return collection of notes
+     */
+    public Collection<Note> getNotes() {
+        return Collections.unmodifiableCollection(noteList);
+    }
+
+    /**
+     * Returns the notes stored in this layer sorted according to {@link #comparator}
+     * @return sorted collection of notes
+     */
+    public Collection<Note> getSortedNotes() {
+        final ArrayList<Note> list = new ArrayList<>(noteList);
+        Collections.sort(list, comparator);
+        return list;
     }
 
@@ -155,8 +160,22 @@
      * @param newNotes A list of notes to add
      */
-    public synchronized void addNotes(List<Note> newNotes) {
+    public synchronized void addNotes(Collection<Note> newNotes) {
         for (Note newNote : newNotes) {
             if (!noteList.contains(newNote)) {
                 noteList.add(newNote);
+            } else {
+                final Note existingNote = noteList.get(newNote);
+                final boolean isDirty = Utils.exists(existingNote.getComments(), new Predicate<NoteComment>() {
+                    @Override
+                    public boolean evaluate(NoteComment object) {
+                        return object.getIsNew();
+                    }
+                });
+                if (!isDirty) {
+                    noteList.put(newNote);
+                } else {
+                    // TODO merge comments?
+                    Main.info("Keeping existing note id={0} with uncommitted changes", String.valueOf(newNote.getId()));
+                }
             }
             if (newNote.getId() <= newNoteId) {
@@ -165,7 +184,4 @@
         }
         dataUpdated();
-        if (Main.isDebugEnabled()) {
-            Main.debug("notes in current set: " + noteList.size());
-        }
     }
 
@@ -256,6 +272,5 @@
 
     private void dataUpdated() {
-        Collections.sort(noteList, comparator);
-        Main.map.noteDialog.setNoteList(noteList);
+        Main.map.noteDialog.setNotes(getSortedNotes());
         Main.map.mapView.repaint();
     }
Index: trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java	(revision 8222)
+++ trunk/src/org/openstreetmap/josm/gui/dialogs/NotesDialog.java	(revision 8224)
@@ -13,4 +13,5 @@
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
 
@@ -186,5 +187,5 @@
             noteData = ((NoteLayer)newLayer).getNoteData();
             model.setData(noteData.getNotes());
-            setNoteList(noteData.getNotes());
+            setNotes(noteData.getSortedNotes());
         }
     }
@@ -193,7 +194,4 @@
     public void layerRemoved(Layer oldLayer) {
         if (oldLayer instanceof NoteLayer) {
-            if (Main.isDebugEnabled()) {
-                Main.debug("note layer removed. Clearing everything");
-            }
             noteData = null;
             model.clearData();
@@ -209,5 +207,5 @@
      * @param noteList List of notes to display
      */
-    public void setNoteList(List<Note> noteList) {
+    public void setNotes(Collection<Note> noteList) {
         model.setData(noteList);
         updateButtonStates();
@@ -265,5 +263,5 @@
 
         public NoteTableModel() {
-            data = new ArrayList<Note>();
+            data = new ArrayList<>();
         }
 
@@ -281,5 +279,5 @@
         }
 
-        public void setData(List<Note> noteList) {
+        public void setData(Collection<Note> noteList) {
             data.clear();
             data.addAll(noteList);
@@ -315,5 +313,4 @@
             dialog.showNoteDialog(tr("Add comment to note:"), NotesDialog.ICON_COMMENT);
             if (dialog.getValue() != 1) {
-                Main.debug("User aborted note reopening");
                 return;
             }
@@ -337,5 +334,4 @@
             dialog.showNoteDialog(tr("Close note with message:"), NotesDialog.ICON_CLOSED);
             if (dialog.getValue() != 1) {
-                Main.debug("User aborted note closing");
                 return;
             }
@@ -377,5 +373,4 @@
             dialog.showNoteDialog(tr("Reopen note with message:"), NotesDialog.ICON_OPEN);
             if (dialog.getValue() != 1) {
-                Main.debug("User aborted note reopening");
                 return;
             }
Index: trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 8222)
+++ trunk/src/org/openstreetmap/josm/gui/layer/NoteLayer.java	(revision 8224)
@@ -13,4 +13,6 @@
 import java.text.DateFormat;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
 import java.util.List;
 
@@ -56,5 +58,5 @@
      * @param name The name of the layer. Typically "Notes"
      */
-    public NoteLayer(List<Note> notes, String name) {
+    public NoteLayer(Collection<Note> notes, String name) {
         super(name);
         noteData = new NoteData(notes);
@@ -63,6 +65,5 @@
     /** Convenience constructor that creates a layer with an empty note list */
     public NoteLayer() {
-        super(tr("Notes"));
-        noteData = new NoteData();
+        this(Collections.<Note>emptySet(), tr("Notes"));
     }
 
@@ -97,5 +98,4 @@
     @Override
     public boolean requiresSaveToFile() {
-        Main.debug("associated notes file: " + getAssociatedFile());
         return getAssociatedFile() != null && isModified();
     }
Index: trunk/src/org/openstreetmap/josm/io/NoteReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/NoteReader.java	(revision 8222)
+++ trunk/src/org/openstreetmap/josm/io/NoteReader.java	(revision 8224)
@@ -195,5 +195,4 @@
         @Override
         public void endDocument() throws SAXException  {
-            Main.info("parsed notes: " + notes.size());
             parsedNotes = notes;
         }
@@ -210,5 +209,5 @@
                 return sdf.parse(dateStr);
             } catch(ParseException e) {
-                Main.error("error parsing date in note parser");
+                Main.error(e);
                 return null;
             }
