template bitstream on blocktype
refactor / cleanup