Changed ClientManager and EventManager to use dependency injection, so we can use them more easily, especially in testing.