minor bug fixes for state restoration