fix to read kav.tar.gz file and code cleanup.