Restructured the code so that in the unlikely event that c.NewAPIClient() returns an error, the following code will not fail/panic/etc.