Fix memcpy and memmove performance