I had this stalling problem, checked the code and it was air flow meter(MAF). I tried to go cheap and get a used one from a salvage yard(never again). I found out it was bad after I broke down and bought a new one from Subaru and it cranked right up.
Mike