Fix removal of objects in upgrade script