Fixed several bugs in events.