Optimize the unsetClient method to avoid loops.