I am experiencing a very similar problem with my 523i. sometimes its fine and sometimes the engine is very "lumpy" when accelerating. It has been known in the past few days to just cut out when its on idle.
Someone suggested on this thread a Cam Sensor, not thought of that so will check that.
Any other suggestions???