file handling improvements