Sterilizing the growing medium, maintaining cleanliness, and using high-quality spawn are effective ways to prevent contamination.