Backport various fixes from !3479 (fix linking with measure LPE, fix multiple copy-pastes, fix copy-paste clones to new document)
Backports part of Jabier Arraiza's fix from a5f8da8b
Fix #387 (closed), #1743 (closed), #3035 (closed)
/cc @jabiertxof could you review?
Update: Jabier's taken a quick look at it, but he's pretty busy too. From DMs:
I see your code seems tiny and correct,
Edited by Nathan Lee