Modifications to handle better flat triangles cases