Added a couple of set -e: hopefully, this will make debugging easier
Moved oq_upgrade