Small refactoring in client switching code