implemented more consistent segments intersections (is_last used also for non-collinear segments), not needed checks for duplicated IPs commented out