improved bitstream parsing