Improve migration to update Node.tagnames and handle duplicate tags. Issue #315.