Some file operation fixes and comments