Made the resizing more reliable for the canvas size.