Finding the needle in the haystack: 21 cm cosmology in the midst of foregrounds