Reworked the triangle-plane detection