Fixed some bugs

Fixed "file overwrite" bug