You could adjust the TPS and see if the code resolves. TPS may not be busted, just out of whack. If so the MIL can sub for a meter.
I'm gonna back pedal and say it's possible the 31 could cause that richness. Unlikely though. Besides, the EFI system usually isn't responible for this kind of thing. It's still always best to fix codes first though. And you still haven't said under what conditions it's happening.
Lastly, that you have both AFM codes suggests a wiring issue. Gonna need the DMM for that.