Updated to use Stefan Petre's improved touch handling.