Fixed lots of buglets in events.js.