Added support for pre and post (success/failure) scripting.