fix event handling.
Rewrite fix
Merge pull request #612 from rfuerst87/event-handler-fix

fix event handling.