Simplified and made the ClientThread process much more readable.