A couple fixes for debug warnings and improvement to upgrade script