refactor macros, use memcpy