Just a quick note to say you can balance the humidity with some microscreen that will keep the "pests" out, though I don't really have ventilation on a lot of my roach containers aside from the bit that gets in between the lid and container (and when I open them to feed every couple of days). I use isopods in my large dubia colony and I see fewer fungus gnats in that bin than any of the others that don't have isopods. I simply change substrate when a problem occurs and sometimes the bin. Mostly, I just kind of live with the traveling fungus gnat "culture". I rarely see phorid flies because I usually find the dead roaches before they get a chance to pupate and emerge.
I haven't changed the substrate in that dubia tank in over a year, maybe closer to two. It was an isopod bin, then a giant cave cricket bin, then about a year ago it became a dubia bin that has housed thousands of dubia. The isopods and probably the roaches seem to do a pretty good job cleaning house together, though I probably don't feed them as often as I could.
Sometimes, I just drop my youngest mantids in with the roaches to feed on the fungus gnats and keep the humidity down for awhile.
Wouldn't hurt to hit up all the typically recommended foods and maintain higher humidity too! Maybe you're putting too much food in or not pulling it out fast enough (though I know it only takes 24 hours or less for mold to spread under some conditions).