At the start, Nathan Fillion is dressed up as a "space cowboy". This is essentially the same outfit that he wore as Captain Malcolm Reynolds in the TV show Firefly (2002) and in the movie Serenity (2005). Molly C. Quinn continues the joke when she says "there are no cows in space" (in Firefly (2002) "Safe", Captain Reynolds transports a load of cattle to another planet), "didn't you wear that, like, five years ago" and "don't you think you should move on" (Serenity (2005) was released in 2005, or about "five years ago"). Actor Seamus Dever also dresses up as a former character - a doctor at the Halloween party. Det. Ryan's actor has played a doctor in both General Hospital (1963) and Army Wives (2007).
In a flip of fates, after Alexis mentions how Castle wore his "Space Cowboy"/"Mal Reynolds" costume 5 years before, Castle suggests Alexis should dress as "Hermione Granger" from Harry Potter. Roughly 5 years after the episode aired, Molly C. Quinn would portray Hermione in episode of the YouTube Series "Princess Rap Battles"
When Castle tells Beckett that he's giving her the bird, this is meant as a double entendre. First, it means he's giving her the stuffed bird he's holding, but it's also a subtle way of giving her "the finger".