Fix bugs on panic mode error recovery