Extracting cosmological signals from foregrounds in deep mm maps of the sky