Fix intersection for the z-sorting