Understanding and Using Dreams to Learn and to Forget