Add credentials handling.
Improved error handling.