My first guess when I read this was the terminals. Next question, how old is the battery. If it older then 5 years, it's on it's last legs. Some have gone as far as 8 years, but I replaced mine at 5 to be safe.
You have in effect reset the ECU a few times now. It is re-learning. The idle should become normal in a short time.
174,000+ miles, 5/20/12 new ej257 short block, 8/20/11 installed VF52 turbo, @20.8psi, 280whp, 300ftlbs. Also CHECK YOUR OIL, these cars use it.