To say last week was a glass cage of emotions for “Brooklyn Nine-Nine” showrunner Dan Goor would be an understatement. The Andy Samberg-led comedy went from cancelled on Fox to renewed on NBC in a matter of 30 hours thanks to some backdoor finagling from Universal, a handful of interested broadcasters, and a powerful outpouring from fans and A-listers (including Lin-Manuel Miranda and Mark Hamill) on social media.

“A lot of what happened was behind closed doors even to executive producers on the show,” Goor tells Variety of the 13-episosde, sixth-season renewal. “The tell-all I want to read is what [Universal TV president] Pearlena Igbokwe was doing. It seems like she just defied all odds, what she did was so masterful.”

Indeed, as the series was wrapping its fifth-season run Goor and co. were prepared for the end with a special wedding episode that featured Jake (Samberg) and Amy (Melissa Fumero) tying the knot, Rosa (Stephanie Beatriz) meeting a potential love interest in the form of guest star Gina Rodriguez, and Captain Holt (Andre Braugher) learning whether he had made commissioner (that last plot point ended on a cliffhanger).

“We knew in the weeks leading up to the upfronts that we were on the bubble. That said we had been on the bubble before and felt optimistic so on some level we all felt like we’d hopefully get renewed. Then a few days beforehand it became scarier and scarier and it felt like the momentum was shifting towards we might not get picked up. And then on that Thursday it became clear that we were not going to get picked up. I got a call from the studio and then the network…it really didn’t hit me as real until I heard the words, ‘Your show is not being picked up.’ It was like, ‘Oh my God’ was echoing in my head,” Goor says, noting that he was learning the news of a potential pickup elsewhere as outlets were reporting it.

But Goor also says they have been “game-planning behind-the-scenes” so he knew there was a chance of getting picked up on another platform.

“That dulled the pain and desperation and made it not feel full final yet. At that point we started figuring out what our options were,” he adds.

When he learned Hulu wasn’t interested in saving his show the way they had previously saved Mindy Kaling’s “The Mindy Project” (which also originated on Fox), Goor admits he worried a bit. But by the end of the week he got a text saying NBC was going to pick up “Brooklyn Nine-Nine” for one final season.

“I was truly shocked and elated and so happy,” he says, calling out the “deep roots” at NBC, including the fact that series executive producer Mike Schur has two other shows on NBC’s 2018-19 television schedule (“The Good Place,” which is entering its third season, and freshman comedy “Abby’s”).

Here, Goor talks with Variety about what that fifth season finale meant for the show creatively, how “Brooklyn” will adjust from a 22-episode order to 13, and what kind of pressure comes with crafting a series that’s been cancelled and then saved.

What were those 30 hours of limbo like for you?

In this narrative I totally left out that the most surprising and amazing thing, which was the overwhelming and surprising online reaction. It was so warming and it was the most impactful part of the whole experience. Most of Friday was also spent with me pressing refresh on my phone and looking at my Twitter over and over again, and my wife saying, “Can you please put your phone away?” And me saying, “No, this is the only thing that makes me happy!”… [But also] really if nothing else, being able to attend your own funeral and hear that people liked you only to then be resurrected is amazing. Just going to the funeral was so gratifying.

Creatively how does it feel knowing the studio and NBC worked this out without you having to pitch anything — is that liberating or do you now feel more pressure?

I said to my wife, “I feel like there’s a lot of pressure to live up to expectations,” and she was like, “Are you saying you’re going to work harder now?” She was so furious at me. [Laughs.] We always have put tremendous pressure on ourselves to make the show as good as we can make it so I don’t think there’s increased pressure on us. NBC has been incredibly supportive. They know the show they bought and they know us. The strong message we’re getting from them is they want more of the show that we have been doing. And so that’s what we intend to do.

You mentioned Mike Schur’s other shows is there a possibility for another crossover event like the one with “New Girl” now that you’re all in the NBC family together?

We don’t have our writers’ room convened for the season yet so we haven’t talked about stories. …It’s unlikely we’ll have a crossover, but you never know. For one thing one of Mike’s shows doesn’t take place in our standard living reality so that makes that one difficult. I do think it’s hard to imagine doing a crossover with “The Good Place.”

Have you started imaging how a 13 episode order versus 22 or 23 order will affect the storytelling?

We’re really excited to have a 13-episode season, that’s going to be one of the first things we talk about in the writers’ room, is how to structure that. That affords us a lot of creative opportunities. I don’t know exactly how we’re going to approach it, I have a few thoughts and am really curious what the other writers have to say, but I’m excited that it gives us more time per episode. Twenty-two episodes is so grueling; it’s nice to have a little bit more time to focus on each one.

There were a lot of actors publicly supporting you guys on social media, have you started dream casting anyone for the new season?

All of these stars who came out to support us are people whom we are huge fans of so I would love to have any one or more of them on the show in some capacity. That is definitely a wish list. Obviously because they’re such big stars and good at what they do their availability is limited. And we haven’t broke any stories but I would die to have any of them on the show.

Is it safe to say that, although you’d been on the bubble before, this season you had an increased awareness of a potential cancellation?

Yes I think it’s fair to say this season that was the case. Our time slot was Tuesdays at 9:30 when we started and that’s not a time slot that has a lot of eyeballs on it no matter who’s there. We were aware, looking at our ratings that we were on the bubble, and then when they brought us back early and put us on Sunday nights that felt like a real vote of confidence. But at the end of the day I don’t think any of the specifics of our show and the ratings mattered as much as the fact that Fox seems to have made a strategic shift away from single-cams towards multicams. It’s funny because we spent so much time — you can’t help it — but really analyzing what your ratings mean or what it means to be on, but at the end of the day there were much larger issues at play than the reception of any of the individual shows.

Given that awareness, did you take creative chances and push the envelope with certain elements in season 5, like Rosa’s coming out storyline or “The Box” episode?

We really tried to push the envelope a bunch this season. There were two factors. Mainly the year before we did the “Moo Moo” episode in which Terry [Terry Crews] was racially profiled. That was a tonal shift for us and an experiment, and we were really happy with the way it turned out. It opened us up to doing more of those sorts of episodes. The other factor wasn’t that we were afraid we wouldn’t come back, but after you’ve done 100 episodes, to keep it fresh for the writers and actors and crew, it’s fun and necessary to challenge yourselves. We wanted to do these episodes because they seemed interesting. Going back to that question about a 13-episode order, we’re committed to doing the same show we’ve been doing. I feel like season five was one of our most successful years creatively and with 13 we still want to find a way to do your standard issue “Brooklyn Nine-Nine” episodes where the squad is hanging out and solving crimes, but we want to do things like “The Box” and challenging things like Rosa coming out or “Moo Moo” too. The other aspect about 13 is it might be interesting to do some more arcs for Jake and the squad or a crime that they follow over several episodes. But again we haven’t broken the room so it’s not clear but those are the considerations that we’ve been thinking about.

Fred Armisen was back for the finale, was that a nod to the pilot?

Yes. He was in the pilot, he was in the Super Bowl episode and he was in “Jake & Amy.” In fact my only fear about having him back, because we all love Fred and the Melipnos character, my only thing was that people would think it was such a bookend that it was a series finale.

Did you learn anything crafting Leslie and Ben’s wedding on “Parks and Recreation” that you applied to Jake and Amy’s wedding?

We did learn from it. The fact is we faced a similar challenge here that we had faced in the “Parks’” writing room. We had two characters who loved each other and wanted to get married. Therefore it’s difficult to figure out what the stakes are going to be. Also we had a similarity in that they are both workplace romances and that their loved ones that the viewers care about are their workmates and not relatives or outside friends. So we faced the same challenges and in a broad way. Where there’s like an external force that disrupts the wedding and then they have to sort of rally together. I was really conscious of trying not to do the same thing, which is one of the reasons that we spend a little less time on for instance, the mechanism by which they all kind of rally in order to make the wedding happen. And there were different emotional stories. But it did influence us for sure. At “Parks” it was such a great writers room and working with Mike was so great. But I think the most influences are just in the sort of general concept of what should happen given that the characters ultimately do want to get married.

Heading into the new season do you now try to top yourself or do you pull back into a “business as usual” mode?

What I like about the show is that we do a variety of different episodes. We make episodes like the wedding, but we also do episodes where most of the comedy and story is them hanging out in the bullpen joking with one another. It becomes a trap if you’re constantly trying to top yourself because then the show goes too much in one direction with higher and higher stakes. I wouldn’t say that we would pull back in the sense that I don’t want to make it sound like we’re going to do a less good story to follow up that wedding, but we might go in a different direction. We have a lot to accomplish because it’s our first episode back, it’s our first episode on NBC, it’s a season premiere, we have a cliffhanger, and it will be the 113th episode of the show. Really it’s a puzzle to figure out. But I think the writers on the show are most excited when there is a puzzle like that to figure out.

Do you know whether Holt got the Commissioner gig at this point?

Yes, I do know what Holt’s face meant. We have an idea of where we’re going and what’s happening with Holt and the commissioner job.