Fixed some bugs with file copying.