Rewrite of the file handling + fix for time-outs