refactored transformation to bitstream. fixed imprecision bug.