Add support for user-defined events via an "events" attribute. Fixes #15