I had a similar issue regarding code P0320, my 98 auto TJ run rough on idle or gear reving up by itself, and usually the condition went away after some driving... so before I spend 100+ bucks on a new crankshaft position sensor I plugged it off and removed it to check its condition (I was going to diagnose it but I tried manually adjusting first), I gave it a clean with a rag checking the condition of the wires and connectors and since nothing looked damaged I installed it back on... when I tried to tighten the screw back on I noticed that the screw was really short and could not hold tightly the CPS, so I replaced the screw... first I just let the CPS go in all the way and tighten the screw... when I turned the engine the reving up was still there, then I tried placing the CPS all the way out from the hole as possible and tighten the screw again (the CPS hole has a slot) and VOILA! the condition was no longer there... but the code and check engine light where still on... I drove around for a while with the light still on but no reving condition... the next day I started the jeep and the check engine light was gone!!!
PS. The screw I had on and had replaced was M10 not a 7/16...
I think I got lucky but you never know if you don't try!