ported single byte workaround from C lib to CPP