         dup code-size>> 1 - 2^ >>clear-code
         dup clear-code>> 1 + >>end-of-information-code
         swap >>input
-        BV{ } clone >>output ;
+        BV{ } clone >>output
+        reset-lzw-uncompress ;
 
 ERROR: not-in-table value ;
 

prettyprint sequences vectors ;
QUALIFIED-WITH: bitstreams bs
IN: compression.lzw

SYMBOL: current-lzw

TUPLE: lzw
input

    ] if ;
    
: lzw-uncompress-char ( lzw -- )
    [ >>code handle-uncompress-code lzw-uncompress-char ] lzw-read* ;

: lzw-uncompress ( bitstream code-size class -- byte-array )
    <lzw-uncompress>
    [ lzw-uncompress-char ] [ output>> ] bi ;

: tiff-lzw-uncompress ( seq -- byte-array )
    bs:<msb0-bit-reader> 9 tiff-lzw lzw-uncompress ;
