Extract Way#replaceNode
Fix circularize boundary cases (fixes #494)

There are still more boundary cases even farther out. But this is
probably sufficient for the real world.