Added initial templating and on-the-fly gzipping