Hoitz is basically Dignam, reassigned and demoted instead of left on his own to kill off Sullivan as per Reality Ensues. Bonus points for Gamble ambushing Hoitz in his own apartment.
Also, when Terry is in group therapy for officers who have had to fire their weapons in the line of duty, everyone but him is extremely proud of themselves. In The Departed, Leonardo DiCaprio's character tells his therapists that cops who cry about having to fire a weapon is something made-up for tv, and that real cops love it.
He could also be the other Wahlberg's cop role. Made particularly obvious with a non sequitur slo-mo pub crawl.
And Gamble yelling at length about injuries (or even a hangover) comes all the way from his role in the first two Austin Powers movies.
Speaking of hangovers, Rob Riggle demands his taser back from a class of schoolchildren, parodying his One-Scene Wonder role in The Hangover.
One of the old men singing in the bar with Gamble is Malachy McCourt of Angela's Ashes, not the actor who played him in the movie adaptation but the actual man himself.
Playing Against Type: For a long time now, Ferrell has mostly been known for playing immature Man Children. His portrayal of the nerdy, straight-laced, and prudish Allen Gamble is marked departure from that norm.