Fix overlapping memcpy