Adjusted the type of flags (unsigned short -> unsigned int)