Fix upgrade from code