"Nobody does it better," sang Carly Simon during the opening credits of "The Spy Who Loved Me."

Indeed, you could make a case that the 007 adventure, released 40 years ago this week in the U.S. (on July 13, 1977), was the best of the late Roger Moore's James Bond movies, with perhaps the best pre-credit sequence (that ski jump!), one of the best cars (that Lotus Esprit that converts into a submarine), a great henchman (Richard Kiel's Jaws), and an even better Bond girl -- Barbara Bach's Agent XXX, a.k.a. Anya Amasova, who's every bit as skilled, smart, and lethal a spy as 007.

As beloved as the movie is, there's plenty you may not know about its behind-the-scenes intrigue. Here's the secret dossier on "The Spy Who Loved Me."
1. The film has almost nothing in common with Ian Fleming's novel, due to the author's contract stipulating that none of the book's plot could be used. It's a departure for Fleming, told largely from a female spy's point of view; James Bond doesn't even show up until two-thirds of the way through. Fleming wasn't happy with the way it turned out, and when he sold the film rights to Eon, the producers of the other titles in the 007 movie franchise, he allowed only the use of the title. Nonetheless, the characters of henchmen Jaws and Sandor are loosely inspired by similar characters in the novel, with the former inspired by the character called Horror.

2. As it turned out, Eon was also legally barred from using the villain it wanted. Kevin McClory, who owned the rights to "Thunderball" (the lone Fleming 007 novel that had been a screenplay first), had licensed those rights to Eon for 10 years, beginning with the production of that Bond adventure in 1965. Now those rights had lapsed, and when McClory learned that Eon's "Spy Who Loved Me" script idea included Blofeld and SPECTRE (both mentioned in "Thunderball"), he filed an injunction, as he was trying to develop his own Bond movie series. (Eventually, his "Thunderball" reboot became "Never Say Never Again" and brought Sean Connery back for one last turn as 007.) So Eon went back to the drawing board and came up with the Blofeld-like Stromberg, whose scheme to start a nuclear war between the Soviets and the West echoes the plot of the 1967 Bond movie "You Only Live Twice."
3. How similar is "Spy" to "Twice"? Not only is it directed by the person, Lewis Gilbert, it uses a tanker to swallow nuclear submarines, similar to how "Twice" featured a space capsule that could swallow other space capsules. (Gilbert acknowledges this similarity on the film's first special edition DVD release.)

4. Eon sought a number of different directors, including Steven Spielberg -- then newly-hot after the success of his own movie about a character nicknamed Jaws -- before finally returning to "You Only Live Twice" director Lewis Gilbert.
5. Frequent 007 screenwriter and script doctor Tom Mankiewicz claimed in his memoir that iconic French star Catherine Deneuve was interested in starring in the film, but her quote at the time was $400,000. Mankiewicz said she offered to cut her fee to $250,000, but the producers were unwilling to spend more than $80,000.

6. A young John Landis worked on an early story treatment for the film, alongside then-potential director Guy Hamilton ("Goldfinger").
7.Lois Chiles (pictured) turned down the chance to be Bond's love interest, though she would sign on to play Holly Goodhead in the next 007 adventure, "Moonraker."

8. Bach landed the lead role just four days before shooting began. She thought she was auditioning for another, smaller part. According to People, Moore was disappointed; he'd been hoping for Brigitte Bardot.
9. Bach seemed similarly unimpressed with her leading man, describing James Bond to People as "a chauvinist pig who uses girls to shield him against bullets."

10.Geoffrey Keen and Walter Gotell made their Bond movie debuts, as British defense minister Frederick Gray and KGB chief General Gogol, respectively. Each would reprise his role for the next five sequels.
11.Curt Jurgens (above) was cast as Stromberg because Gilbert had enjoyed working with the Austrian actor when he starred in Gilbert's 1959 adventure "Ferry to Hong Kong."

12. Production designer Ken Adam had famously built an enormous, temporary set at England's Pinewood Studios to house Blofeld's volcano lair in "You Only Live Twice." This time, he built an even bigger soundstage there, a permanent one, to house the interior of Stromberg's submarine-swallowing supertanker. Dubbed the 007 Stage, it covered 45,000 square feet and contained a 300-foot-long water tank that held 1.2 million gallons. The set cost $1.8 million to construct.
13. Lighting the massive soundstage proved too difficult for cinematographer Claude Renoir, who was then losing his eyesight. So the producers smuggled onto the set a secret lighting consultant: no less than Stanley Kubrick, who'd recently pulled off the feat of lighting much of his "Barry Lyndon" with nothing but candles and natural light -- sources appropriate to the film's 18th-century setting. (Adam had won an Oscar for "Barry Lyndon's" production design.)

14. "Spy Who Loved Me" was a typically globetrotting 007 production, with filming locations as far-flung as Sardinia, Spain, and the Bahamas. There was also Egypt, where the producers realized they couldn't properly light the Pyramids at night; they ended up using miniatures instead.
15. The production used six versions of the Lotus Esprit S1, each showing the supposedly amphibious car in various stages of its transformation. Only one actually operated underwater. It was nicknamed "Wet Nellie," a reference to the "Little Nellie" autogyro Bond used in "You Only Live Twice." It was a $100,000 mini-sub in an Esprit shell. There were also some scenes that used miniatures, with air bubbles generated by Alka-Seltzer tablets.

16. While shooting in Egypt, the production briefly ran out of food. So franchise producer Albert "Cubby" Broccoli found himself cooking a spaghetti dinner for 100 members of the cast and crew.
17. Those scary metal chompers Jaws wore were actually made of acrylic. Though a dentist molded them to fit Kiel's teeth, Kiel told the Guardian that they were so painful to wear that he could only keep them in his mouth for a minute or two before he would start to gag.

18. A dispute with British tax authorities kept longtime 007 composer John Barry from working on the movie, so scoring duties fell to EGOT winner Marvin Hamlisch.
19. With lyricist Carole Bayer Sager, Hamlisch co-wrote the theme song, "Nobody Does It Better," the first Bond theme not titled after its movie (though the lyrics do contain the phrase "the spy who loved me"). Carly Simon's performance of the tune reached No. 2 on the Billboard Hot 100 and stayed on the chart for nearly three months, making it her longest-charting hit ever.

20. The filmmakers hired Hollywood stuntman Rick Sylvester to do the pre-credit ski jump after seeing his amateur Super 16 footage of his own illegal parachute jump of 3,000 feet from El Capitan at Yosemite. Sylvester was paid $30,000 to make a similar vault off the summit of Canada's Mt. Asgard. There was no rehearsal, and there would only be opportunity for one take.
21. Sylvester was too slow in his take-off, tangled his legs during the flip, and took so long to recover that, by the time he opened that now-famous Union Jack chute, he'd fallen out of range of the helicopter filming the scene. Fortunately, another cameraman who was roped into place just below the summit caught the whole jump

22. "Spy" cost $14 million to make, still a lofty sum for a movie in 1977. It earned back $185 million worldwide.
23. The Academy nominated the movie for three Oscars. Two nominations went to Hamlisch, for his score and for Best Original Song. The third was for art direction, marking the third career nomination for Adam and his only one for a Bond film.

24. The closing credits promised that Bond would return in "For Your Eyes Only," but the successes of such 1977 sci-fi movies as "Star Wars" and "Close Encounters of the Third Kind" inspired Eon to film space adventure "Moonraker" next instead.
25. Kiel's Jaws was an instant fan favorite. He was initially supposed to die in Stromberg's shark tank, but test audiences disapproved, so the film was recut to let him live. He's perhaps the only henchman to appear in more than one 007 film, and in "Moonraker," he even got a character arc and a love interest. We almost got to see him marry Dolly in "For Your Eyes Only," but the filmmakers decided the franchise had become too cartoonish, dialed it back a bit, and nixed a third Jaws appearance.

26. In 2013, Wet Nellie was sold at auction for $989,000 to Tesla CEO Elon Musk, who pledged to turn it into a vehicle that would actually transform from a car into a submarine and back like it did for 007.