Updated upgrade script to deal with empty arrays.