fixes for incorrect junctions and pinched loops