Fight - can black stones be killed?
In general, this kind of fight is going to get you into trouble - you have a bunch of separate groups to take care of.  If your strategy before Black's invasion was sound, then you should be able to get a useful wall out of the invasion.  In that case, it's generally better to just keep extending along the fourth line.  So, instead of 20, I would just extend.  Black gets two points/move, and you're getting thickness that's worth more.

In the first diagram, if 39 is at 40, then isn't Black alive?