Sets up events.