Just be sure to mark all the hoses prior to removing them - duct tape & a marker should work.
Once you've pulled out the old valve, use a garden hose to squirt water into the upper heater core, then once the water runs clear, squirt it into the bottom heater core until it comes out clear. You may have to do this a few times to get all the gunk out.