Move the "last task" hack into ReplaySession.

#603