Fixing stream size calculation bug