Replace unsigned char with uint8_t for some conditions