Makes sense, given the variability of your symptoms. Replace both with OEM equivalents once you confirm they are in fact bad and it's not a poor electrical connection or something else triggering those codes...Once you have new sensors in place, your harsh shifting symptoms should go away....The MAF influences the PCM's management of transmission internal line pressure so if it's over reporting or under reporting air flow, the AFM will also be off and consequently, the line pressure curve will also be out of phase. The TPS data stream is also used by the PCM to control the transmission, including playing a part in line rise response by the EPC to throttle input...same deal, if the TPS is reporting inaccurately to the PCM, well - garbage in, garbage out.
Let us know what happens once you have done the repairs.