Improved the upgrade script.