Fixed a bug in the upgrade code