fix saved state bugs