Empty array after clearing timeouts
Refactor event handlers