Fixed setTimeout and setInterval errors