upgrade.py: Rewrite to make it simple