- if 'set +e' is called in a trap (except for EXIT), then call 'set -e' at the end. - added several missing cleanups. (cherry picked from commit a7de35462a3df6a30e7eba2d36d1b8bd2fd92aaf)