Fix bugs on filemode