Fixed Canvas.at assertion and cleaned up code.