added package.gz functionality, cleanup file handling