Correct error recovery and better error reporting