Don't be so keep to call upgrade_mode/1, it can die in all sorts of ways.