Cleanup of canvas.js

Documented functions, removed unnecessary functions, renamed several variables to be more clear, and moved a non-generic function to drawing.js