Refactor record and replay such that the replay tool emits the same files as record