Refactoring credential detection.