Fix stack overflow in CreatePath