Fixed MergePoints, added supporting functions