Add check for existing files
Thats's a massive commit, sorry