Optimized the upgrade tool and add a plugin

As far as I can tell, there is no good reason for the second line of the "tools/upgrade.sh" to be there. If escaping white space where necessary, that method would be insufficient. Worse, since the only later use of the variable has it in double quotes having backslash escapes for spaces actually breaks it.