Re: Moths.... Be sure to freeze your seeds at least 48 hours before use. If need be, put the seed into smaller bags or containers and then freeze. This will help kill any eggs that may be in the seed.
You can get moth traps (check Ebay) for cheap.. your best bet here is to get a small cage, hang the trap inside the cage, then hang the cage where the moths most frequent... thus, your birds are in no danger of being caught in a trap.
Re: Fruit flies... I've heard of two good methods here... One, get some red wine and leave about 1/2 of it at the bottom of the bottle, or put into another bottle. To make this more affective, get a 2 liter bottle, cut the top off (atleast 4" or so of the top), then turn the top upside down so that the "spout" points down into the bottom. Make sure to have some red wine at the bottom to catch the flies...
Another idea, take out all fruits at the end of the day, put into a zip lock bag, and leave open overnight. In the morning, close the bag and toss it. Repeat as long as needed.
Here's an idea combining the fruit and the 2 liter bottle...
I've noticed that flies can't easily land on food if there is a current of air flowing over the food. Either don't leave the food out for more than 30 minutes, or see if you could set up a fan to blow over the food that wouldn't bother the birds but would keep the flies away.