added flag filled and corrected for proper saving when the state is loaded from a file