Fixed event binding

Also fixes #492