Fixes number of received bytes calculation in the input stream.