Fix event handling bug.