Refactor the library

Use a Client class to persist state (logged in cookies).

Change-Id: Ifcc48f53c47b6b61029bc5883922176b082a6d67