I don't get why these need to be exposed (each of these is only called once). Why not just call `doCleanup` etc with the appropriate arguments? We can make those `private[spark]` if necessary for testing.