improved pkg upgrade