content: 
  ===Writing===
  The episode was written by series producer Bryan Cogman.
  This episode was written by the series producer Bryan Cogman, who has written at least one episode in every season of the show. It contains some content from George Martin's novel ''A Feast for Crows'', chapters Arya II, The Queenmaker, Cat of the Canals, and Cersei X and ''A Dance with Dragons'', chapters the Ugly Little Girl, Tyrion X, and the Prince of Winterfell, though series consultant Elio Garcia describes the portrayal of some of these events as "vastly different" from the original.
  Like other episodes this season, it also included content and storylines written specifically for the television adaptation.  Myles McNutt of ''A.V. Club'' points out that this changes the way the viewers interpret the showrunner's decisions. When describing his opinion of the decision to show Sansa raped by Ramsay on their wedding night (a storyline given to a different character, Jeyne Poole, in the books), he compares the scene to a similar one between Daenerys and Drogo in season one (which was consensual in the novels): "While we could frame the shifted events of Dany and Khal Drogo’s wedding night in light of where we knew Dany’s story was going, here we have no idea what this does to Sansa’s storyline." Most critics questioned the decision to show Sansa raped on her wedding night, but, as ''Business Insider'' pointed out, "The book version of this scene was much, much worse," with Theon ordered, graphically, to participate in Jeyne's mistreatment. In an interview with ''Entertainment Weekly'', show writer Bryan Cogman was asked about the decision to decrease the level of violence, responding, "Lord no. ''No-no-no-no-no.'' No. It’s still a shared form of abuse that they have to endure, Sansa and Theon. But it’s not the extreme torture and humiliation that scene in the book is."
  However, in other ways, the episode veers back to book canon: "Whereas Loras’ arrest suggested the show was replacing Margaery's alleged dalliances with his homosexuality, here the show gradually builds to Margaery's arrest for lying on her brother's behalf."