Compression now works!

The code is still REALLY ugly though. I'm focusing on getting it working
first and doing minor refactorings along the way. Also, I still need to
serialize the tree and write it out to the file.