Refactoring and changes to support Replay detection