code cleanup, don't use memcpy/memset