Added support for running custom code before save session