Well if the system is a 90' (like my 5.0) then the "throtle body airflow" scalar will not be correct with a 351. This setting as well as the map for the IAC flow and several others will not be correct. These change with displacement, cam, idle speed, etc... The changes are many of what custom chip burners do to get good idle quality on aftermarket engines (dyno time is well worth the money). These are the figures which tell the computer how much air is being sucked in by the motor at idle, and how much the IAC is supposed to add to achieve a given idle rpm. For instance the IAC also holds a higher idle setpoint until you get below 7mph in order to keep the motor from dying on rapid deceleration. Check tweecer.com for these and many more fun pitfalls of latemodel computer tuning issues...
The stock program also specs out a 672 rpm idle, now if your engine can not idle at 672 (many good cams can not), then the computer will have an embolism trying to get it down there. Also be advised if the IAC does not give the controll the computer wants then it uses engine timing to do the job. (so don't be suprised if your timing is all over the place at idle) I set my idle speed to 880 rpm in the program (tweecerRT) and this solved most of my idle issues.
Another trick that the latemodel guys use sometimes is to rotate the MAF, as turbulance through it can sometimes cause a problem. This may not be possible/practical in your case since its inside the aircleaner.
The surge can also be caused by the O2 sensors cooling off at idle (with long tubes) and causing a rich condition (but this *seems to be* most common on 94/95 systems). If you have shorties, this is unlikely.
Also check the wire in your MAF to ensure that its clean (isopropyl alcohol ... GENTLY!!!!!) If you run a KnN, the oil film from the filter coats the wire in the MAF and screws up the readings to the computer.
The TPS voltage that you are looking for is LESS THAN 1.0vdc. (k.o.e.o : key on engine off) Anything above 1 puts the computer into "part throtle" mode. (I run .90 at the sensor, some say .97-.99 but what if your meter isnt exactly the same as the computer...?!?! )
The coolant temp sensor can also contribute, as well as the air charge temp sensor, but these are fairly rare. And of course a bad O2 sensor... but the codes will show that (trouble shoot the first code first. dont start with the last one and work backward)
The other ideas listed above are valid, but I thought I would add some not mentioned yet... and f.y.i. the dreaded "surge" is fairly common with cams, heads, etc... untill the computer is tuned.
Good luck, hope its just a bad sensor.
Dave-