encode finished
Structure and algorithms in decode.c