Car hesitates when accelerating, is the EGR (exhaust gas recirculation) to blame?

Your EGR valve probably is opened by a vacuum. If the vacuum line between the intake manifold and the
EGR valve were to be leaking, it would cause both the driveability problems and the P0401 code. First, inspect or replace that line. A vacuum leak could also affect the shift points on the transmission.