Fix resize and redrawing of the canvas