Fix handling motion events