How are you adjusting the idle? You should know better than to try and adjust it manually by now...
And wadda ya mean gotta be the TPS? You Haven't checked that yet? BTW, you shouldn't set the timing without the car at idle. From what I understand, you can do it, but when in diagnostic mode the ECU doesn't set the timing advance to a flat 10?BTDC, it merely stays on the default (RPM based) map with no adjustments per the trim sensor inputs.
Oh, and if you keep getting a code 51 then check the damned IDL switch already! sheesh...