Implement vertex mergining.

* Again, purely based off SmallVCM code.