fix: wrong size of flag type, and changed some conditional statement of internal functions.