PCM failure is very rare. Problem solve for the trouble codes. The right turn shut-off and rainy day issues very strongly suggest wiring/wire connector/ground issues Suspect that the cam sensor needs to be synchronized. Read this ->
http://jeep.blackonyx.net/pdfs/jcss.pdf
P0340 JEEP - Camshaft Position Sensor Circuit
Possible causes
- Faulty Camshaft Position Sensor
- Timing chain stretched or jumped
- Camshaft Position Sensor harness is open or shorted
- Camshaft Position Sensor circuit poor electrical connection
- Dead (Weak) battery
P1391 JEEP - CMP or CKP Signal Intermittent Condition
Possible causes
- Faulty Camshaft Position (CMP) Sensor
- Camshaft Position (CMP) Sensor harness is open or shorted
- Camshaft Position (CMP) Sensor circuit poor electrical connection.
Potential Fixes:
Fix #1:
Inspect your wire harnesses for damaged wires, chafed insulation, or failed wire splices. Use a volts/ohms multi-meter to check the resistance of the ground wire circuits from each sensor. Replace corroded ground wires/connectors and clean ground wire connection points.
Fix #2:
Timing may off. Re-index the distributor/cam sensor per the FSM instructions, or replace faulty distributor/cam sensor pickup module.
A mis-indexed distributor/cam sensor may exhibit surging, light bucking or intermittent engine misfiring. This will most likely occur when the vehicle is at operating temperature and under a light load at approximately 2,000 rpm. The proper indexing procedure must be used as outlined in the service manual.