Slasher is right on this, a long turn, or sweep elbow isn't going to help. You need to go back a bit further on the horizontal pipe, cut it clean, and use a "slip coupling" to make the repair. couple of tips on this. First, to make a clean cut line around the pipe, wrap the pipe with a sheet of paper, like a long piece of legal pad paper. Once the paper is squarely wrapped around, and the edge lines up, you can take a Sharpie, and trace the edge of the paper. This will create a perfectly square cut line. A slip, or repair, coupling is a little looser than a normal one, and it has no center stop. You slide it on to the existing pipe, lather both sides of the pipe joint, heavily, with PVC cement, then slide the coupling in place, with a twisting motion. Remember to mark the pipe so you know that your coupling is centered over the joint. You can replace the flange with a stainless steel one, which will eliminate the rust issue.