Reworked file handling.