Implemented event manager.
Refactored code to Context