Added better recovery code.