Refactored Router

Refactored router into a class that inherits from EventEmitter to make it possible to add event listeners external to the module.