small refactoring mostly repair.cpp
comments