Upgrade installation script so that it does a better job of detecting what is already installed