Added code to respond to touch and shake events.