Further improvements

Use the requestAnimationFrame API for running the animation.