Define the event handlers before add them.