Partial refarctor of the event related features. Added a template class
to have a more expressive DSL.