replace most memmove/memcpy with std::copy