Critical fixes for uninstall functionality