Fixed file-related bugs