Strange failsafe behavior
2005 BMW 325i
Ok, so when I start this car, I MUST put it in reverse or drive within 5 seconds or else it will go to transmission fail safe mode. If I quickly put it in gear after starting, it will drive great and seem mechanically fine. But even after driving for awhile, if it's then put in park more than 5 seconds, the car goes into failsafe and motor changes to be a little more rough sounding. Once in failsafe mode, I have to turn the car off and lock the doors for 10 seconds so I can try again (works 100% of the time). I also had a brake light and traction control light come on for a day the then never came back. And occasionally (once a week or less) the car will bog down like it has a blown head gasket or something, then I have to turn the car off and start it again and it runs fine. Does this sound electrical? I had codes read at oriellys and I got tons of o2 sensor fails and cylinder 4 & 5 misfires, but I dont think it's misfiring unless it's during that occasional bog down. While driving it runs so smooth and quick and gets great gas mileage.
I looked for corrosion around the fuse box and didn't see any. I'm thinking I need to try:
MAF Sensor cleaning/replacement
Any other ideas?
Thanks for any help.