Set up protocol and implement delegate methods.