Depends when you are experiencing the flat spots.
It the engine dies when booted say in 2nd gear but recovers then this would be the in tank fuel pump. Particluarly prevalent with less than a 1/4 full tank.
If it is missing when loaded up particularly at low rpms but clears at higher rpms then this is highly likely to be leads. You can replace the plugs, dizzy cap etc but most avoid changing the leads which are quoted at £440 from BMW. The high cost is due to BMW having to make these up and hence it is mostly labour.
You can purchase all the columns, connectors and wire direct from BMW. Dizzy end plugs at £5.50 ,connectors a few pence. Most expensive bits are the columns at £26 each. You can make up a full set for £200.
Post some more detail about you specific problem for more.
PS it is not usually the air flow meter and as yours is new it will not be this.
Ian