Fixed some bugs.
Finished implementing decode.
Fixed a bug.