Just went through this myself, code 31 problems. Everyone calls code 31 the wastegate code, but that's not really right, there's a lot more stuff on that circuit than that.
The wiring leaves the ECM/SOL fuse and goes to a switch on the brake pedal. It then splits, one branch goes to the TCC solenoid and the other branch goes a bunch of different places - wastegate, a/c, egr, cannister purge, one other spot I think. I seem to remember 6 places total.
My code 31 turned out to be caused by the TCC wiring. The last guy in the tranny had run the wiring through all 3 clips and it was stretched tight as a drum. Wire had rubbed through and was shorted out on the valve body. Took a while troubleshooting with a multimeter to find that one. Mine would blow the fuse as soon as I turned the key since it was on the hot side of the solenoid.
John