Fix bad uses of the UINT16_MAX constant