I know these issues all too well. I would definitely clean the idle control valve (here's the write-up
http://forums.bimmerforums.com/forum...d.php?t=454501 , check for leaks (with the car running, spray brake cleaner around the tb, intake, hoses, etc - if there's a surge, then its a leak), if that seems to work, check the AFM - I have one for sale BTW. Let me know if this works...