A vacuum/air leak, a misbehaving PCV system, leaky intake gaskets, even an exhaust leak, all could cause an engine to run lean.
A dirty MAF can cause an engine to run lean. See:
Cleaning the MAF sensor.
Some of the 1997 4.0L's had problems with the fuel supply manifold gasket (not real hard to replace, btw):
Article No. 98-6-8
LIGHT TRUCK: 1997 AEROSTAR, RANGER 4.0L ENGINES ONLY
ISSUE:
A rough idle, stalling at an idle and/or Diagnostic Trouble Codes (DTCs) P0171, P0174, P1131, and/or P1151 may be stored in memory on some vehicles with a 4.0L engine. This may be caused by the gasket located between the fuel rail and lower intake manifold losing its compressive loading and becoming drawn into the intake manifold runners resulting in a vacuum leak.
ACTION:
Replace the fuel rail-to-intake manifold paper gasket with a revised gasket.
....