Replaced manual copy with memcpy