Update ENM for better handling of failures

Copy code from MPM, which does not rely on timeouts when run fails,
and provides useful error messages.