Refactor replay detection

Re-work the replay detection additions so that deserialize_msg() is
minimally changed before. A bunch of refactoring was done that didn't
improve anything and wasn't needed.

Change-Id: Ic2d48c957643dcd6217ebc6534398f483d6a8f16