Clean up the code used to write the gzip trailer and add some comments.