If you've already replaced the EGR, and are getting a PO401 code then the next most likely issue (which should have been checked 1st before the valve was installed, unless there were other code(s) prior) would be flow restricted by carbon (or ???) through the system to intake.
It's fairly easy to check - with engine OFF, remove the EGR from it's base and set aside, with ports now visible look for obvious carbon deposits in the holes, if none seen then start the engine and listen to idle - is idle 'normal'? if the idle is normal then the port from EGR to intake manifold is plugged somewhere along it path. If idle is 'odd' (very rough, high RPM or other) then most likely the path from the exhaust manifold up to intake is blocked somewhere.
Fix is about the same for either;
If it's in the path to intake use Carb Cleaner Spray (OX2 Sensor safe type) and some type of wire (drain router spring wire or even a coat-hanger) and the spray to clean the passage as best as possible until you can blow through the passage easily.
If it's in the path to exhaust do the same procedure, but I try to vaccum out as much of the plugging 'junk' as possible as I go to prevent dropping a bunch into the Cat path and causing other issues ...
And :yes: a loose or 'bad' cap can cause some of these MIL code(s) - most often they are pending or present codes that will reset by themselves after a few start-drive-stop cycles, during which time you've either found the cap loose and/or re-tightened the cap when you refueled.
Most often a loose or bad cap will cause only intermittent MIL indication - it is always something that should be checked as part of good diagnosis before you start replacing parts.
Hope this helps some