Added event firing code.
Added jsdoc comments..