Sounds like it could be the MAF. Have you checked to see if the sensor is dirty? Sometimes (rarely) cleaning the sensor will at least improve the surging/idle problem. Also, does this "clicking" sound sound a bit like a rod knock? If so and if it does actually go away after warm up figure that to just be a normal Subaru thing.
I had a similar "surge" issue with my 98 Outback. Meaning that the surge was more like a flat spot in acceleration under load. It would often go away after warm up but was definitely prevalent between 2000-3500 rpm. I replaced just about everything (coil, plugs, wires, MAF, PCV, engine grounds, battery and coolant temp sensor) but it still persisted. After a bit more research I found that it could be the ECU that causes this. I bit the bullet and got a replacement - note you'll need to get the vin programmed into the replacement. Replacing the ECU fixed the "surging" for me. The ECU and programming ran me $450.