Refactoring for clarity and debugging.