use memmove instead of memcpy when removing message header since the areas may overlap