Refactoring generic gzip to handle each payload chunk separately

Closes #535