First of all, NG, my heart aches for you.
I am so sorry that "the system" fails in so many ways. I hate that HATE that there is no good advice in this situation.
Your post triggers me just a little because I can hear and see my L telling me that my ex could "show up in court with a hooker on each arm, drunk, with a needle hanging from his arm" and he would still be awarded visitation time with my children.
My solution was not to go to court over this. We went to mediation and it was terrifying and awful to be that close to him and to "play" the game of letting him win and be in charge...
BUT the up side here is that there is some damn creative protective language in my parenting agreement. Ex got caught up in the "wins" I gave, and of appearing generous and "good dad" for the audience of the mediator (who was a woman and of a grandmotherly age). I got lucky in this in many ways.
The two things that stick out for me here are to be extremely vigilant and to get him on the defensive with regard to the "habits." If there is child porn on his computer involve law enforcement if possible. If he has probation conditions act on them.
Teach the girls to go everywhere together. I have gone so far as to instruct the boys that they are to protect one another at all costs. They are the only one there for each other when I am not. Sucks but I let them know that those were my expectations. Be there for each other. And they have. In some sucky sucky situations...
The hardest part is making sure the kids continue to talk to you without feeling like they are "getting daddy in trouble." I always redirect it to "keeping them safe" and that grown ups don't need protecting from their own behaviors.
Make sure you have an outlet/confidante who can listen and give you a measure of what is "normal" and "ok" because exposure to the weirdness for so long numbs us and our WTF factor gets miscalibrated.