Fixed various (stupid) IO errors regarding files.