Merge branch clear

This will fix a issue which prevents from redraw code within the same canvas element. It also fixes an error whcih prevented the script to call the onInvalid callback.