Implemented more of the event router, refactored to use lambdas.