Have you cleaned the idle control valve? It should rattle when shaken. Don't poke anything inside it, just hose it out with an appropriate solvent (brake cleaner?).
Ed in San Jose '97 540i 6 speed aspensilber over aubergine leather. Build date 3/97. Golden Gate Chapter BMW CCA Nr 62319.