fixes a bug in internalCopy that made appendScratchpad produce corrupted trees