Fix error recovery bug