Add next_bits implementation and update TB