* Complete refactoring main event functions.
* Move plugin helper functions to its own file.