add missing clause & more safely close polygons