Fixed an serious bug in events.js