Try to deal with duplicate names in arguments gracefully
Fix highlight and rewrite weirdness

The underlying cause of much of the strange behaviour (including
highlighting not working properly, and strange things during rewrites)
seems to be down to bad parsing of attached rewrites: the new graph was
never parsed out properly.

Of course, fixing this exposed a slew of other bugs.  Things *mostly*
seem to behave sensibly now.  It is possible that this will fix
issue #109, but I can't reliably reproduce it any more, so I'm not
certain of that.
Fix position update on paste

Fixes #107