washer parts and black spots question

My wife asked me to look at our washing machine. she was finding black tar like stuff at the bottom after washes.

I opened the access panel and have 2 questions:

  1. what is the little square box attached to the bottom left side of outer tub. It is half filled with water and has a tube running from the box to the top back of the machine. It looks like it has two halfs and the right side of mine has black stuff at the bottom. Any one know what this part is or what it does?

  2. the top part of my outer tub also has black gunk. is there a way to clean this or does it need to be replaced? I assume this is just from heavy use.

Thanks