First have the battery tested in order to make sure it doesn't need to be replaced. Next replace the O2 sensor and diagnose/repair the coolant temp issue. After all of that, check to see if and codes remain and how it's running.