Fixed file management bugs