Fix issues relating to writing / updating files and return success code when appropriate.