Added state saving