light debugging and refactoring. no functional changes.