Refactoring Plane Topology

Replaced old global distance functions by plane topology