code cleanup for upgrade script