Adding event handling code.