Refactor and switch to zlib compression. WIP
Finish refactor