fix bitstream parsing bugs