It will revert to default open loop mode for fueling, that is why your idle smooths out. The code 13 means the O2 is refusing to talk to the ecm. I know you replaced the O2 sensor, but it's not uncommon for people to get several bad bosch sensors in a row. My bosch sensor came with a year warranty, I would take full advantage of it if I didn't want to shell out for the Delco unit (which I plan on doing anyway) Are your cross counts lazy or even moving? Basically for that code either the sensor is lazy and it screws up the air/fuel ratio, which causes your idle problem, or the ground for the 02 is crappy, which causes the sensor to read out of whack, which will also screw up the A/F ratio.
Make sure to disconnect the orange power wire to the ecm when making changes or unplugging stuff, in order to clear pre-existing codes and start with a fresh reference point.
As an aside, I found the following statement by gofstbuick in a similar old thread in regards to a code 13: "warm the engine up to operating temp and take a volt reading at the O2 sensor. If the reading is locked, it is possible that your O2 sensor is dead. You can also see if the computer has the ability to respond to the sensor signal by: grabbing a hold of the signal wire (in one hand ) and touching the positive terminal of the battery with your other hand, then look (on your scanner) to see if the O2 volts are rising and the engine begins to run lean. So that coupled with a locked reading probably points to a dead sensor."
and just for the hell of it...
http://www.gnttype.org/maint/malf.html#13
one of the conditions is that TPS must be over 6% above idle...is yours still in the correct range? You can try lowering it a bit more to see if it helps, then readjust IAC..
This is all I have for now...I am not sure where exactly the O2 ground ring terminal goes, but I am going to try to go through the manual to find the color of the wire if possible. Maybe try a thorough search in the general section for fresh ideas.
Mike