I'm with MASSIVE boost leak + Push/pop starting a stalled car (or driving with a broken speedo cable and a bad distributor) + Stepping on the throttle while in diagnostic mode (that's your code 51, yes, it's a real code) + ..... well, something else.... <nevermind this bit.... no code 44 according to all the Toyota references I care to dig through at the moment..>.
These could all be old codes and you're just getting freaked out because you're hitting fuel cut and possibly over boosting. What's your AFR when the engine freaks and what is the boost reaching?
An O2 sensor wouldn't cause any of this, the ECU doesn't reference it at high loads.
And no, like Frisbee said, don't replace the knock sensor... see aren't you glad you stopped dicking around?