improved cleanup in tovos and preliminary ngs_prepare_file