Use requestAnimationFrame and fix stat bug