Shifted around execution order to make non-interactive execution on Ubuntu.