Implement bitstream format with some bugs left