Added ability to set state saving duration