Installed packages are stored with uninstall IDs

It will either take the IDs from the installer in the manifest or from the registry (if only one change is detected).
null check for that is above, they were the same check done 2x.