Ios bug

Merging changes made attempting to fix IOS bug
These changes where mostly around file reading and writing