Regarding Bathsheba it is my opinion that she provided the story for her own purposes and for her son's. That she was performing the ceremony for menstruating and that her husband was absent and then killed, proved that Solomon was indeed David's.
By some means she managed to get her son on the throne, and so started the cleansing of David -- for Solomon's and Bathsheba's sakes. Of course this process of sanitizing David lay in the political interest of their successors, and we need to be conscious that much of what we read is subsequent political propaganda put out by the "House of David", and these later layers should be laid aside, if possible.
The situation changed when the Davidic monarchy ceased (despite 2 Samuel 7). Post-monarchic Deutero-Isaiah ignored the Davidides, while the Chronicler revived the manipulated history of David.
The other matter to keep in mind is that when Psalms of Solomon introduced the Davidic Messiah ("Son of David"), this Messiah would be a violent fighting warrior who would remove the Roman oppressors.
The NT writers were equally inventive.
Yes, it would be an interesting exercise to trace the sanitizing of God (YHWH)),
Doug