Fixed bug with pending events not being updated

- Pending events are not properly unset if flushBuffer is called before
  the AsyncTask returns. We clear the indexArray of pending tasks, and
  eventually "forget" to unset the pending flag.
- Fixes #24