Cleaning up replay code a bit