Way back in the 70s and 80s, when I was heavily involved with fixed media waste treatment systems for water reuse, we had a problem. Many of those facilities had fly infestations. So, we began adding Bacillus thuringiensis (BT) microbes to the mix. These microbes secreted a chemical that took care of the flies. (We actually manufactured the microbial mutants on peanut hulls, which kept the microbes on the surface of the water (peanut hulls tend to float).