Bug fixing for finalReplayAndSwap