The flares have 8 or 9 nuts that go on studs which in turn are welded to 2 or 3 metal tabs. Don't bother to try to save them, you are pretty much guaranteed to break off every stud.
To reinstall them just discard the tabs holding the studs and use 1/4 bolts, washers and nylon lock nuts.
I'd probably want to remove the plastic under the flares anyways before I go and get it undercoated so it actually protects the metal and not the plastic I'd be taking off later.
I definitely would take the junk/plastic stuff under the front bumper off. It is just asking to be ripped off when on the trail. If I remember correctly, it is held on by just a few screws on each side. The part that is left, that is actually part of your flares, can be trimmed up with a dremel tool/cutoff wheel. You can see pretty much what it will look like in Lead's first picture. His rig doesn't have that part anymore, but still has the flares in that pic.
I would do all of this before painting.
Now, my personal opinion... Keep the factory flares if they are in good shape. It won't cost that much more to paint them while you are painting everything else. THEN, if you HATE them or screw them up royally you can take them off. I just like the way XJ's look with flares better (unless you want to run pizza-cutter skinny tires, then my opinion might change).
Again, this is my personal opinion. I am among few voices here that like flares. I am CONSTANTLY being razzed and pressured to trim mine off. Well, I am running 33" tires on a 3.5" lift (bumpstopped correctly) and I am able to keep my flares and I really like the way that it looks. So, take it for what it is worth. As long as you do what you want to do to your own rig (cosmetically speaking) you should be happy.