Cleaning up and using requestAnimationFrame for performance