Refactor client initialization