Added support for canvas modes, misc bugfixes