There's some sort of interaction between the O2 sensor and the trans that can cause wierd problems like this. Inspect the O2 wiring and consider replacing the sensor if it's been a while.