If you have a problem with flies, you can use 2 inches of sand on the top of your soil and that gives them a very very difficult environment to thrive in. They don't like the dry grainy sand. They like moist, damp, moldy places..
Make sure you sterilize your sand in the oven before you use it...