Fixed a few bugs about detection of "target reached" event.