Clean up copying code.