Fixes event dispatching for CommonJS.

Fixes #180.
Fixes #181.
Closes #181.