Slight changes to use requestAnimationFrame (and a polyFill for it).