Add canvas 2D rendering support, requestAnimationFrame support, move and clean some code