I may have found the problem, or at least a problem. There is a solenoid or switch that prevents the tractor from starting unless it is in neutral. The wire on the switch, that goes into differential housing, was hanging by a thread, and then fell off. So the tractor won't start at this point. I tried to take the switch out, and a torpedo looking piece came out of the differential housing and hydraulic oil was pouring out, so I reinstalled it without the torpedo piece temporarily. Is it possible that the frayed wire on that switch could have been causing the tractor to stall at times?
Edit: It may be the PTO safety switch, not the neutral safety switch.
Edit: I bypassed the switch and got the tractor started again, but it is still doing the same thing with the stalling. Have not done the baby powder test to see if there is a leak. I guess that is next. Worried it might be something more serious.