Code #5 is for the O2 sensor.
I am 100% convinced that you need to replace your engine wiring harness.
You have all of the symptoms
Rough idleing, missing, stumbling, random and arbitrary fault codes.
It's your wiring harness. About $550 for the part and 2.5-3 hours labor.
2001 E430, Bourdeaux Red, Oyster interior.
1973 280SE 4.5, 170,000 miles. 568 Signal Red, Black MB Tex. "The Red Baron".