Ok this is off the top of my head so... Essentially, nitrates in the tank are the same in the filter. Ammonia is fish waste. Bacteria then eat this ammonia and excrete nitrites. New bacteria then form which eat nitrites and excrete nitrates. Water changes reduce nitrates. These two kinds of bacteria are found all over your tank from in your filter to the gravel and ornaments. When you wash in tap water the filter it kills the bacteria, or at least destroys the culture. This is why you use tank water to clean the filters so it does not kill the bacteria. The gunk is waste, ammonia, which is constantly being broken down. The gunk is there to feed the bacteria, the bacteria then breaks part of it down into nitrites to nitrates. It is okay to have this gunk anywhere in the tank the filter just makes your tank look cleaner. If your nitrates are still above say 10-20ppm then maybe do more water changes. I have a turtle tank and he (turtle) is a waste monster. Aparantly for every 1g of food they excrete 5ml of waste. I never have problems with nitrates. Once per week gravel clean and 20-40% water change. Depending on my mood. In theory if you have plants they also consume nitrates (to what I've read) so you shouldn't really have problems.
HTH