Refactored types. Tests all pass + tested client with a real account on gmail.