could the above be templated as well?

otherwise, visually reviewed this PR; 
at some point this has to be tried on Debian, because 2.7.5 was giving zlib headaches (not debugged this)