Some code cleaning.
Added support for auto-centering in toCanvas function.