Code refactor to enable one server thread per connected client