need to fix edge cases in polygonization code