I also forgot to mention (SPOILER)that apparently Rowling gave Harry 3 possible ways out of death. The two I mentioned earlier, and the fact that he was the owner of all three Hallows (which we didn't know at the time of course with the wand). Dumbledore did make a reference telling Harry the he was the true uniter of the Hallows. I also don't particularly see it as a deus ex machina because she has explanations that do fit accurately. We just aren't sure which one actually did it.