A few fixes in upgrade script.