Replace a memmove() that spits a random warning when compiling with ubsan
This way is probably faster too.