Issue252

I tried to fix issue #252.
And, I fixed the way of getting event data.

Please check the code. And, if there is some problem, let me know.
I move the decision point before check the value of dbLastEventId at f74916c revision.
But, I don't understand it is good the way.

Is that OK?