Changed all instances of memcpy to memmove.