Fixed a bug which affected events on masks and layers masked by masks