Use requestAnimationFrame for drawing instead of timeouts