Toyota Repair: Hesitation/Stumble Rough running, gas milage, ground connections


Question
What to look for & how to correct?

Subject began at about 245K Miles. No previous problems. Toy. 94 4x4 22RE Manual. Replaced engine at 250K with "New" S&S Engine. Inspected Injectors, replaced gromets, new radiator, cluch, etc... Now at 268K, the subject is still here,  had the 02 sensor replaced... slight improvement for a few miles. Began looking for more info on problem... Discovered method to look for error codes, shorted the diag.term as directed, turned on the key,  sequence !!!! !,  !!!! !,  book indicates TPS sensor,  Bought new TPS, disconnected Batt. for 1 Minute. Connected New TPS,  repeated Check, still gitting error code. Disconnect the TPS,  and run TPS un-connected. No more Hesitation/Stumble or Rough running. Wow,  just disconnect and it purrs like a kitten.(seems to indicate mechanics OK)  Gas Milage is poor. Connected TPS back up, Runs bad again.  Getting 5v from VC @ TPS connector, Monitored VTA at connector while connected, approx 1v - 4.6v through throttle range. Checked this with ground on E2, and - Batt. term. Why would I get the TPS error code? why does the subject go away when the TPS is not connected? If I have the correct imput voltage at TPS connector VC, and TPS output looks to be in range for VTA, resistence should be good. I'm thinking ground,  could the ECM be providing intermitten E2 grounding. I have only performed these checks with the engine not running.  Could running the engine provide a difference in my results?  Truck is driven daily 120 Miles on the freeway. I love this truck,  help!

Answer
This could be a ground problem, check the E2 ground connections near the ECU and check the ECU connectors for any corrosion and clean them as needed, try substituting a known good ECU.
There are some soldered connections inside the engine wire harness, these can get corroded and cause problems, you may have to open the wire harness between the engine and where it enters the firewall and check the soldered connections(splice points), a wiring diagram would help to locate these, if you need one give me an email address and I can send a copy of the engine control EWD.