minor improvements and code cleanup for canvas.js