Small corrections from review comments

Remove remaining legacy code.
Separating untar file writing to be able to use defer for closing.