This is the core clone code.