Fix memory size
Fixed type of var
Reuse buffer in decoding
Remove debug code