Refactored open_files to devices.c and renamed it