refactoring. removed unused functions and events. changed to call functions directly instead of calling them indirectly through event manager.