Fix delete_value bad_cast exception on toupper call