cleanup of memcpy code