Fix memory leaks

* creating new function in timeout callback - basically creating infinite number of functions over time
* not destroying timeouts on scope destroy