Added event handling/dispatch to factory (untested).