Changed tutorial to use explicit canvas copying. Fixed tiny bug in flattenInner.