Use requestAnimationFrame and a single draw function
Some refactoring