Refactor credentials cache