Fixed a lot of bugs.

I put some debugging code while the decoder still doesn't work.