fix memory leak / setTimeout bug