Mainly optimizations to canvas and bug fixes