Having been raised in a home where I didn't feel wanted by my dad, along with alcoholism, infidelity, domestic violence and an NPD mother, I know a bit about what your children face, only they have a sane, balanced and loving mom - they have a safe place so long as you keep their mental emotional safety in mind as you raise them and you're doing that right now in asking these questions.
I also raised my son in a home where bipolar flair ups with his father occurred sometimes. I had to do some preventive educating, some of which helped but some was completely ineffective - I get to see how I did now that DS is in college.
From the perspective of your children:
They already know or sense how much their father wants or doesn't want them. They want his approval. They may be thinking that if they're just obedient enough, he'll love them. They may get caught in that horrible trap. That's the trap I got caught in - thinking that if I just kept the house clean, or did the things my dad was screaming at my mom about not doing, then he'd stop yelling, stop drinking and be the kind of dad my friends had. Talk about overcompensating. My mom was not equipped to recognize what I was doing, or how horrible my life was, or how much I was personalizing what was going on in my home. The world revolved around her experience and so she was clueless and didn't care to get a clue just because I was in pain.
And where your X has the proclivity for little girls and children are sexualized to him, there is a greater danger than I had growing up. Talk with a therapist about neutralizing this trap for your children. Age-appropriate knowledge about mental illness and perversion is important for them to learn so they can protect themselves since the courts won't...yet.
As a parent - what I did right:
1. Was a safe place for DS to talk, cry, complain, etc. without undermining his father's place in his life. We went for a lot of drives to get him a space away from volatility and toxic emotions when his father was having a manic episode. I learned and practiced listening with validation.
2. I would ask him for his ideas and solutions. My natural tendency is problem solving, which DS hated. He wanted to be heard, not told what to do.
3. Taught my son early and often to recognize the difference between cause and effect (his behavior/natural and logical consequences) and other people's issues.
What I wish I had done more of or differently:
1. Paid more attention when he didn't want to talk. I would let him come to me because I didn't want to push and process him all the time.
2. Paid more attention to self-abuse cues. No matter how hard you tell a child it's not their fault and they didn't do anything wrong to have their father behave badly, they have their own beliefs anyway. I would have intercepted those cues and got him working with a counselor a lot sooner.
3. Paid more attention to developing his own goals and dreams. DS is a pleaser, but very strong willed. I would have nurtured that strong will a lot more and taken advantage of the pleaser a lot less.
4. No tickling. I loved to hear him laugh. I craved it. He already felt bullied and pushed around by his dad, especially during manic phases. If I had a do-over, I'd have made sure my own behavior was much safer - though I tried hard to be a safe place for DS, I missed a few very important cues.