Refactored. Added touch detector.