Fix off-by-one on upgrades