More fixes on upgrade script.