Make sure you spend some time researching the codes and the diagnostics needed to test them out. I absolutely hate when people randomly throw parts at a vehicle hoping they get lucky. This is especially true if money is tight as the last thing you need to do is buy stuff you don't need. Basic diagnostics and tests are usually pretty simple to do if you spend a few minutes reading up on them.
Good example is the oxygen sensor code. The code is saying the sensor is reading excessive fuel in the exhaust (engine is running rich). It is not saying the sensor is bad and needs replaced.......granted, the reason it is reading a rich condition COULD be a bad sensor, but it could be because the engine actually is running rich because of another reason. In my experience at least 75% of the oxygen sensor codes are caused by something other than the actual sensor. Always check the wiring and connections first.
With those two codes and the symptoms described, I would concentrate on an ignition related issue. Poor or intermittent ignition will cause the engine to run rich, which will set off the oxygen sensor code. With the issue being intermittent and correcting itself after a key cycle I would concentrate on checking all the wiring and connectors first. A lot of times just a very quick loss of a signal (wire briefly shorts out or a connector wiggles loose for a second) will freak out the system until it is reset by the key cycle.