make zlib methods thread-safe
Add some extra logging