Added a way to call functions before and after updating graphs