refactor things a bit more to make gzip stream easy