Cleaned up the recovery code