Improved the handling of credentials