With a few exceptions (Liz taping the pilot for her failed talk show, Jenna dating James Franco), the fourth season of "30 Rock" was so dire that I came close to walking away from it altogether a few times, and was relieved the Emmys didn't rubber stamp another Outstanding Comedy Series win for the show.

But a very funny thing happened as the fifth season (which ends tomorrow night at 10) got going: "30 Rock" became good again. At times, close to its early greatness.

It's not as perfectly-executed as "Parks and Recreation" is right now, not as conceptually-ambitious as "Community" (and I didn't like its one big experiment, the live episode, very much), nor does it have the pathos of the Michael Scott farewell arc on "The Office" (which has had a weaker overall season than "30 Rock," but probably a more memorable one), but there have been weeks (particularly in the fall, before "Parks and Rec" came back) where "30 Rock" made me laugh longer, louder and more frequently than not only every other NBC sitcom, but every comedy on TV.

So what changed? Given the anything-for-a-yuk ethos of Tina Fey and company, it would be easy to say that the show just got funnier. But the changes go deeper than that, including:

The focus got tighter: "30 Rock" has a fairly large ensemble, particularly when you factor in characters like Grizz, Dotcom, Tofer and Lutz who aren't in the opening credits but appear almost every week, not to mention frequently recurring characters like Dr. Spaceman, Danny and whoever Jack's corporate boss is at the time. Yet there's a clear separation between Liz, Jack and Tracy and almost everyone else, and the writing of season 5 seemed to acknowledge that. The show leaned more heavily on the Jack/Liz friendship than ever, made Tracy more prominent with his quest to win an Oscar, and was much more sparing in its use of Jenna (who has her uses but is very one-note), Kenneth (whose comedic value was largely exhausted a couple of seasons ago) and the "TGS" writers (where Scott Adsit's Pete is the only one seemingly able to carry his own unfortunately rare storylines).

Not surprisingly, the season's weakest stretch came when Tracy Morgan had to take a medical leave of absence and the show had to go further down the bench. (Earlier in the year, a few of my readers had been lamenting the lack of time spent with the writing staff; after a few of the Tracy-less episodes, most of them seemed to understand it was probably for the best.)

If Baldwin ever carries out his threat to leave the show (if not show business itself) after his contract expires, this could be a huge problem, but right now, the top-heavy approach is working very well.

Less schadenfreude for Liz:
Liz Lemon's struggle to find both personal and professional fulfillment - preferably at the same time - is one of the key themes of "30 Rock," but there were times the last couple of seasons where Fey and the other writers seemed to take so much pleasure from rubbing Liz's face in her own misery that it became unpleasant to watch.

Liz spent much of this year in a long-distance relationship with airline pilot Carol (played by game-for-anything Matt Damon), which was a genius move. It gave Liz back just enough dignity that she wasn't a pathetic caricature, and it allowed her a relatively happy, stable personal life for a while without actually requiring we spend much time with her and her boyfriend. After all, for as much as Liz wants a man of her own, the most important relationship in her life from a "30 Rock" perspective is with Jack Donaghy.

And speaking of which, the show did some good work showing how that friendship has evolved after five years, doing episodes where Liz and Jack were forced either by circumstance or their own neuroses to spend time apart and then reunite. In general, "30 Rock" isn't a show that takes its characters or its emotions seriously, but it usually invests the Jack/Liz friendship with much more gravity than anything else, and Fey and Baldwin had some very strong, warm moments together this year.

Smarter use of guest stars: "30 Rock" seemed to be drowning in high-profile guest stars in seasons 3 and 4. I haven't done the math to compare the total number of guest stars from season 5 to the two previous years - and wouldn't be surprised, in fact, if the total was roughly the same or even greater. But where in previous years, episodes often felt like they were being driven by the presence of big names like Steve Martin, Jennifer Aniston or Julianne Moore, this season the guest stars largely felt like part of the show. It helped that most of them were familiar faces like Jon Hamm (Liz's pretty but dum ex), Alan Alda (Jack's liberal biological father) or Elizabeth Banks (Jack's conservative pundit wife). And when the guests were new, they were either well-integrated for the long haul (Ken Howard as the folksy head of Kabletown) or deployed so hilariously (John Slattery as a woefully-unqualified political candidate) that it didn't matter how much of an episode was being given over to them.

It was funnier: Okay, maybe it really is that simple.

Alan Sepinwall may be reached at sepinwall@hitfix.com