Fix event handlers on ruby 2

Fixes #4219