Cleaning up the code. Fixed a bug where the motion events weren't being received due to a missing mask