Listener code refactoring.