Fixed potential infinite loop if constantbytes = 0