better rest and repair logic, improving debug infos