Minor improvements to file handling.