If there’s any reason to recommend Ted 2, it’s that the film absorbs the extreme position against gay marriage—”What if someone wants to marry their pet?”—and subverts it into a plotline reinforcing marriage equality.

Unfortunately, the connective tissue binding this and the rest of the film’s sporadic flourishes of comedic efficacy is the strained sinew of expletive-laden scatalogy. It’s writer-director Seth MacFarlane’s scattershot approach evocative of the best (and worst) Abrahams-Zucker movies. Some gags land with flair—many more land with a thud.

Once Ted (voiced by MacFarlane) and his new wife Tami-Lynn (Jessica Barth) are denied the chance to adopt a child, the government reassesses Ted’s entire legal status. Soon, Ted loses his job, credit cards and pizza rewards membership. His marriage is also nullified, prompting Ted and his Thunder Buddy for life John Bennett (Mark Wahlberg, still showing terrific comic timing) to seek legal redress with the aid of 26-year-old rookie lawyer Samantha Lynn Jackson (Amanda Seyfried).

Yes, her name is Sam L. Jackson, and that’s the caliber of comedy coursing throughout Ted 2—I’d bet weekly wages that MacFarlane hoped to cast the actual Samuel L. Jackson in the role of a big shot civil rights attorney, played instead by Morgan Freeman. And for a film full of incongruously somber speeches about equality, there’s an inordinate reliance on gay and race-based chuckles. When Ted visits a sperm bank and is shown the room where clean samples are separated from those infected with “cystic fibrosis, sickle-cell anemia and other genetic defects,” you can see the racial joke coming around the corner.

But then there are scenes like Ted and John crashing an improv comedy show to shout out sad scenarios for the actors: 9/11, Robin Williams, Ferguson, Bill Cosby, Charlie Hebdo and “Robin Williams on 9/11.” It’s subversive, semi-offensive and searingly hilarious.

There’s an off-color Jay Leno cameo. Liam Neeson, in his Taken persona, buys a box of Trix cereal at a grocery store (it works, trust me). Patrick Warburton and Michael Dorn play gay lovers who attend New York’s Comic Con dressed as The Tick and Worf from “Star Trek: The Next Generation,” the actors’ respective erstwhile television characters. And Seyfried—with her distinctive eyes—allows herself to be compared to Gollum from The Lord of the Rings on multiple occasions.

But it’s difficult to intone about the legal precedent of Dred Scott and Plessy v. Ferguson one minute, and then reel off another phallic pothead pun or politically incorrect non sequitur the next without losing your satirical edge … and your audience.