Always deal with the rot first. Ensure the superstructure is sound, repair and replace as needed.  Next is patching and finishing. Then you are finally ready for paint and Justice. It is all about the prep.