Pulled some logic out into other methods of the client.