Thanks everyone for suggestions. The plugin that I used was attaché. According to docs, it was supposed to swap-in-place the attachments using the OLD attachment id (which is good, because it allows notes to remain the same). but in my particular usage it created NEW attachment ids which invalidated the old notes.