Answer: The condition you describe is anerobic - without oxygen. Decomposing organic matter can have an odor if it is not turned to incorporate air, so you can minimize the odor by frequently turning the compost. Maggots are also an indication that you are not turning your compost so it cooks (heats up and quickly decomposes). Use a garden fork to move the warm center to the outside and the cooler edges to the inside of the pile. The heat will cook the fly eggs and the maggots so they will no longer pose a problem.
In the compost bin, always bury your food waste several inches deep and/or place a couple layers of damp newspaper flat over the surface of the pile. Each of these helps to keep adult fruit flies from accessing the buried food, where they'd love to lay their eggs.
Q&A Library Searching Tips