There are some questions here that I'd like to take a stab at.
The MAF sensor only reads the pressure of the air moving past - sort of like how far your UHF antenna is bending back as you drive along. This is a vital piece of information! If you join that info with the intake air temperature (which the ECU knows) and the boost pressure (which the ECU knows) then you can calculate how many molecules of air are entering each cylinder and therefore know exactly how much fuel to put in for an efficient burn. As air warms up it occupies more space so the most important piece of info is the intake temperature.
Try this experiment: on a cold morning, half-inflate a party balloon. Now put a circle of sticky-tape around its widest point and take it inside, letting it get warm. The balloon will bulge around the tape. It's still the same amount of air - just the temperature has changed. Because the MAF sensor is reading the same amount of air, but the temperature is higher, the ECU knows to inject LESS fuel to remain at peak efficiency because there's less air actually moving into the cylinders. This is another reason why our diesels like cold air.
This function of the ECU is also what makes our cars work equally well at sea level and at altitude. In old carburetor engines, if you were staying for any substantial length of time at a significantly different altitude, you'd get the carby re-jetted. My Honda Eu20si generator manual actually tells me to get the carby rejetted if I am going more than 300m higher or lower in elevation, to maintain peak efficiency. Our ECUs take care of this with the MAFS, temp and boost sensors.
My belief is that the D22 and D40 engines are the same except for the heads, turbocharger and the programming. I am not sure the D22 has a MAFS, so it might use a milder tune in order to stop the engine from leaning out too much at sea level and not be too rich at altitude.
The turbocharger in the D40 has movable vanes on the output of the compressor that adjust the flow of air into the manifold. It allows for faster response to a changing demand, because the turbo's already spooled up. Trouble is, I think the D40 tune also includes some fuel waste to keep that turbo spooled high (to prevent lag) and I really wouldn't mind removing that - I'd take the lag, to get the economy of a D22.