Fixes bug in upgrade script.