It can be argued that the most important mechanism for extracting residual exhaust gases in the combustion chamber comes from the kinetic energy of the outgoing gases. When the exhaust valve opens near the end of the power stroke, there is a sudden expulsion of high-pressure gases. This expulsion creates a pressure wave that travels outward through the exhaust pipe at the speed of sound. Actually, it must accelerate and decelerate, but we can use an average speed for this explanation. This pressure wave travels considerably faster than the outgoing gases pushed by the upward moving piston. On the front side of the pressure wave, there is a high-pressure area, but on the trailing side of the wave, there is a depression or low-pressure area. It's the low pressure created by the traveling pressure wave that helps scavenge exhaust out of and help improve intake flow into the combustion chamber. The critical element is that there needs to be sufficient tubing length to allow the pressure wave to leave behind the depression capable of extracting the stagnant gases. Conversely, if it's too long, excessive flow resistance will create backpressure that limits the scavenging process.
In addition to the kinetic energy of the outgoing gases, reflected waves also help improve scavenging. We know from our discussion on kinetic energy that a pressure wave is released when the exhaust valve opens, and this pressure wave travels outward through the primary pipe of the header. We also know that the depression left behind helps improve exhaust scavenging, but the pressure wave is not actually finished when it leaves the end of the exhaust port and enters the collector. What happens when the high-pressure wave exits the end of the port is something called rarefaction. This technical term means that the high-pressure wave that was contained inside the pipe is allowed to expand rapidly in the collector. This expansion in all directions creates a depression (low-pressure area). The elasticity of the surrounding air will rebound toward this low-pressure area and reflect the negative (low-pressure wave) back toward the exhaust valve. Basically, a high-pressure wave is sent out and a low-pressure wave is reflected back. Time the arrival of this low-pressure wave correctly and you have additional exhaust gas scavenging, as well as improvements in intake flow into the combustion chamber.
How (may you ask) do you time the arrival of these pressure waves? The answer is with primary tube length. Since the pressure waves travel at the speed of sound, timing their arrival for optimum scavenging is based on the opening of the exhaust valve (relative to crank angle), the extent of the overlap period, and (most importantly) the length of the exhaust tract. It should be noted that the positive pressure wave is reflected back as a negative pressure wave. When the negative pressure wave arrives at the combustion chamber, it is again reflected back as a positive pressure wave, and then again as a negative pressure wave; so it goes until the next exhaust cycle.