Moved 'set -e' to top of script so it happens before any commands.