added support for api-key, minor corrections too