X 2 on sounds like Crank Position Sensor. Do a google search on "Jeep 4.0 CPS troubleshooting". There is all kinds of information out there on how to read your CPS out with a multi-meter. Un hook the plug on driver's side of fire wall between the motor and brake booster. It takes about 2 minutes to figure out if it's bad or not. My son just bought a CPS for is 87 XJ at our friendly neighborhood Autozone. It was like $45. i hope this helps.
Brian "Buck" Buchanan, U.S. Navy Chief Petty Officer (RETIRED) - 87 XJ Laredo, Ol' Red - 8.5" Rusty's Offroad/Rough Country lift, D30 trussed and D44 high clearance shock mounts, 4.56's, Aussies, Chromos and Disc Brakes front and rear, JCR Offroad Belly Skid Plate and Stage 2 Rock Sliders, Off Road Fab Winch Bumper and Quarter panel Guards, Liberal Front Wheel Well trimming and Rear Wheel Well Cut N Fold, 35" Goodyear MTR with Kevlars, Cobra CB and AW4 First Gear Lock Crawl switch, SYE, Stock XJ driveshafts front and rear and Milemarker SEC8000 Winch.
91 XJ Sport (Old Gray Jeep) - Layed to Rest (04-01-13)
87 XJ Laredo (Ole Red) - (My Jeep)
87 XJ Base (The Boys Jeep)
96 XJ Country (The Daughters Jeep)
08 Dodge Charger R/T (The Wifes Ride)
04 Silverado 2500HD Duramax/Allison (tow rig)