fixed possible setTimeout and setInterval issues