Simplify file handling in some places