One reason he may not wish to visit Iraq is simply it's a no win situation. With all of his previous statements on what a failure the Maliki government and Iraqi military has been, he must worry that he will not be well received. With the recent victories of the Central government and Iraqi military the last thing he can afford is having to say; I was wrong about the government, military and the American military surge. Another problem for him would be the customary greetings of Muslim countries. If the respected leaders he met in Iraq offered to give him the traditional kiss on each cheek how would Obama respond and how would it be received in American politics.
The reason he may decline the Town Hall meetings with McCain is style and not being able to control the situation. Having truly independent voters asking questions that have not been vetted first can be a dangerous thing. Obama does best giving revamped rhetorical speeches from past Democratic candidates and presidents. He simply rewrites them using new words but the tone and message remains the same. In Town Hall meetings you cannot rely on old speeches, voters want real answers to their questions.
Obama believes the Town Hall meeting style debate is too structured. The truth is the Lincoln vs Douglas style debate is entirely structured. Each candidate gives a prepared speech for a set amount of time and is allowed a follow-up speech at the end with no questions. There is a moderator agreed upon by both parties. Voters hear only the speeches the candidates have prepared in advance, voters may as well spend their time going to the candidate's campaign rally.