To run R:
Prepare to run script.
Clean up after running script.
Prepare to run a callback.
Clean up after running a callback.