Currently the 2D context is created and then stored on the canvas object. This needs to go. Wrap the canvas in an object or just move the ctx creation out.