To be honest, damned near everything.
I've shored up my frame completely, and replaced all of the following parts related to stability and steering:
Rear shocks
Rear sway bar links and bushings
Rear upper and lower control arms
Front sway bar links
Front upper and lower ball joints
Inner and outer tie rods (x2)
However....the thing that made the biggest difference... BY FAR... was tires. Get good tires. I had tires that were manufactured in 2010. They looked great, the tread was totally fine... but they were wobbly as hell. I got some Michelin Defenders, and on the drive home from Discount Tire I couldn't believe the difference it made, and that was after I'd already replaced all of the rear components.
Keep in mind that 'on rails' is very relative. I'm talking about having a feel for the road, driving at any speed and on any road condition feels safe and predictable. If you want to more literally be on rails, obviously you have to be in a low sports car not a wobbly-even-when-new tall SUV
Now all that said, when I got my most recent frame repairs done, there was a noticeable decrease in the slight wobble/swerve I would get while shifting gears (mine is a 5-speed), especially the freeway shift from 4th to 5th.
I know I stated earlier in the thread that the control arms were the reason it felt stable. It DID help, but nothing helped as much as new tires.