* Fixed compression code, old code was unreliable and failed at random
(don't use zlib's compress function)
* More refactory work, ready for merge