I had the same issue until my transmission malfunction light came on...I took it to several Transmission shops only to find that my transmission oil pan was leaking and had been for sometime. The filter, pan, and transmission gasket come as an assembly so all of that was replaced. When the shop drained by transmission I had 2 quarts out of 2 gallons. I was lucky the transmission did not burn up. Anyway...I had new fluid, and the pan, filter, gasket assembly replaced for $650 and once the computer reprogrammed itself my car is good as new.
at 35 to 40 shifts in and out of overdrive: Under normal excelleration, this is the normal speed for the converter to lock up...unless it does what I call "being busy". In and out and in and out, repeatedly. If this is what's happening, you have a bad torque converter pressure switch.
A year late tot he party but i had the same issues with my 2004 545i. Really concerned me and mechanics could not recreate or pinpoint the cause. Along with this I was having massive electrial issues. Eventually(well over a year) it was determined that I had a faulty alternator. Once that was replaced the banging(transmission issues at 35/40mph) went away. Have your alternator replaced or checked.