Aight.... a few words on gas mileage..... lets think here... hmmm
First thing that comes to mind.... O2 sensors.... the entire O2 sensor system... I've seen more than one car... absolutely suck the gas because of a faulty O2 sensor... weather or not it has failed might be the problem... if it hasnt exactly failed yet.. telling the OBD to give you a CEL then it might be giving you a bad signal witch will lead to a bad fuel ratio... check into that... you can test them out... with a voltmeter
Second thing... which IMO goes back to just good car maintenance.... fuel filters... air filters and oil filters.... make sure they are upto date and within a change cycle... BTW... if your using shitty oil... then your probably getting under par results... friction causes slower movement with the same amount of power put forth to the same part. Physics...
Another main contributor of bad gas mileage is spark plugs.. using the right ones.. and spark at the right interval for BMW's crazy distributor-less ignition system... is rather important... a degraded plug will do some work on gas and power alone.
Another fault path would be to check your injectors... if old and rather crusty... they are done.. and need to be replaced...
Just a few to note of.... and to add to the topic...
Peace,
Les