the phrase for, when you say something inappropriate, realize the mistake, and then improvise to make it less inappropriate

Solution 1:

It sounds like back-pedalling (or backpedalling, without the hyphen, either is acceptable, or backpedaling, with one 'l').

http://www.dictionary.com/browse/backpedalling

verb (used without object), back-pedaled, back-pedaling or (especially British) back-pedalled, back-pedalling.
1.  to retard the forward motion by pressing backward on the pedal, especially of a bicycle with coaster brakes.
2.  to retreat from or reverse one's previous stand on any matter; shift ground: to back-pedal after severe criticism.
3.  Boxing. to retreat from an opponent, especially by stepping rapidly backward.

eg, from https://www.themuse.com/advice/how-to-backpedal-out-of-a-bad-conversation-without-making-things-worse

Oh, uh, I didn’t mean to… well, what I meant was, um, well, uh… that didn’t come out right. What I’m trying to say is, uh…

Sound familiar? We’ve all been there—those panicky moments when your stomach jumps into your throat because you let a few wrong words fly out of your mouth before you even had a chance to think about exactly what you were saying. Now you’re stuck trying to backpedal and retract that foolish statement without causing even more damage. And, that’s not always easy.