Bryan Cogman tells THR of penning the HBO hit: "It's not until you see it air with an audience who enjoys it that you can finally relax."

[Warning: Spoilers ahead for Sunday's episode of Game of Thrones, "The Laws of Gods and Men."]

Game of Thrones writer Bryan Cogman has knocked some of the series' most difficult scenes out of the park, most recently with Sunday's trial of Tyrion.

He also has the distinction of penning the first script to go significantly beyond the books -- with an explosive episode revealing just what the White Walkers have been doing with Craster's babies.

PHOTOS: Joffrey's 10 Most Evil Moments

But those successes wouldn't be possible without a dose (or two) of worry.

"I'm terrified all the time. You're talking to me now as we're writing season five and I'm at the stage where I think everything is going to be terrible," Cogman tells The Hollywood Reporter. "I go through all seven stages of whatever a writer goes through. I'm a wreck when I'm writing the show. It's not until you see it air with an audience who enjoys it that you can finally relax."

Here Cogman talks writers' jitters, Theon's standout season and getting Tyrion's trial right.

Where did "Do you love me Reek?" in the bathtub scene come from?

In the book, there's a scene where Theon has been cleaned up. So that led to us thinking we should show the cleanup. It shows Theon's physical mutilation has already happened, but the psychological mutilation continues. "Do you love me Reek?" is one of my favorite things because there is so much behind the question and it tells you a lot about Ramsay and how Ramsay defines love. It's not directly from the books but it's definitely inspired by the books.

And you have another bathtub seen with Davos and Salladhor Saan.

One of the reasons for setting Salladhor Saan and the courtesans in the bath is because it's sort of an elemental thing. A bath is when you're most at ease, but it's also when you're most vulnerable. The same thing dictated the Theon bath scene. It created this very intimate and all the more terrifying encounter.

PHOTOS: 'Game of Thrones': 20 Best Quotes

What's your take on Yara leaving Theon?

She realizes she is the future of her house and she can die there with Theon or fight another day. And the fact that Ramsay is letting her live says a lot. He could kill her, but he chooses not to because it's more fun for him.

Alfie Allen (Theon) has had an amazing season. Did you realize how good he was back in season one?

In my mind, Alfie Allen is one of the unsung heroes in the show. He was cast off a great audition, but Theon in the first season was a background character. He's one of those characters George (R.R. Martin) introduces and then in season two you see things from his point of view. We were casting Alfie and Theon for season two and beyond. Alfie brought so much humanity to the role right off the bat and had such a screen presence with Richard Madden (Robb). The brotherly relationship between Theon and Robb are there in the books but we definitely upped the storyline.

PHOTOS: Daenerys' 10 Fiercest Moments

And Theon has been through a lot now.

The scenes are very difficult to watch and they are meant to be. It (season three's torture) was very controversial and I don't think it worked for everybody, but I applaud (showrunners) David (Benioff) and Dan (Weiss) for going there. Now you're starting to see the method behind Ramsay's madness and how he's going to use Theon for his own ends and how Theon's transformation is affecting other characters in this world, including Yara.

How fun was writing that trial scene?

While it was tremendously fun to play with the courtroom genre, the danger was you don't want it to become a spoof of itself. "Game of Thrones does Law and Order!" It was about making it familiar as a courtroom drama but also making it Game of Thrones.

You got to relive some of Tyrion's greatest zingers.

Dan and David were adamant that most the testimony against Tyrion be basically true. In one draft, I had characters making up a lot more false testimony. The guys said very wisely "No, no, no. Go back and find nuggets from the past." The tremendously satisfying thing about writing it is it's basically the climax of the Lannister family drama that these characters have been embroiled in for decades.

PHOTOS: 'Game of Thrones'' Most Gruesome Deaths

The scene plays out in looks among the Lannisters. It was beautifully played by all the actors and beautifully directed by Alik (Sakharov). Jaime doesn't say a word during the trial, but Nikolaj (Coster-Waldau) can play so much with his looks or a nod of the head. That was something very conscious in the scripting of the scene.

Do you get nervous writing something as iconic as the trial?

I'm terrified all the time. You're talking to me now as we're writing season five and I'm at the stage where I think everything is going to be terrible. I go through all seven stages of whatever a writer goes through. I'm a wreck when I'm writing the show. It's not until you see it air with an audience who enjoys it that you can finally relax.

How has writing the show changed for you since you started?

At this point I know how to write these characters in terms of their voices. It's been years of living with them and not only that, but living with the actors and playing to their strengths. It's no longer Cersei Lannister, it's Lena Headey's Cersei Lannister. I think the series gets stronger because the actors get more comfortable as well. The guys have been very generous over the last four seasons in trusting me with some big scenes.

What is your take on Daenerys in this episode? Is it accurate to say she's learning that ruling can be quite boring?

I don't now if boring is the right word. It's certainly exhausting to hear all of her supplicants. It's also that she saw the world in black and white for a very long time, and it's starting to look a lot grayer and she's going to need to learn how to deal with that. Its one of the great elements of George's story and it's something we really want to explore in the series and will continue to explore—that the story doesn't end when you storm the castle.

For more from Cogman, check out his appearance on the Game of Thrones fan podcast Game of Owns.

Stay tuned to THR.com/GoT on Friday, when we'll have a preview of Sunday's episode with director Alik Sakharov.

Email: Aaron.Couch@THR.com

Twitter: @AaronCouch