Fix bug with sending an event twice