Tried fixing a bug occurring with invalid polygons