Bail bondsman Deon Carver is murdered in his office. A bloody shoeprint is found near the body. Beckett discovers a bug hidden inside a desk calculator. Carver's wife, Brooke, says she doesn't recognize the symbol-ridden paper that was found on her hubby after Castle places it in her trembling hands. Castle thinks the symbols on the paper could represent some kind of code. Hmm.
Carver had an argument with a criminal named Random Pierce, who is apprehended by bounty hunter Mike Royce, an ex-cop who was also Beckett's training officer when she was a rookie. It's obvious these two were very close. We're just wondering how close. Beckett releases Random to Royce so he can collect his bounty at Central Booking. Royce is grateful and asks Castle to take a quick snapshot of him with Beckett in front of the crime board. You know, for old time's sake. FLASH!
The prints of a former felon named Clifford Stuckey were found in Carver's office. He's an old man who claims he was at the office on behalf of Random, who had broken into Stuckey's apartment. Stuckey wanted Carver to cut Random a break so he wouldn't end up like him. Beckett notices Stuckey giving the cryptic paper a more-than-passing glance at the station. Maybe it does have something to do with the case.
The bloody footprint belongs to a priest named Father Aaron Low. The good father didn't kill anyone, but says Carver was having marital troubles and he was counseling him. That explains why Brooke Carver planted that bug in her husband's office. She was checking up on him.
The team discovers that all of their suspects are connected. Father Aaron volunteers at the prison where Random served his time. Random's old cellmate, who died of heart attack, was a known associate of Clifford Stuckey. The two of them swiped $10 million in sapphires and rubies that were never found. Castle believes that mysterious paper packed with symbols is actually a treasure map. Cool!
Stuckey's old partner in crime told Father Aaron about the map while receiving the last rites. Deon Carver had been able to decipher the symbols but was killed before he could do anything about it. With a little help from Alexis, Castle cracks the code. He folds the paper in a way that makes the words "under the gun" appear. Unfortunately, he has no idea what this means.
Meanwhile, Beckett has a drink with her old training officer, Royce. She feels so comfortable with this guy. That is until Ryan calls to say that Royce never delivered Random to Central Booking. Beckett now knows that Royce lied to her and may even be a murderer.
Castle realizes that the picture he took of Royce and Beckett had the map in the background. When Royce calls the station, Beckett bears her soul about the betrayal she feels from a man she once loved. Castle is shocked to learn that such a heartfelt speech was all an acted to get a trace on the call. But the anguished look on Beckett's face let us know that this "act" stemmed from some painful reality.
Thanks to her bug, Brooke Carver heard plans to cut her out of millions. She killed her husband after he figured out the symbols were gravesites. The treasure must be buried under a headstone bearing the name "Gunn." The team hits a cemetery where Brooke, Stuckey, Royce, Beckett, Ryan and Esposito all draw guns on each other. Castle's the only one without a weapon, so he gets to dig for buried treasure. Instead, he shovels dirt into Brooke and Stuckey's face. The distraction allows all the cops to take down all the bad guys, including Mike Royce. This is a truly bittersweet collar for Beckett.
In a side story, Alexis has been serving her dad breakfast in bed in order to sway him into letting her have a scooter. Beckett believes Alexis is entering he bad girl phase. She went through it and even had a motorcycle. Castle's request for photographic evidence of Beckett in her biker chick days is denied. Beckett says, "I don't think you can handle the sight of me straddling it in tight, black leather." Kate Beckett is a wise woman.