Refactoring: use a simple macro to add listeners.