I also thought this episode was a set up for the new Derrick Storm series.
I thought this episode was about Castle as a sleeper agent. They activate him for short term assignments but he doesn't overtly remember anything specific about them when not activated. This assignment lasted longer than most (2 months). I think Martha knows about these - she was very "let's not ask too many questions" throughout the episode. Not exactly Manchurian Candidate, but a lighter version where she knows but does not control.
Here's the real speculation - Castle's handler is an agent named Derrick Storm. Storm's as real as Beckett in the fictional universe and the new series will be about the "real" Derrick Storm, not the Castle fictional character. The Derrick Storm novels were based on what Castle remembers about his real adventures as a sleeper agent along with Storm. He didn't just do research on tsunamis, he lived through one on a case with Storm but cannot recall that part, only the lingering "irrational" fear and the notion that he had researched them.
Just a theory, but a couple of pieces seem to fit and it would set up the new series quite nicely.