Make more resilient upgrade process