If the codes you had were for a faulty lambda sensor then you have to find which of the 4 it is.
You say the engine didn't run well and the exhaust was not good. That suggests a pre-cat sensor as they are the ones that tell Gems how to alter the management. The post-cat sensors ( as I described earlier) just check the exhaust AFTER the cat has cleaned the exhaust gas. Basically checking that the cats are ok.
The lambda sensors are often hard to remove as they seize in place and getting a socket / spanner to fit is a problem. The multi pin connector and wires stop a socket or ring spanner fitting. Open ended spanners can slip off due to a small space to fit to the hex on the sensor. If you are CERTAIN which sensor is faulty you could cut the wires close. Suggested options include cutting a slot in a socket to let the wires stick out or a cut in a ring spanner to do similar. Spraying release fluid is a must! Last resort is a blowtorch! Even removing the cat to work on a bench would help BUT you then have to deal with clamps and resealing after refitting.
Good luck!